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

Commitf4a49ff

Browse files
committed
Merge branch 'firm1-commit_by_actor'
2 parents45eb728 +c6ee00d commitf4a49ff

File tree

5 files changed

+46
-10
lines changed

5 files changed

+46
-10
lines changed

‎doc/source/tutorial.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,10 @@ Access objects and add/remove entries. Commit the changes::
297297
# Access the entries directly
298298
index.add(['my_new_file']) # add a new file to the index
299299
index.remove(['dir/existing_file'])
300-
new_commit = index.commit("my commit message")
300+
new_commit = index.commit("my commit message") # commit by commit message first
301+
my_author = Actor("An author", "author@example.com")
302+
my_committer = Actor("A committer", "committer@example.com")
303+
next_commit = index.commit("my commit message", author=my_author, commiter=my_committer) # commit by commit message and author and committer
301304
302305
Create new indices from other trees or as result of a merge. Write that result to a new index file::
303306

‎git/objects/commit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ def create_from_tree(cls, repo, tree, message, parent_commits=None, head=False,
358358
# as well ...
359359
importgit.refs
360360
try:
361-
repo.head.set_commit(new_commit,logmsg="commit: %s"%message)
361+
repo.head.set_commit(new_commit,logmsg=message)
362362
exceptValueError:
363363
# head is not yet set to the ref our HEAD points to
364364
# Happens on first commit

‎git/refs/log.py

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
altz_to_utctz_str,
1919
)
2020
fromgit.compatimport (
21+
PY3,
2122
xrange,
2223
string_types,
2324
defenc
@@ -32,16 +33,30 @@
3233
classRefLogEntry(tuple):
3334

3435
"""Named tuple allowing easy access to the revlog data fields"""
35-
_fmt="%s %s %s <%s> %i %s\t%s\n"
3636
_re_hexsha_only=re.compile('^[0-9A-Fa-f]{40}$')
3737
__slots__=tuple()
3838

3939
def__repr__(self):
4040
"""Representation of ourselves in git reflog format"""
41+
res=self.format()
42+
ifPY3:
43+
returnres
44+
else:
45+
# repr must return a string, which it will auto-encode from unicode using the default encoding.
46+
# This usually fails, so we encode ourselves
47+
returnres.encode(defenc)
48+
49+
defformat(self):
50+
""":return: a string suitable to be placed in a reflog file"""
4151
act=self.actor
4252
time=self.time
43-
returnself._fmt% (self.oldhexsha,self.newhexsha,act.name,act.email,
44-
time[0],altz_to_utctz_str(time[1]),self.message)
53+
returnu"{0} {1} {2} <{3}> {4!s} {5}\t{6}\n".format(self.oldhexsha,
54+
self.newhexsha,
55+
act.name,
56+
act.email,
57+
time[0],
58+
altz_to_utctz_str(time[1]),
59+
self.message)
4560

4661
@property
4762
defoldhexsha(self):
@@ -267,10 +282,9 @@ def append_entry(cls, config_reader, filepath, oldbinsha, newbinsha, message):
267282

268283
lf=LockFile(filepath)
269284
lf._obtain_lock_or_raise()
270-
271285
fd=open(filepath,'ab')
272286
try:
273-
fd.write(repr(entry).encode(defenc))
287+
fd.write(entry.format().encode(defenc))
274288
finally:
275289
fd.close()
276290
lf._release_lock()
@@ -295,7 +309,7 @@ def _serialize(self, stream):
295309

296310
# write all entries
297311
foreinself:
298-
write(repr(e).encode(defenc))
312+
write(e.format().encode(defenc))
299313
# END for each entry
300314

301315
def_deserialize(self,stream):

‎git/test/test_index.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#-*-coding:utf-8-*-
12
# test_index.py
23
# Copyright (C) 2008, 2009 Michael Trier (mtrier@gmail.com) and contributors
34
#
@@ -10,6 +11,7 @@
1011
fixture,
1112
with_rw_repo
1213
)
14+
fromgit.utilimportActor
1315
fromgitimport (
1416
IndexFile,
1517
BlobFilter,
@@ -432,7 +434,7 @@ def mixed_iterator():
432434
# TEST COMMITTING
433435
# commit changed index
434436
cur_commit=cur_head.commit
435-
commit_message="commit default head"
437+
commit_message=u"commit default head by Frèderic Çaufl€"
436438

437439
new_commit=index.commit(commit_message,head=False)
438440
assertcur_commit!=new_commit
@@ -445,6 +447,23 @@ def mixed_iterator():
445447
assertlen(new_commit.parents)==1
446448
assertcur_head.commit==cur_commit
447449

450+
# commit with other actor
451+
cur_commit=cur_head.commit
452+
453+
my_author=Actor(u"Frèderic Çaufl€","author@example.com")
454+
my_committer=Actor(u"Committing Frèderic Çaufl€","committer@example.com")
455+
commit_actor=index.commit(commit_message,author=my_author,committer=my_committer)
456+
assertcur_commit!=commit_actor
457+
assertcommit_actor.author.name==u"Frèderic Çaufl€"
458+
assertcommit_actor.author.email=="author@example.com"
459+
assertcommit_actor.committer.name==u"Committing Frèderic Çaufl€"
460+
assertcommit_actor.committer.email=="committer@example.com"
461+
assertcommit_actor.message==commit_message
462+
assertcommit_actor.parents[0]==cur_commit
463+
assertlen(new_commit.parents)==1
464+
assertcur_head.commit==commit_actor
465+
assertcur_head.log()[-1].actor==my_committer
466+
448467
# same index, no parents
449468
commit_message="index without parents"
450469
commit_no_parents=index.commit(commit_message,parent_commits=list(),head=True)

‎git/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ def __str__(self):
328328
returnself.name
329329

330330
def__repr__(self):
331-
return'<git.Actor "%s <%s>">'% (self.name,self.email)
331+
returnu'<git.Actor "%s <%s>">'% (self.name,self.email)
332332

333333
@classmethod
334334
def_from_string(cls,string):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp