Skip to content

Commit af86f05

Browse files
Yuri Volchkovyvolchkov
authored andcommitted
Fix inheritance issue at commit.iter_items
The iterator used to yield Commit() objects, which does not play well with inheritance. Yield cls() instead. Signed-off-by: Yuri Volchkov <yuri@volch.org>
1 parent 3c19a6e commit af86f05

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

git/objects/commit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ def _iter_from_process_or_stream(cls, repo, proc_or_stream):
269269
# END handle extra info
270270

271271
assert len(hexsha) == 40, "Invalid line: %s" % hexsha
272-
yield Commit(repo, hex_to_bin(hexsha))
272+
yield cls(repo, hex_to_bin(hexsha))
273273
# END for each line in stream
274274
# TODO: Review this - it seems process handling got a bit out of control
275275
# due to many developers trying to fix the open file handles issue

test/test_commit.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,13 @@ def test_iteration(self):
199199
less_ltd_commits = list(Commit.iter_items(self.rorepo, 'master', paths=('CHANGES', 'AUTHORS')))
200200
assert len(ltd_commits) < len(less_ltd_commits)
201201

202+
class Child(Commit):
203+
def __init__(self, *args, **kwargs):
204+
super(Child, self).__init__(*args, **kwargs)
205+
206+
child_commits = list(Child.iter_items(self.rorepo, 'master', paths=('CHANGES', 'AUTHORS')))
207+
assert type(child_commits[0]) == Child
208+
202209
def test_iter_items(self):
203210
# pretty not allowed
204211
self.assertRaises(ValueError, Commit.iter_items, self.rorepo, 'master', pretty="raw")

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