Skip to content

Commit

Permalink
Merge pull request gitpython-developers#1119 from yvolchkov/master
Browse files Browse the repository at this point in the history
Fix inheritance issue at commit.iter_items
  • Loading branch information
Byron authored Feb 5, 2021
2 parents 3c19a6e + af86f05 commit 9de6450
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion git/objects/commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ def _iter_from_process_or_stream(cls, repo, proc_or_stream):
# END handle extra info

assert len(hexsha) == 40, "Invalid line: %s" % hexsha
yield Commit(repo, hex_to_bin(hexsha))
yield cls(repo, hex_to_bin(hexsha))
# END for each line in stream
# TODO: Review this - it seems process handling got a bit out of control
# due to many developers trying to fix the open file handles issue
Expand Down
7 changes: 7 additions & 0 deletions test/test_commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,13 @@ def test_iteration(self):
less_ltd_commits = list(Commit.iter_items(self.rorepo, 'master', paths=('CHANGES', 'AUTHORS')))
assert len(ltd_commits) < len(less_ltd_commits)

class Child(Commit):
def __init__(self, *args, **kwargs):
super(Child, self).__init__(*args, **kwargs)

child_commits = list(Child.iter_items(self.rorepo, 'master', paths=('CHANGES', 'AUTHORS')))
assert type(child_commits[0]) == Child

def test_iter_items(self):
# pretty not allowed
self.assertRaises(ValueError, Commit.iter_items, self.rorepo, 'master', pretty="raw")
Expand Down

0 comments on commit 9de6450

Please sign in to comment.