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

Commitc6ee00d

Browse files
committed
Made sure commits accept unicode or unicode characters
1 parent7379091 commitc6ee00d

File tree

3 files changed

+23
-10
lines changed

3 files changed

+23
-10
lines changed

‎git/refs/log.py

Lines changed: 14 additions & 3 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
@@ -37,6 +38,16 @@ class RefLogEntry(tuple):
3738

3839
def__repr__(self):
3940
"""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"""
4051
act=self.actor
4152
time=self.time
4253
returnu"{0} {1} {2} <{3}> {4!s} {5}\t{6}\n".format(self.oldhexsha,
@@ -45,7 +56,7 @@ def __repr__(self):
4556
act.email,
4657
time[0],
4758
altz_to_utctz_str(time[1]),
48-
self.message).encode("utf-8")
59+
self.message)
4960

5061
@property
5162
defoldhexsha(self):
@@ -273,7 +284,7 @@ def append_entry(cls, config_reader, filepath, oldbinsha, newbinsha, message):
273284
lf._obtain_lock_or_raise()
274285
fd=open(filepath,'ab')
275286
try:
276-
fd.write(repr(entry).encode(defenc))
287+
fd.write(entry.format().encode(defenc))
277288
finally:
278289
fd.close()
279290
lf._release_lock()
@@ -298,7 +309,7 @@ def _serialize(self, stream):
298309

299310
# write all entries
300311
foreinself:
301-
write(repr(e).encode(defenc))
312+
write(e.format().encode(defenc))
302313
# END for each entry
303314

304315
def_deserialize(self,stream):

‎git/test/test_index.py

Lines changed: 8 additions & 6 deletions
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
#
@@ -433,7 +434,7 @@ def mixed_iterator():
433434
# TEST COMMITTING
434435
# commit changed index
435436
cur_commit=cur_head.commit
436-
commit_message="commit default head"
437+
commit_message=u"commit default head by Frèderic Çaufl€"
437438

438439
new_commit=index.commit(commit_message,head=False)
439440
assertcur_commit!=new_commit
@@ -449,18 +450,19 @@ def mixed_iterator():
449450
# commit with other actor
450451
cur_commit=cur_head.commit
451452

452-
my_author=Actor("An author","author@example.com")
453-
my_committer=Actor("An committer","committer@example.com")
453+
my_author=Actor(u"Frèderic Çaufl€","author@example.com")
454+
my_committer=Actor(u"Committing Frèderic Çaufl€","committer@example.com")
454455
commit_actor=index.commit(commit_message,author=my_author,committer=my_committer)
455456
assertcur_commit!=commit_actor
456-
assertcommit_actor.author.name=="An author"
457+
assertcommit_actor.author.name==u"Frèderic Çaufl€"
457458
assertcommit_actor.author.email=="author@example.com"
458-
assertcommit_actor.committer.name=="An committer"
459+
assertcommit_actor.committer.name==u"Committing Frèderic Çaufl€"
459460
assertcommit_actor.committer.email=="committer@example.com"
460461
assertcommit_actor.message==commit_message
461462
assertcommit_actor.parents[0]==cur_commit
462463
assertlen(new_commit.parents)==1
463-
assertcur_head.commit==cur_commit
464+
assertcur_head.commit==commit_actor
465+
assertcur_head.log()[-1].actor==my_committer
464466

465467
# same index, no parents
466468
commit_message="index without parents"

‎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