def cloneUpstream(self, project, dest): # Check for a cached git repo first git_cache = '%s/%s' % (self.cache_dir, project) # Then, if we are cloning the repo for the zuul_project, then # set its origin to be the zuul merger, as it is guaranteed to # be correct and up to date even if mirrors haven't updated # yet. Otherwise, we can not be sure about the state of the # project, so our best chance to get the most current state is # by setting origin to the git_url. if (self.zuul_url and project == self.zuul_project): git_upstream = '%s/%s' % (self.zuul_url, project) else: git_upstream = '%s/%s' % (self.git_url, project) repo_is_cloned = os.path.exists(os.path.join(dest, '.git')) if (self.cache_dir and os.path.exists(git_cache) and not repo_is_cloned): # file:// tells git not to hard-link across repos git_cache = 'file://%s' % git_cache self.log.info("Creating repo %s from cache %s", project, git_cache) new_repo = git.Repo.clone_from(git_cache, dest) self.log.info("Updating origin remote in repo %s to %s", project, git_upstream) new_repo.remotes.origin.config_writer.set('url', git_upstream) else: self.log.info("Creating repo %s from upstream %s", project, git_upstream) repo = Repo(remote=git_upstream, local=dest, email=None, username=None) if not repo.isInitialized(): raise Exception("Error cloning %s to %s" % (git_upstream, dest)) return repo
def cloneUpstream(self, project, dest): # Check for a cached git repo first git_cache = '%s/%s' % (self.cache_dir, project) git_upstream = '%s/%s' % (self.git_url, project) if (self.cache_dir and os.path.exists(git_cache) and not os.path.exists(dest)): # file:// tells git not to hard-link across repos git_cache = 'file://%s' % git_cache self.log.info("Creating repo %s from cache %s", project, git_cache) new_repo = git.Repo.clone_from(git_cache, dest) self.log.info("Updating origin remote in repo %s to %s", project, git_upstream) new_repo.remotes.origin.config_writer.set('url', git_upstream) else: self.log.info("Creating repo %s from upstream %s", project, git_upstream) repo = Repo( remote=git_upstream, local=dest, email=None, username=None) if not repo.isInitialized(): raise Exception("Error cloning %s to %s" % (git_upstream, dest)) return repo
def cloneUpstream(self, project, dest): git_upstream = '%s/%s' % (self.git_url, project) self.log.info("Creating repo %s from upstream %s", project, git_upstream) repo = Repo( remote=git_upstream, local=dest, email=None, username=None) if not repo.isInitialized(): raise Exception("Error cloning %s to %s" % (git_upstream, dest)) return repo
def cloneUpstream(self, project, dest): # Check for a cached git repo first git_cache = '%s/%s' % (self.cache_dir, project) git_upstream = '%s/%s' % (self.git_url, project) if (self.cache_dir and os.path.exists(git_cache) and not os.path.exists(dest)): # file:// tells git not to hard-link across repos git_cache = 'file://%s' % git_cache self.log.info("Creating repo %s from cache %s", project, git_cache) new_repo = git.Repo.clone_from(git_cache, dest) self.log.info("Updating origin remote in repo %s to %s", project, git_upstream) new_repo.remotes.origin.config_writer.set('url', git_upstream) else: self.log.info("Creating repo %s from upstream %s", project, git_upstream) repo = Repo(remote=git_upstream, local=dest, email=None, username=None) if not repo.isInitialized(): raise Exception("Error cloning %s to %s" % (git_upstream, dest)) return repo