def commit_docs(*, added, removed):
    """
    Commit the docs to the current branch

    Assumes that :func:`setup_GitHub_push`, which sets up the ``doctr_remote``
    remote, has been run.

    Returns True if changes were committed and False if no changes were
    committed.
    """
    TRAVIS_BUILD_NUMBER = os.environ.get("TRAVIS_BUILD_NUMBER", "<unknown>")
    TRAVIS_BRANCH = os.environ.get("TRAVIS_BRANCH", "<unknown>")
    TRAVIS_COMMIT = os.environ.get("TRAVIS_COMMIT", "<unknown>")
    TRAVIS_REPO_SLUG = os.environ.get("TRAVIS_REPO_SLUG", "<unknown>")
    TRAVIS_JOB_WEB_URL = os.environ.get("TRAVIS_JOB_WEB_URL", "<unknown>")
    TRAVIS_TAG = os.environ.get("TRAVIS_TAG", "")
    branch = "tag" if TRAVIS_TAG else "branch"

    DOCTR_COMMAND = ' '.join(map(shlex.quote, sys.argv))


    if added:
        run(['git', 'add', *added])
    if removed:
        run(['git', 'rm', *removed])

    commit_message = """\
Update docs after building Travis build {TRAVIS_BUILD_NUMBER} of
{TRAVIS_REPO_SLUG}

The docs were built from the {branch} '{TRAVIS_BRANCH}' against the commit
{TRAVIS_COMMIT}.

The Travis build that generated this commit is at
{TRAVIS_JOB_WEB_URL}.

The doctr command that was run is

    {DOCTR_COMMAND}
""".format(
    branch=branch,
    TRAVIS_BUILD_NUMBER=TRAVIS_BUILD_NUMBER,
    TRAVIS_BRANCH=TRAVIS_BRANCH,
    TRAVIS_COMMIT=TRAVIS_COMMIT,
    TRAVIS_REPO_SLUG=TRAVIS_REPO_SLUG,
    TRAVIS_JOB_WEB_URL=TRAVIS_JOB_WEB_URL,
    DOCTR_COMMAND=DOCTR_COMMAND,
    )

    # Only commit if there were changes
    if run(['git', 'diff-index', '--exit-code', '--cached', '--quiet', 'HEAD', '--'], exit=False) != 0:
        print("Committing")
        run(['git', 'commit', '-am', commit_message])
        return True

    return False
Commit the docs to the current branch

    Assumes that :func:`setup_GitHub_push`, which sets up the ``doctr_remote``
    remote, has been run.

    Returns True if changes were committed and False if no changes were
    committed.