Ejemplo n.º 1
0
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
Ejemplo n.º 2
0
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
Ejemplo n.º 3
0
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
Ejemplo n.º 4
0
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