From 5d602f267c32e1e917599d9bcdcfec4eef05d477 Mon Sep 17 00:00:00 2001 From: firm1 Date: Mon, 24 Mar 2014 14:52:44 +0100 Subject: add param to create_from_tree --- git/objects/commit.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'git/objects/commit.py') diff --git a/git/objects/commit.py b/git/objects/commit.py index cbfd5097..f1c2a23d 100644 --- a/git/objects/commit.py +++ b/git/objects/commit.py @@ -254,7 +254,7 @@ class Commit(base.Object, Iterable, Diffable, Traversable, Serializable): @classmethod - def create_from_tree(cls, repo, tree, message, parent_commits=None, head=False): + def create_from_tree(cls, repo, tree, message, parent_commits=None, head=False, author=None, committer=None): """Commit the given tree, creating a commit object. :param repo: Repo object the commit should be part of @@ -299,8 +299,13 @@ class Commit(base.Object, Iterable, Diffable, Traversable, Serializable): cr = repo.config_reader() env = os.environ - committer = Actor.committer(cr) - author = Actor.author(cr) + if author is None and committer is None: + committer = Actor.committer(cr) + author = Actor.author(cr) + elif author is None: + author = Actor.author(cr) + elif committer is None: + committer = Actor.committer(cr) # PARSE THE DATES unix_time = int(time()) -- cgit v1.2.1 From ba67e4ff74e97c4de5d980715729a773a48cd6bc Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Mon, 17 Nov 2014 10:59:39 +0100 Subject: Assure API remains backwards compatible; update API docs --- git/objects/commit.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'git/objects/commit.py') diff --git a/git/objects/commit.py b/git/objects/commit.py index 9ec58c52..453afe66 100644 --- a/git/objects/commit.py +++ b/git/objects/commit.py @@ -276,6 +276,10 @@ class Commit(base.Object, Iterable, Diffable, Traversable, Serializable): If True, the HEAD will be advanced to the new commit automatically. Else the HEAD will remain pointing on the previous commit. This could lead to undesired results when diffing files. + :param author: The name of the author, optional. If unset, the repository + configuration is used to obtain this value. + :param committer: The name of the committer, optional. If unset, the + repository configuration is used to obtain this value. :return: Commit object representing the new commit @@ -283,7 +287,6 @@ class Commit(base.Object, Iterable, Diffable, Traversable, Serializable): Additional information about the committer and Author are taken from the environment or from the git configuration, see git-commit-tree for more information""" - parents = parent_commits if parent_commits is None: try: parent_commits = [repo.head.commit] @@ -357,7 +360,6 @@ class Commit(base.Object, Iterable, Diffable, Traversable, Serializable): except ValueError: # head is not yet set to the ref our HEAD points to # Happens on first commit - import git.refs master = git.refs.Head.create(repo, repo.head.ref, new_commit, logmsg="commit (initial): %s" % message) repo.head.set_reference(master, logmsg='commit: Switching to %s' % master) # END handle empty repositories -- cgit v1.2.1