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

Commitc9dbf20

Browse files
committed
Moved small types that had their own module into the utils module
1 parent38b3cfb commitc9dbf20

File tree

8 files changed

+482
-488
lines changed

8 files changed

+482
-488
lines changed

‎lib/git/__init__.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,17 @@ def _init_externals():
2727
fromgit.configimportGitConfigParser
2828
fromgit.objectsimport*
2929
fromgit.refsimport*
30-
fromgit.actorimportActor
3130
fromgit.diffimport*
3231
fromgit.errorsimportInvalidGitRepositoryError,NoSuchPathError,GitCommandError
3332
fromgit.cmdimportGit
3433
fromgit.repoimportRepo
35-
fromgit.statsimportStats
3634
fromgit.remoteimport*
3735
fromgit.indeximport*
38-
fromgit.utilsimportLockFile,BlockingLockFile
36+
fromgit.utilsimport (
37+
LockFile,
38+
BlockingLockFile,
39+
Stats
40+
)
3941

4042
#} END imports
4143

‎lib/git/actor.py

Lines changed: 0 additions & 62 deletions
This file was deleted.

‎lib/git/objects/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
fromtreeimport*
99
fromcommitimport*
1010
fromsubmoduleimport*
11+
fromutilsimportActor
1112

1213
__all__= [nameforname,objinlocals().items()
1314
ifnot (name.startswith('_')orinspect.ismodule(obj)) ]

‎lib/git/objects/commit.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
# This module is part of GitPython and is released under
55
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
66

7-
fromgit.utilsimportIterable
7+
fromgit.utilsimport (
8+
Iterable,
9+
Stats,
10+
)
11+
812
importgit.diffasdiff
9-
importgit.statsasstats
10-
fromgit.actorimportActor
1113
fromtreeimportTree
1214
fromgitdbimportIStream
1315
fromcStringIOimportStringIO
@@ -223,7 +225,7 @@ def stats(self):
223225
text=text2
224226
else:
225227
text=self.repo.git.diff(self.parents[0].sha,self.sha,'--',numstat=True)
226-
returnstats.Stats._list_from_string(self.repo,text)
228+
returnStats._list_from_string(self.repo,text)
227229

228230
@classmethod
229231
def_iter_from_process_or_stream(cls,repo,proc_or_stream):
@@ -332,8 +334,8 @@ def create_from_tree(cls, repo, tree, message, parent_commits=None, head=False):
332334
enc_section,enc_option=cls.conf_encoding.split('.')
333335
conf_encoding=cr.get_value(enc_section,enc_option,cls.default_encoding)
334336

335-
author=Actor(author_name,author_email)
336-
committer=Actor(committer_name,committer_email)
337+
author=utils.Actor(author_name,author_email)
338+
committer=utils.Actor(committer_name,committer_email)
337339

338340

339341
# CREATE NEW COMMIT

‎lib/git/objects/utils.py

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
"""
99
importre
1010
fromcollectionsimportdequeasDeque
11-
fromgit.actorimportActor
1211
importplatform
1312

1413
fromstringimportdigits
@@ -19,6 +18,8 @@
1918
'ProcessStreamAdapter','Traversable','altz_to_utctz_str','utctz_to_altz',
2019
'verify_utctz')
2120

21+
#{ Functions
22+
2223
defget_object_type_by_name(object_type_name):
2324
"""
2425
Returns
@@ -180,6 +181,60 @@ def parse_actor_and_date(line):
180181
actor,epoch,offset=m.groups()
181182
return (Actor._from_string(actor),int(epoch),utctz_to_altz(offset))
182183

184+
185+
#} END functions
186+
187+
188+
#{ Classes
189+
190+
classActor(object):
191+
"""Actors hold information about a person acting on the repository. They
192+
can be committers and authors or anything with a name and an email as
193+
mentioned in the git log entries."""
194+
# precompiled regex
195+
name_only_regex=re.compile(r'<(.+)>' )
196+
name_email_regex=re.compile(r'(.*) <(.+?)>' )
197+
198+
def__init__(self,name,email):
199+
self.name=name
200+
self.email=email
201+
202+
def__eq__(self,other):
203+
returnself.name==other.nameandself.email==other.email
204+
205+
def__ne__(self,other):
206+
returnnot (self==other)
207+
208+
def__hash__(self):
209+
returnhash((self.name,self.email))
210+
211+
def__str__(self):
212+
returnself.name
213+
214+
def__repr__(self):
215+
return'<git.Actor "%s <%s>">'% (self.name,self.email)
216+
217+
@classmethod
218+
def_from_string(cls,string):
219+
"""Create an Actor from a string.
220+
:param string: is the string, which is expected to be in regular git format
221+
222+
John Doe <jdoe@example.com>
223+
224+
:return: Actor """
225+
m=cls.name_email_regex.search(string)
226+
ifm:
227+
name,email=m.groups()
228+
returnActor(name,email)
229+
else:
230+
m=cls.name_only_regex.search(string)
231+
ifm:
232+
returnActor(m.group(1),None)
233+
else:
234+
# assume best and use the whole string as name
235+
returnActor(string,None)
236+
# END special case name
237+
# END handle name/email matching
183238

184239

185240
classProcessStreamAdapter(object):

‎lib/git/repo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
fromerrorsimportInvalidGitRepositoryError,NoSuchPathError
88
fromcmdimportGit
9-
fromactorimportActor
9+
fromobjectsimportActor
1010
fromrefsimport*
1111
fromindeximportIndexFile
1212
fromobjectsimport*

‎lib/git/stats.py

Lines changed: 0 additions & 60 deletions
This file was deleted.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp