Skip to content

Fix inheritance issue at commit.iter_items #1119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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