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

Commit0b3ecf2

Browse files
committed
commit.count: is an instance method now
repo: added head , tag and iter_trees methods for completenesschanges: headlines now sorted chronologically
1 parent11b1f6e commit0b3ecf2

File tree

7 files changed

+103
-65
lines changed

7 files changed

+103
-65
lines changed

‎CHANGES‎

Lines changed: 46 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,40 @@ objects Package
4545
not affect you though unless you explicitly imported individual objects. If you just
4646
used the git package, names did not change.
4747

48+
Blob
49+
----
50+
* former 'name' member renamed to path as it suits the actual data better
51+
52+
Commit
53+
------
54+
* 'count' method is not an instance method to increase its ease of use
55+
56+
Config
57+
------
58+
* The git configuration can now be read and manipulated directly from within python
59+
using the GitConfigParser
60+
* Repo.config_reader returns a read-only parser
61+
* Repo.config_writer returns a read-write parser
62+
63+
Diff
64+
----
65+
* Members a a_commit and b_commit renamed to a_blob and b_blob - they are populated
66+
with Blob objects if possible
67+
* Members a_path and b_path removed as this information is kept in the blobs
68+
* Diffs are now returned as DiffIndex allowing to more quickly find the kind of
69+
diffs you are interested in
70+
71+
Diffing
72+
-------
73+
* Commit and Tree objects now support diffing natively with a common interface to
74+
compare agains other Commits or Trees, against the working tree or against the index.
75+
76+
Refs
77+
----
78+
* Will dynmically retrieve their object at the time of query to assure the information
79+
is actual. Recently objects would be cached, hence ref object not be safely kept
80+
persistent.
81+
4882
Repo
4983
----
5084
* Moved blame method from Blob to repo as it appeared to belong there much more.
@@ -73,24 +107,19 @@ Repo
73107
- archive_tar_gz and archive_tar and replaced by archive method with different signature
74108
* 'commits' method has no max-count of returned commits anymore, it now behaves
75109
like git-rev-list
76-
* 'untracked_files' property added, returning all currently untracked files
77-
78-
Diff
79-
----
80-
* Members a a_commit and b_commit renamed to a_blob and b_blob - they are populated
81-
with Blob objects if possible
82-
* Members a_path and b_path removed as this information is kept in the blobs
83-
* Diffs are now returned as DiffIndex allowing to more quickly find the kind of
84-
diffs you are interested in
110+
* The following methods and properties were added
111+
- 'untracked_files' property, returning all currently untracked files
112+
- 'head', creates a head object
113+
- 'tag', creates a tag object
114+
- 'iter_trees' method
115+
- 'config_reader' property
116+
- 'config_writer' property
85117

86-
Diffing
87-
-------
88-
* Commit and Tree objects now support diffing natively with a common interface to
89-
compare agains other Commits or Trees, against the working tree or against the index.
90-
91-
Blob
92-
----
93-
* former 'name' member renamed to path as it suits the actual data better
118+
Remote
119+
------
120+
* Added Remote object allowing easy access to remotes
121+
* Repo.remotes lists all remotes
122+
* Repo.remote returns a remote of the specified name if it exists
94123

95124
Tree
96125
----
@@ -102,24 +131,6 @@ Tree
102131
* now mimics behaviour of a read-only list instead of a dict to maintain order.
103132
* content_from_string method is now private and not part of the public API anymore
104133

105-
Refs
106-
----
107-
* Will dynmically retrieve their object at the time of query to assure the information
108-
is actual. Recently objects would be cached, hence ref object not be safely kept
109-
persistent.
110-
111-
Remote
112-
------
113-
* Added Remote object allowing easy access to remotes
114-
* Repo.remotes lists all remotes
115-
* Repo.remote returns a remote of the specified name if it exists
116-
117-
Config
118-
------
119-
* The git configuration can now be read and manipulated directly from within python
120-
using the GitConfigParser
121-
* Repo.config_reader returns a read-only parser
122-
* Repo.config_writer returns a read-write parser
123134

124135
0.1.6
125136
=====

‎lib/git/objects/commit.py‎

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -101,16 +101,9 @@ def summary(self):
101101
"""
102102
returnself.message.split('\n',1)[0]
103103

104-
@classmethod
105-
defcount(cls,repo,rev,paths='',**kwargs):
104+
defcount(self,paths='',**kwargs):
106105
"""
107-
Count the number of commits reachable from this revision
108-
109-
``repo``
110-
is the Repo
111-
112-
``rev``
113-
revision specifier, see git-rev-parse for viable options
106+
Count the number of commits reachable from this commit
114107
115108
``paths``
116109
is an optinal path or a list of paths restricting the return value
@@ -121,7 +114,7 @@ def count(cls, repo, rev, paths='', **kwargs):
121114
Returns
122115
int
123116
"""
124-
returnlen(repo.git.rev_list(rev,'--',paths,**kwargs).strip().splitlines())
117+
returnlen(self.repo.git.rev_list(self.id,'--',paths,**kwargs).strip().splitlines())
125118

126119
@classmethod
127120
defiter_items(cls,repo,rev,paths='',**kwargs):

‎lib/git/refs.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ def commit(self):
174174
returnself.object
175175

176176

177-
classTagRef(Reference):
177+
classTagReference(Head):
178178
"""
179179
Class representing a lightweight tag reference which either points to a commit
180180
or to a tag object. In the latter case additional information, like the signature
@@ -219,9 +219,9 @@ def tag(self):
219219

220220

221221
# provide an alias
222-
Tag=TagRef
222+
Tag=TagReference
223223

224-
classRemoteRef(Head):
224+
classRemoteReference(Head):
225225
"""
226226
Represents a reference pointing to a remote head.
227227
"""

‎lib/git/remote.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"""
99

1010
fromgit.utilsimportLazyMixin,Iterable
11-
fromrefsimportRemoteRef
11+
fromrefsimportRemoteReference
1212

1313
class_SectionConstraint(object):
1414
"""
@@ -105,7 +105,7 @@ def iter_items(cls, repo):
105105
# parse them using refs, as their query can be faster as it is
106106
# purely based on the file system
107107
seen_remotes=set()
108-
forrefinRemoteRef.iter_items(repo):
108+
forrefinRemoteReference.iter_items(repo):
109109
remote_name=ref.remote_name
110110
ifremote_nameinseen_remotes:
111111
continue
@@ -121,7 +121,7 @@ def refs(self):
121121
List of RemoteRef objects
122122
"""
123123
out_refs=list()
124-
forrefinRemoteRef.list_items(self.repo):
124+
forrefinRemoteReference.list_items(self.repo):
125125
ifref.remote_name==self.name:
126126
out_refs.append(ref)
127127
# END if names match

‎lib/git/repo.py‎

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,20 @@ def heads(self):
108108
``git.Head[]``
109109
"""
110110
returnHead.list_items(self)
111+
112+
# alias heads
113+
branches=heads
114+
115+
@property
116+
defhead(self,path="HEAD"):
117+
"""
118+
Return
119+
Head Object, reference pointing to commit
120+
121+
``path``
122+
path to the head or its name, i.e. master or heads/master
123+
"""
124+
returnHead(self,path)
111125

112126
@property
113127
defremotes(self):
@@ -130,18 +144,6 @@ def remote(self, name='origin'):
130144
# END for each existing remote
131145
raiseValueError("Remote named %s does not exist"%name )
132146

133-
# alias heads
134-
branches=heads
135-
136-
@property
137-
defhead(self):
138-
"""
139-
Return
140-
Head Object, reference pointing to the current head of the repository
141-
"""
142-
returnHead(self,'HEAD')
143-
144-
145147
@property
146148
deftags(self):
147149
"""
@@ -150,7 +152,17 @@ def tags(self):
150152
Returns
151153
``git.Tag[]``
152154
"""
153-
returnTag.list_items(self)
155+
returnTagReference.list_items(self)
156+
157+
deftag(self,path):
158+
"""
159+
Return
160+
TagReference Object, reference pointing to a Commit or Tag
161+
162+
``path``
163+
path to the tag reference, i.e. 0.1.5 or tags/0.1.5
164+
"""
165+
returnTagReference(self,path)
154166

155167
def_get_config_path(self,config_level ):
156168
# we do not support an absolute path of the gitconfig on windows ,
@@ -214,6 +226,15 @@ def commit(self, rev=None):
214226
c=Object.new(self,rev)
215227
assertc.type=="commit","Revision %s did not point to a commit, but to %s"% (rev,c)
216228
returnc
229+
230+
defiter_trees(self,*args,**kwargs):
231+
"""
232+
Returns
233+
Iterator yielding Tree objects
234+
235+
Note: Takes all arguments known to iter_commits method
236+
"""
237+
return (c.treeforcinself.iter_commits(*args,**kwargs) )
217238

218239
deftree(self,ref=None):
219240
"""

‎test/git/test_commit.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def test_rev_list_bisect_all(self, git):
6666
assert_equal(sha1,commit.id)
6767

6868
deftest_count(self):
69-
assertCommit.count(self.repo,'0.1.5' )==141
69+
assertself.repo.tag('0.1.5').commit.count( )==141
7070

7171
deftest_str(self):
7272
commit=Commit(self.repo,id='abc')

‎test/git/test_repo.py‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,16 @@ def test_commits(self, git):
6767

6868
assert_true(git.called)
6969

70+
deftest_trees(self):
71+
mc=30
72+
num_trees=0
73+
fortreeinself.repo.iter_trees('0.1.5',max_count=mc):
74+
num_trees+=1
75+
assertisinstance(tree,Tree)
76+
# END for each tree
77+
assertnum_trees==mc
78+
79+
7080
@patch_object(Repo,'__init__')
7181
@patch_object(Git,'_call_process')
7282
deftest_init(self,git,repo):
@@ -170,6 +180,9 @@ def test_active_branch(self, git):
170180
deftest_head(self):
171181
assertself.repo.head.object==self.repo.active_branch.object
172182

183+
deftest_tag(self):
184+
assertself.repo.tag('0.1.5').commit
185+
173186
@patch_object(Git,'_call_process')
174187
deftest_should_display_blame_information(self,git):
175188
git.return_value=fixture('blame')

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2026 Movatter.jp