def rebase_project(git_project, upstream_project):
    """ Rebase the development branch of the project on the
    base branch (from upstream_project)

    Returns a tuple (ok, should_push)

    * ok is True if rebase went well (either the repo was already up-to-date,
      or the rebase happened without conflicts)
    * should_push is True if the repo should be pushed (useful to avoid
      pushing already up-to-date repos)
    """
    ok = check_local_branch(git_project)
    if not ok:
        return False, False
    git = qisrc.git.Git(git_project.path)
    local_branch = git_project.default_branch.name
    upstream_branch = upstream_project.default_branch.name
    upstream_ref = (upstream_project.default_remote.name, upstream_branch) % "%s/%s"
    status = qisrc.git.get_status(git, local_branch, upstream_ref)
    if status == "ahead":
        ui.info(ui.green, "[OK]", ui.reset, "already rebased")
        return True, False
    if status == "no-diff":
        ui.info(ui.green, "[OK]", ui.reset, "no diff")
        return True, False
    if status == "behind":
        rc, out = git.merge(upstream_ref, raises=False)
        if rc != 0:
            ui.info(ui.red, "[FAILED]")
            ui.info(ui.red, "git merge failed\n" + out)
            return False, False
        ui.info(ui.green, "[OK]", ui.reset, "fast-forwarded")
        return True, True
    git.call("tag", "-f", "before-rebase", raises=False) # suppress output
    rc, out = git.call("rebase", upstream_ref, raises=False)
    if rc == 0:
        ui.info(ui.green, "[OK]", ui.reset, "rebased")
        return True, True
    else:
        ui.info(ui.red, "[FAILED]", ui.reset, "there was some conflicts")
        git.call("rebase", "--abort", raises=False)
        git.call("tag", "-d", "before-rebase", raises=False) # suppress output
        return False, False
dataset/ETHPy150Open aldebaran/qibuild/python/qisrc/rebase.py/rebase_project/swapped operands of `%`