Skip to content

Commit 9780b7a

Browse files
committed
Merge branch '0.3' of https://github.com/firm1/GitPython into firm1-0.3
Fixed most pressing issues, more to come in next commit as we introduced a regression here. Conflicts: git/objects/commit.py git/refs/log.py git/refs/symbolic.py
2 parents 322db07 + 3a1e0d7 commit 9780b7a

File tree

4 files changed

+15
-11
lines changed

4 files changed

+15
-11
lines changed

git/index/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,7 @@ def move(self, items, skip_errors=False, **kwargs):
867867

868868
return out
869869

870-
def commit(self, message, parent_commits=None, head=True):
870+
def commit(self, message, parent_commits=None, head=True, author=None, committer=None):
871871
"""Commit the current default index file, creating a commit object.
872872
873873
For more information on the arguments, see tree.commit.
@@ -878,7 +878,7 @@ def commit(self, message, parent_commits=None, head=True):
878878
:return:
879879
Commit object representing the new commit"""
880880
tree = self.write_tree()
881-
return Commit.create_from_tree(self.repo, tree, message, parent_commits, head)
881+
return Commit.create_from_tree(self.repo, tree, message, parent_commits, head, author=author, committer=committer)
882882

883883
@classmethod
884884
def _flush_stdin_and_wait(cls, proc, ignore_stdout=False):

git/objects/commit.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ def _iter_from_process_or_stream(cls, repo, proc_or_stream):
258258
finalize_process(proc_or_stream)
259259

260260
@classmethod
261-
def create_from_tree(cls, repo, tree, message, parent_commits=None, head=False):
261+
def create_from_tree(cls, repo, tree, message, parent_commits=None, head=False, author=None, committer=None):
262262
"""Commit the given tree, creating a commit object.
263263
264264
:param repo: Repo object the commit should be part of
@@ -303,8 +303,8 @@ def create_from_tree(cls, repo, tree, message, parent_commits=None, head=False):
303303
cr = repo.config_reader()
304304
env = os.environ
305305

306-
committer = Actor.committer(cr)
307-
author = Actor.author(cr)
306+
committer = committer or Actor.committer(cr)
307+
author = author or Actor.author(cr)
308308

309309
# PARSE THE DATES
310310
unix_time = int(time())

git/refs/log.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,8 @@ def append_entry(cls, config_reader, filepath, oldbinsha, newbinsha, message):
235235
"""Append a new log entry to the revlog at filepath.
236236
237237
:param config_reader: configuration reader of the repository - used to obtain
238-
user information. May be None
238+
user information. May also be an Actor instance identifying the committer directly.
239+
May also be None
239240
:param filepath: full path to the log file
240241
:param oldbinsha: binary sha of the previous commit
241242
:param newbinsha: binary sha of the current commit
@@ -249,8 +250,9 @@ def append_entry(cls, config_reader, filepath, oldbinsha, newbinsha, message):
249250
raise ValueError("Shas need to be given in binary format")
250251
#END handle sha type
251252
assure_directory_exists(filepath, is_file=True)
252-
entry = RefLogEntry((bin_to_hex(oldbinsha), bin_to_hex(newbinsha), Actor.committer(config_reader), (int(time.time()), time.altzone), message))
253-
253+
committer = isinstance(config_reader, Actor) and config_reader or Actor.committer(config_reader)
254+
entry = RefLogEntry((bin_to_hex(oldbinsha), bin_to_hex(newbinsha), committer, (int(time.time()), time.altzone), message))
255+
254256
lf = LockFile(filepath)
255257
lf._obtain_lock_or_raise()
256258

git/refs/symbolic.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -355,9 +355,11 @@ def log_append(self, oldbinsha, message, newbinsha=None):
355355
:param newbinsha: The sha the ref points to now. If None, our current commit sha
356356
will be used
357357
:return: added RefLogEntry instance"""
358-
return RefLog.append_entry(self.repo.config_reader(), RefLog.path(self), oldbinsha,
359-
(newbinsha is None and self.commit.binsha) or newbinsha,
360-
message)
358+
# NOTE: we use the committer of the currently active commit - this should be
359+
# correct. See https://github.com/gitpython-developers/GitPython/pull/146
360+
return RefLog.append_entry(self.commit.committer, RefLog.path(self), oldbinsha,
361+
(newbinsha is None and self.commit.binsha) or newbinsha,
362+
message)
361363

362364
def log_entry(self, index):
363365
""":return: RefLogEntry at the given index

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy