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

Commit3d0556a

Browse files
committed
Added test ofgitpython-developers#147 to verify it works.
Applied a few more fixes to commit implementation, possibly not the last
1 parent04357d0 commit3d0556a

File tree

2 files changed

+20
-16
lines changed

2 files changed

+20
-16
lines changed

‎git/objects/commit.py

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -373,40 +373,33 @@ def create_from_tree(cls, repo, tree, message, parent_commits=None, head=False,
373373

374374
def_serialize(self,stream):
375375
write=stream.write
376-
write("tree %s\n"%self.tree)
376+
write(("tree %s\n"%self.tree).encode('ascii'))
377377
forpinself.parents:
378-
write("parent %s\n"%p)
378+
write(("parent %s\n"%p).encode('ascii'))
379379

380380
a=self.author
381381
aname=a.name
382-
ifisinstance(aname,text_type):
383-
aname=aname.encode(self.encoding)
384-
# END handle unicode in name
385-
386382
c=self.committer
387383
fmt="%s %s <%s> %s %s\n"
388-
write(fmt% ("author",aname,a.email,
384+
write((fmt% ("author",aname,a.email,
389385
self.authored_date,
390-
altz_to_utctz_str(self.author_tz_offset)))
386+
altz_to_utctz_str(self.author_tz_offset))).encode(self.encoding))
391387

392388
# encode committer
393389
aname=c.name
394-
ifisinstance(aname,text_type):
395-
aname=aname.encode(self.encoding)
396-
# END handle unicode in name
397-
write(fmt% ("committer",aname,c.email,
390+
write((fmt% ("committer",aname,c.email,
398391
self.committed_date,
399-
altz_to_utctz_str(self.committer_tz_offset)))
392+
altz_to_utctz_str(self.committer_tz_offset))).encode(self.encoding))
400393

401394
ifself.encoding!=self.default_encoding:
402-
write("encoding %s\n"%self.encoding)
395+
write(("encoding %s\n"%self.encoding).encode('ascii'))
403396

404397
ifself.gpgsig:
405398
write("gpgsig")
406399
forsiglineinself.gpgsig.rstrip("\n").split("\n"):
407-
write(" "+sigline+"\n")
400+
write((" "+sigline+"\n").encode('ascii'))
408401

409-
write("\n")
402+
write(b"\n")
410403

411404
# write plain bytes, be sure its encoded according to our encoding
412405
ifisinstance(self.message,text_type):

‎git/test/test_base.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#-*-coding:utf-8-*-
12
# test_base.py
23
# Copyright (C) 2008, 2009 Michael Trier (mtrier@gmail.com) and contributors
34
#
@@ -106,3 +107,13 @@ def test_with_rw_remote_and_rw_repo(self, rw_repo, rw_remote_repo):
106107
assertnotrw_repo.config_reader("repository").getboolean("core","bare")
107108
assertrw_remote_repo.config_reader("repository").getboolean("core","bare")
108109
assertos.path.isdir(os.path.join(rw_repo.working_tree_dir,'lib'))
110+
111+
@with_rw_repo('0.1.6')
112+
deftest_add_unicode(self,rw_repo):
113+
filename=u"שלום.txt"
114+
115+
file_path=os.path.join(rw_repo.working_dir,filename)
116+
open(file_path,"wb").write('something')
117+
118+
rw_repo.git.add(rw_repo.working_dir)
119+
rw_repo.index.commit('message')

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp