Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6bfdf93

Browse files
committed
Commit.iter_items: Will not restrict comits to the ones containing changes to paths anymore as it will only append '--' if paths are actually given.
Added unittest to verify this
1 parent3e14ab5 commit6bfdf93

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

‎lib/git/objects/commit.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,13 @@ def iter_items(cls, repo, rev, paths='', **kwargs):
165165
"""
166166
options= {'pretty':'raw','as_process' :True }
167167
options.update(kwargs)
168+
169+
args=list()
170+
ifpaths:
171+
args.extend(('--',paths))
172+
# END if paths
168173

169-
proc=repo.git.rev_list(rev,'--',paths,**options)
174+
proc=repo.git.rev_list(rev,args,**options)
170175
returncls._iter_from_process_or_stream(repo,proc,True)
171176

172177
defiter_parents(self,paths='',**kwargs):

‎test/git/test_commit.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,24 @@ def test_traversal(self):
9292
# sha )
9393
assertlen(first.parents)==0
9494

95+
deftest_iteration(self):
96+
# we can iterate commits
97+
all_commits=Commit.list_items(self.rorepo,'master')
98+
assertall_commits
99+
assertall_commits==list(self.rorepo.iter_commits())
100+
101+
# this includes merge commits
102+
mcomit=Commit(self.rorepo,'d884adc80c80300b4cc05321494713904ef1df2d')
103+
assertmcomitinall_commits
104+
105+
# we can limit the result to paths
106+
ltd_commits=list(self.rorepo.iter_commits(paths='CHANGES'))
107+
assertltd_commitsandlen(ltd_commits)<len(all_commits)
108+
109+
# show commits of multiple paths, resulting in a union of commits
110+
less_ltd_commits=list(Commit.iter_items(self.rorepo,'master',paths=('CHANGES','AUTHORS')))
111+
assertlen(ltd_commits)<len(less_ltd_commits)
112+
95113

96114
@patch_object(Git,'_call_process')
97115
deftest_rev_list_bisect_all(self,git):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp