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

Commit7379091

Browse files
committed
Merge branch 'commit_by_actor' ofhttps://github.com/firm1/GitPython into firm1-commit_by_actor
2 parents45eb728 +b6ed8d4 commit7379091

File tree

4 files changed

+29
-6
lines changed

4 files changed

+29
-6
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: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,20 @@
3232
classRefLogEntry(tuple):
3333

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

3938
def__repr__(self):
4039
"""Representation of ourselves in git reflog format"""
4140
act=self.actor
4241
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)
42+
returnu"{0} {1} {2} <{3}> {4!s} {5}\t{6}\n".format(self.oldhexsha,
43+
self.newhexsha,
44+
act.name,
45+
act.email,
46+
time[0],
47+
altz_to_utctz_str(time[1]),
48+
self.message).encode("utf-8")
4549

4650
@property
4751
defoldhexsha(self):
@@ -267,7 +271,6 @@ def append_entry(cls, config_reader, filepath, oldbinsha, newbinsha, message):
267271

268272
lf=LockFile(filepath)
269273
lf._obtain_lock_or_raise()
270-
271274
fd=open(filepath,'ab')
272275
try:
273276
fd.write(repr(entry).encode(defenc))

‎git/test/test_index.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
fixture,
1111
with_rw_repo
1212
)
13+
fromgit.utilimportActor
1314
fromgitimport (
1415
IndexFile,
1516
BlobFilter,
@@ -445,6 +446,22 @@ def mixed_iterator():
445446
assertlen(new_commit.parents)==1
446447
assertcur_head.commit==cur_commit
447448

449+
# commit with other actor
450+
cur_commit=cur_head.commit
451+
452+
my_author=Actor("An author","author@example.com")
453+
my_committer=Actor("An committer","committer@example.com")
454+
commit_actor=index.commit(commit_message,author=my_author,committer=my_committer)
455+
assertcur_commit!=commit_actor
456+
assertcommit_actor.author.name=="An author"
457+
assertcommit_actor.author.email=="author@example.com"
458+
assertcommit_actor.committer.name=="An committer"
459+
assertcommit_actor.committer.email=="committer@example.com"
460+
assertcommit_actor.message==commit_message
461+
assertcommit_actor.parents[0]==cur_commit
462+
assertlen(new_commit.parents)==1
463+
assertcur_head.commit==cur_commit
464+
448465
# same index, no parents
449466
commit_message="index without parents"
450467
commit_no_parents=index.commit(commit_message,parent_commits=list(),head=True)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp