def _clone_missing(self, git_project, repo): """ Clone Missing """ branch = repo.default_branch fixed_ref = repo.fixed_ref clone_url = repo.clone_url qisys.sh.mkdir(git_project.path, recursive=True) git = qisrc.git.Git(git_project.path) remote_name = repo.default_remote.name try: git.init() git.remote("add", remote_name, clone_url) git.fetch(remote_name, "--quiet") if branch: git.checkout("-b", branch, "%s/%s" % (remote_name, branch)) if fixed_ref: git.checkout("-q", fixed_ref) except Exception: ui.error("Cloning repo failed") if git.is_empty(): qisys.sh.rm(git_project.path) self.worktree.remove_project(repo.src) return False self.save_project_config(git_project) self.load_git_projects() return True
def _clone_missing(self, git_project, repo): branch = repo.default_branch clone_url = repo.clone_url qisys.sh.mkdir(git_project.path, recursive=True) git = qisrc.git.Git(git_project.path) remote_name = repo.default_remote.name try: git.init() git.remote("add", remote_name, clone_url) git.fetch(remote_name, "--quiet") git.checkout("-b", branch, "%s/%s" % (remote_name, branch)) except: ui.error("Cloning repo failed") if git.is_empty(): qisys.sh.rm(git_project.path) self.worktree.remove_project(repo.src) return False self.save_project_config(git_project) self.load_git_projects() return True
def _clone_missing(self, git_project, repo): branch = repo.default_branch clone_url = repo.clone_url qisys.sh.mkdir(git_project.path, recursive=True) git = qisrc.git.Git(git_project.path) remote_name = repo.default_remote.name try: git.init() git.remote("add", remote_name, clone_url) git.fetch(remote_name, "--quiet") remote_branch = "%s/%s" % (remote_name, branch) rc, _ = git.call("rev-parse", "--verify", "--quiet", remote_branch, raises=False) # When `remote_branch` is invalid, try to checkout `branch` instead git.checkout("-b", branch, branch if rc else remote_branch) except: ui.error("Cloning repo failed") if git.is_empty(): qisys.sh.rm(git_project.path) self.worktree.remove_project(repo.src) return False self.save_project_config(git_project) self.load_git_projects() return True