def _update_repository(repo, current_only, fetch_only, prune):
    """Update a single git repository by fetching remotes and rebasing/merging.

    The specific actions depend on the arguments given. We will fetch all
    remotes if *current_only* is ``False``, or only the remote tracked by the
    current branch if ``True``. If *fetch_only* is ``False``, we will also
    update all fast-forwardable branches that are tracking valid upstreams.
    If *prune* is ``True``, remote-tracking branches that no longer exist on
    their remote after fetching will be deleted.
    """
    print(INDENT1, BOLD + os.path.split(repo.working_dir)[1] + ":")

    try:
        active = repo.active_branch
    except __HOLE__:  # Happens when HEAD is detached
        active = None
    if current_only:
        if not active:
            print(INDENT2, ERROR,
                  "--current-only doesn't make sense with a detached HEAD.")
            return
        ref = active.tracking_branch()
        if not ref:
            print(INDENT2, ERROR, "no remote tracked by current branch.")
            return
        remotes = [repo.remotes[ref.remote_name]]
    else:
        remotes = repo.remotes

    if not remotes:
        print(INDENT2, ERROR, "no remotes configured to fetch.")
        return
    _fetch_remotes(remotes, prune)

    if not fetch_only:
        for branch in sorted(repo.heads, key=lambda b: b.name):
            _update_branch(repo, branch, branch == active)
dataset/ETHPy150Open earwig/git-repo-updater/gitup/update.py/_update_repository