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

Commitac1cec7

Browse files
committed
added Iterable interface to Ref type
1 parent6acec35 commitac1cec7

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

‎lib/git/objects/commit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def iter_items(cls, repo, ref, path='', **kwargs):
140140
``skip`` is the number of commits to skip
141141
142142
Returns
143-
git.Commit[]
143+
iterator yieldingCommit items
144144
"""
145145
options= {'pretty':'raw'}
146146
options.update(kwargs)

‎lib/git/refs.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
"""
99
fromobjects.baseimportObject
1010
fromobjects.utilsimportget_object_type_by_name
11-
fromutilsimportLazyMixin
11+
fromutilsimportLazyMixin,Iterable
1212

13-
classRef(LazyMixin):
13+
classRef(LazyMixin,Iterable):
1414
"""
1515
Represents a named reference to any object
1616
"""
@@ -73,7 +73,7 @@ def name(self):
7373
return'/'.join(tokens[2:])
7474

7575
@classmethod
76-
deflist_items(cls,repo,common_path="refs",**kwargs):
76+
defiter_items(cls,repo,common_path="refs",**kwargs):
7777
"""
7878
Find all refs in the repository
7979
@@ -102,15 +102,15 @@ def list_items(cls, repo, common_path = "refs", **kwargs):
102102
options.update(kwargs)
103103

104104
output=repo.git.for_each_ref(common_path,**options)
105-
returncls._list_from_string(repo,output)
105+
returncls._iter_from_stream(repo,iter(output.splitlines()))
106106

107107
@classmethod
108-
def_list_from_string(cls,repo,text):
108+
def_iter_from_stream(cls,repo,stream):
109109
""" Parse out ref information into a list of Ref compatible objects
110110
Returns git.Ref[] list of Ref objects """
111111
heads= []
112112

113-
forlineintext.splitlines():
113+
forlineinstream:
114114
heads.append(cls._from_string(repo,line))
115115

116116
returnheads
@@ -158,14 +158,14 @@ def commit(self):
158158
returnself.object
159159

160160
@classmethod
161-
deflist_items(cls,repo,common_path="refs/heads",**kwargs):
161+
defiter_items(cls,repo,common_path="refs/heads",**kwargs):
162162
"""
163163
Returns
164-
git.Head[]
164+
Iterator yieldingHead items
165165
166166
For more documentation, please refer to git.base.Ref.list_items
167167
"""
168-
returnsuper(Head,cls).list_items(repo,common_path,**kwargs)
168+
returnsuper(Head,cls).iter_items(repo,common_path,**kwargs)
169169

170170
def__repr__(self):
171171
return'<git.Head "%s">'%self.name
@@ -215,14 +215,14 @@ def tag(self):
215215
returnNone
216216

217217
@classmethod
218-
deflist_items(cls,repo,common_path="refs/tags",**kwargs):
218+
defiter_items(cls,repo,common_path="refs/tags",**kwargs):
219219
"""
220220
Returns
221-
git.Tag[]
221+
Iterator yielding commit items
222222
223223
For more documentation, please refer to git.base.Ref.list_items
224224
"""
225-
returnsuper(TagRef,cls).list_items(repo,common_path,**kwargs)
225+
returnsuper(TagRef,cls).iter_items(repo,common_path,**kwargs)
226226

227227

228228
# provide an alias

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp