Skip to content

Commit 3d0556a

Browse files
committed
Added test of gitpython-developers#147 to verify it works.
Applied a few more fixes to commit implementation, possibly not the last
1 parent 04357d0 commit 3d0556a

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
for p in self.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-
if isinstance(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-
if isinstance(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
if self.encoding != self.default_encoding:
402-
write("encoding %s\n" % self.encoding)
395+
write(("encoding %s\n" % self.encoding).encode('ascii'))
403396

404397
if self.gpgsig:
405398
write("gpgsig")
406399
for sigline in self.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
if isinstance(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
assert not rw_repo.config_reader("repository").getboolean("core", "bare")
107108
assert rw_remote_repo.config_reader("repository").getboolean("core", "bare")
108109
assert os.path.isdir(os.path.join(rw_repo.working_tree_dir, 'lib'))
110+
111+
@with_rw_repo('0.1.6')
112+
def test_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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy