From 9995b22d8d46c193cce1fef4215fbfc469fb6a2e Mon Sep 17 00:00:00 2001 From: Frederic Massart Date: Mon, 9 Sep 2013 15:12:55 +0800 Subject: [PATCH] Setting not to use the cache as upstream remote --- config-dist.json | 7 +++++++ lib/commands/check.py | 4 ++-- lib/workplace.py | 17 ++++++++++++----- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/config-dist.json b/config-dist.json index bffbed0..1fbeebd 100644 --- a/config-dist.json +++ b/config-dist.json @@ -146,6 +146,13 @@ // during an instance creation. If false, the symlink won't be created. "symlinkToData": false, + // By default MDK caches origin as a local mirror. It is much faster when it comes to upgrading + // a couple of instances at the same time. MDK will update the mirror as often as it needs to, + // but if you are not using MDK to upgrade your instances, you might want to disable this + // functionality to only rely on the real origin. Creating new instances will not be affected + // by this setting. + "useCacheAsUpstreamRemote": true, + // You should not edit this, this is the branch that is considered as master by developers. "masterBranch": 26, diff --git a/lib/commands/check.py b/lib/commands/check.py index a77f860..3a98700 100644 --- a/lib/commands/check.py +++ b/lib/commands/check.py @@ -203,8 +203,8 @@ class CheckCommand(Command): print 'Checking remotes' remotes = { 'mine': self.C.get('remotes.mine'), - 'stable': self.Wp.getCachedRemote(), - 'integration': self.Wp.getCachedRemote(True) + 'stable': self.Wp.getCachedRemote() if self.C.get('useCacheAsUpstreamRemote') else self.C.get('remotes.stable'), + 'integration': self.Wp.getCachedRemote(True) if self.C.get('useCacheAsUpstreamRemote') else self.C.get('remotes.integration') } myRemote = self.C.get('myRemote') upstreamRemote = self.C.get('upstreamRemote') diff --git a/lib/workplace.py b/lib/workplace.py index d9bb020..58d2b0f 100644 --- a/lib/workplace.py +++ b/lib/workplace.py @@ -93,10 +93,7 @@ class Workplace(object): os.mkdir(wwwDir, 0755) os.mkdir(dataDir, 0777) - if integration: - repository = os.path.join(self.cache, 'integration.git') - else: - repository = os.path.join(self.cache, 'moodle.git') + repository = self.getCachedRemote(integration) # Clone the instances logging.info('Cloning repository...') @@ -106,7 +103,7 @@ class Workplace(object): if os.path.islink(linkDir): os.remove(linkDir) if os.path.isfile(linkDir) or os.path.isdir(linkDir): # No elif! - logging.warning('Could not create symbolic link. Please manually create: ln -s %s %s' (wwwDir, linkDir)) + logging.warning('Could not create symbolic link. Please manually create: ln -s %s %s' % (wwwDir, linkDir)) else: os.symlink(wwwDir, linkDir) @@ -119,6 +116,9 @@ class Workplace(object): logging.info('Checking out branch...') repo = git.Git(wwwDir, C.get('git')) + # Removing the default remote origin coming from the clone + repo.delRemote('origin') + # Setting up the correct remote names repo.setRemote(C.get('myRemote'), C.get('remotes.mine')) repo.setRemote(C.get('upstreamRemote'), repository) @@ -133,6 +133,13 @@ class Workplace(object): repo.checkout(branch) repo.pull(remote=C.get('upstreamRemote')) + # Fixing up remote URLs if need be, this is done after pulling the cache one because we + # do not want to contact the real origin server from here, it is slow and pointless. + if not C.get('useCacheAsUpstreamRemote'): + realupstream = C.get('remotes.integration') if integration else C.get('remotes.stable') + if realupstream: + repo.setRemote(C.get('upstreamRemote'), realupstream) + M = self.get(name) return M -- 2.11.0