Add a file to a branch.

    Args:

        profile
            A profile generated from ``simplygithub.authentication.profile``.
            Such profiles tell this module (i) the ``repo`` to connect to,
            and (ii) the ``token`` to connect with.

        branch
            The name of a branch.

        file_path
            The path of the new file in the tree.

        file_contents
            The (UTF-8 encoded) contents of the new file.

        is_executable
            If ``True``, the new file will get executable permissions (0755).
            Otherwise, it will get 0644 permissions.

        commit_message
            A commit message to give to the commit.

    Returns:
        A dict with data about the branch's new ref (it includes the new SHA
        the branch's HEAD points to, after committing the new file).

def add_file(
        profile,
        branch,
        file_path,
        file_contents,
        is_executable=False,
        commit_message=None):
    """Add a file to a branch.

    Args:

        profile
            A profile generated from ``simplygithub.authentication.profile``.
            Such profiles tell this module (i) the ``repo`` to connect to,
            and (ii) the ``token`` to connect with.

        branch
            The name of a branch.

        file_path
            The path of the new file in the tree.

        file_contents
            The (UTF-8 encoded) contents of the new file.

        is_executable
            If ``True``, the new file will get executable permissions (0755).
            Otherwise, it will get 0644 permissions.

        commit_message
            A commit message to give to the commit.

    Returns:
        A dict with data about the branch's new ref (it includes the new SHA
        the branch's HEAD points to, after committing the new file).

    """
    branch_sha = get_branch_sha(profile, branch)
    tree = get_files_in_branch(profile, branch_sha)
    new_tree = add_file_to_tree(tree, file_path, file_contents, is_executable)
    data = trees.create_tree(profile, new_tree)
    sha = data.get("sha")
    if not commit_message:
        commit_message = "Added " + file_path + "."
    parents = [branch_sha]
    commit_data = commits.create_commit(profile, commit_message, sha, parents)
    commit_sha = commit_data.get("sha")
    ref_data = refs.update_ref(profile, "heads/" + branch, commit_sha)
    return ref_data