// 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,
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')
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...')
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)
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)
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