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 = (project.default_remote.name, project.default_branch.name) % "%s/%s"

    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
dataset/ETHPy150Open aldebaran/qibuild/python/qisrc/status.py/check_state/swapped operands of `%`