def test_get_ref_sha1(tmpdir): a_git = tmpdir.mkdir("a_git_project") git = qisrc.git.Git(a_git.strpath) assert git.is_valid() == False git.init() assert git.is_valid() == True
def check_state(project, untracked): """ Check and register the state of a project. """ state_project = ProjectState(project) git = qisrc.git.Git(project.path) if not git.is_valid(): state_project.valid = False return state_project state_project.clean = git.is_clean(untracked=untracked) if project.fixed_ref: state_project.ahead, state_project.behind = stat_fixed_ref(git, project.fixed_ref) state_project.fixed_ref = project.fixed_ref _set_status(git, state_project, untracked=untracked) return state_project state_project.current_branch = git.get_current_branch() state_project.tracking = git.get_tracking_branch() if project.default_remote and project.default_branch: state_project.manifest_branch = "%s/%s" % (project.default_remote.name, project.default_branch.name) if state_project.current_branch is None: state_project.not_on_a_branch = True return state_project if project.default_branch: if state_project.current_branch != project.default_branch.name: state_project.incorrect_proj = True (state_project.ahead, state_project.behind) = stat_tracking_remote( git, state_project.current_branch, state_project.tracking) if state_project.incorrect_proj: (state_project.ahead_manifest, state_project.behind_manifest) = stat_tracking_remote( git, state_project.current_branch, "%s/%s" % ( project.default_remote.name, project.default_branch.name)) _set_status(git, state_project, untracked=untracked) return state_project
def check_state(project, untracked): """Check and register the state of a project.""" state_project = ProjectState(project) git = qisrc.git.Git(project.path) if not git.is_valid(): state_project.valid = False return state_project state_project.clean = git.is_clean(untracked = untracked) state_project.current_branch = git.get_current_branch() state_project.tracking = git.get_tracking_branch() #clean worktree, but is the current branch sync with the remote one? if state_project.clean: if state_project.current_branch is None: state_project.not_on_a_branch = True return state_project if state_project.current_branch != project.branch: state_project.incorrect_proj = True (state_project.ahead, state_project.behind) = stat_tracking_remote(git, state_project.current_branch, state_project.tracking) if not state_project.sync_and_clean: out = git.get_status(untracked) if out is not None: state_project.status = [ x[:3] for x in out.splitlines() if len(x.strip()) > 0 ] return state_project
def check_state(project, untracked): """Check and register the state of a project.""" state_project = ProjectState(project) git = qisrc.git.Git(project.path) if not git.is_valid(): state_project.valid = False return state_project state_project.clean = git.is_clean(untracked=untracked) if project.fixed_ref: state_project.ahead, state_project.behind = stat_fixed_ref( git, project.fixed_ref) state_project.fixed_ref = project.fixed_ref _set_status(git, state_project, untracked=untracked) return state_project state_project.current_branch = git.get_current_branch() state_project.tracking = git.get_tracking_branch() if project.default_remote and project.default_branch: state_project.manifest_branch = "%s/%s" % (project.default_remote.name, project.default_branch.name) if state_project.current_branch is None: state_project.not_on_a_branch = True return state_project if project.default_branch: if state_project.current_branch != project.default_branch.name: state_project.incorrect_proj = True (state_project.ahead, state_project.behind) = stat_tracking_remote(git, state_project.current_branch, state_project.tracking) if state_project.incorrect_proj: (state_project.ahead_manifest, state_project.behind_manifest) = stat_tracking_remote( git, state_project.current_branch, "%s/%s" % (project.default_remote.name, project.default_branch.name)) _set_status(git, state_project, untracked=untracked) return state_project
def check_state(project, untracked): """Check and register the state of a project.""" state_project = ProjectState(project) git = qisrc.git.Git(project.path) if not git.is_valid(): state_project.valid = False return state_project state_project.clean = git.is_clean(untracked=untracked) state_project.current_branch = git.get_current_branch() state_project.tracking = git.get_tracking_branch() if project.default_remote and project.default_branch: state_project.manifest_branch = "%s/%s" % (project.default_remote.name, project.default_branch.name) if state_project.current_branch is None: state_project.not_on_a_branch = True return state_project if project.default_branch: if state_project.current_branch != project.default_branch.name: state_project.incorrect_proj = True (state_project.ahead, state_project.behind) = stat_tracking_remote(git, state_project.current_branch, state_project.tracking) if state_project.incorrect_proj: (state_project.ahead_manifest, state_project.behind_manifest) = stat_tracking_remote( git, state_project.current_branch, "%s/%s" % (project.default_remote.name, project.default_branch.name)) if not state_project.sync_and_clean: out = git.get_status(untracked) if out is not None: state_project.status = [ x for x in out.splitlines() if len(x.strip()) > 0 ] return state_project
def clone_missing(self, repo): """ Add a new project. :returns: a boolean telling if the clone succeeded """ worktree_project = self.worktree.add_project(repo.src) git_project = qisrc.project.GitProject(self, worktree_project) if os.path.exists(git_project.path): git = qisrc.git.Git(git_project.path) git_root = qisrc.git.get_repo_root(git_project.path) if not git_root == git_project.path: # Nested git projects: return self._clone_missing(git_project, repo) if git.is_valid() and git.is_empty(): ui.warning("Removing empty git project in", git_project.src) qisys.sh.rm(git_project.path) else: # Do nothing, the remote will be re-configured later # anyway return True return self._clone_missing(git_project, repo)