def clone_or_pull(self): if not self.remote_available(): raise exceptions.GitException( self, "Cannot clone or pull Git repository") try: if os.path.isdir(self.clone_dir): git_repo = GitRepo(self.clone_dir) git_repo.remotes.origin.fetch(tags=True, force=True) git_repo.git.reset("--hard", "origin/master") else: git_repo = GitRepo.clone_from(self.git_url, self.clone_dir) except GitError: raise exceptions.GitException( self, "Cannot clone or pull Git repository") self.git_repo = git_repo
def clone_or_pull(self): try: if os.path.isdir(self.clone_dir): git_repo = GitRepo(self.clone_dir) git_repo.remotes.origin.pull("refs/heads/master:refs/heads/origin") else: git_repo = GitRepo.clone_from(self.git_url, self.clone_dir) except GitError: raise exceptions.GitException(self, "Cannot clone or pull Git repository") self.git_repo = git_repo
def checkout_tag(self, tag): try: self.git_repo.git.checkout(self.find_git_tag(tag)) except GitError: raise exceptions.GitException(self, "Cannot checkout tag %s" % tag) self.current_tag = tag