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

Commit6404168

Browse files
committed
Merge pull requestgitpython-developers#200 from dbaxa/0.3-with-unicode-fixes
0.3 with unicode fixes
2 parents27c577d +c390e22 commit6404168

File tree

4 files changed

+27
-14
lines changed

4 files changed

+27
-14
lines changed

‎.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[submodule "gitdb"]
22
path=git/ext/gitdb
3-
url=http://github.com/gitpython-developers/gitdb.git
3+
url=https://github.com/gitpython-developers/gitdb.git

‎git/cmd.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,12 +410,16 @@ def transform_kwargs(self, split_single_char_options=False, **kwargs):
410410
@classmethod
411411
def__unpack_args(cls,arg_list):
412412
ifnotisinstance(arg_list, (list,tuple)):
413+
ifisinstance(arg_list,unicode):
414+
return [arg_list.encode('utf-8')]
413415
return [str(arg_list) ]
414416

415417
outlist=list()
416418
forarginarg_list:
417419
ifisinstance(arg_list, (list,tuple)):
418420
outlist.extend(cls.__unpack_args(arg ))
421+
elifisinstance(arg_list,unicode):
422+
outlist.append(arg_list.encode('utf-8'))
419423
# END recursion
420424
else:
421425
outlist.append(str(arg))

‎git/repo/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ def commit(self, rev=None):
376376
ifrevisNone:
377377
returnself.head.commit
378378
else:
379-
returnself.rev_parse(str(rev)+"^0")
379+
returnself.rev_parse(unicode(rev)+"^0")
380380

381381
defiter_trees(self,*args,**kwargs):
382382
""":return: Iterator yielding Tree objects
@@ -399,7 +399,7 @@ def tree(self, rev=None):
399399
ifrevisNone:
400400
returnself.head.commit.tree
401401
else:
402-
returnself.rev_parse(str(rev)+"^{tree}")
402+
returnself.rev_parse(unicode(rev)+"^{tree}")
403403

404404
defiter_commits(self,rev=None,paths='',**kwargs):
405405
"""A list of Commit objects representing the history of a given ref/commit

‎git/test/test_git.py

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
66

77
importos,sys
8-
fromgit.test.libimport (TestBase,
9-
patch,
8+
fromgit.test.libimport (
9+
TestBase,
10+
patch,
1011
raises,
1112
assert_equal,
1213
assert_true,
@@ -16,7 +17,7 @@
1617
GitCommandError )
1718

1819
classTestGit(TestBase):
19-
20+
2021
@classmethod
2122
defsetUp(cls):
2223
super(TestGit,cls).setUp()
@@ -29,6 +30,14 @@ def test_call_process_calls_execute(self, git):
2930
assert_true(git.called)
3031
assert_equal(git.call_args, ((['git','version'],), {}))
3132

33+
deftest_call_unpack_args_unicode(self):
34+
args=Git._Git__unpack_args(u'Unicode'+unichr(40960))
35+
assert_equal(args, ['Unicode\xea\x80\x80'])
36+
37+
deftest_call_unpack_args(self):
38+
args=Git._Git__unpack_args(['git','log','--',u'Unicode'+unichr(40960)])
39+
assert_equal(args, ['git','log','--','Unicode\xea\x80\x80'])
40+
3241
@raises(GitCommandError)
3342
deftest_it_raises_errors(self):
3443
self.git.this_does_not_exist()
@@ -58,7 +67,7 @@ def test_it_ignores_false_kwargs(self, git):
5867
# this_should_not_be_ignored=False implies it *should* be ignored
5968
output=self.git.version(pass_this_kwarg=False)
6069
assert_true("pass_this_kwarg"notingit.call_args[1])
61-
70+
6271
deftest_persistent_cat_file_command(self):
6372
# read header only
6473
importsubprocessassp
@@ -67,37 +76,37 @@ def test_persistent_cat_file_command(self):
6776
g.stdin.write("b2339455342180c7cc1e9bba3e9f181f7baa5167\n")
6877
g.stdin.flush()
6978
obj_info=g.stdout.readline()
70-
79+
7180
# read header + data
7281
g=self.git.cat_file(batch=True,istream=sp.PIPE,as_process=True)
7382
g.stdin.write("b2339455342180c7cc1e9bba3e9f181f7baa5167\n")
7483
g.stdin.flush()
7584
obj_info_two=g.stdout.readline()
7685
assertobj_info==obj_info_two
77-
86+
7887
# read data - have to read it in one large chunk
7988
size=int(obj_info.split()[2])
8089
data=g.stdout.read(size)
8190
terminating_newline=g.stdout.read(1)
82-
91+
8392
# now we should be able to read a new object
8493
g.stdin.write("b2339455342180c7cc1e9bba3e9f181f7baa5167\n")
8594
g.stdin.flush()
8695
assertg.stdout.readline()==obj_info
87-
88-
96+
97+
8998
# same can be achived using the respective command functions
9099
hexsha,typename,size=self.git.get_object_header(hexsha)
91100
hexsha,typename_two,size_two,data=self.git.get_object_data(hexsha)
92101
asserttypename==typename_twoandsize==size_two
93-
102+
94103
deftest_version(self):
95104
v=self.git.version_info
96105
assertisinstance(v,tuple)
97106
forninv:
98107
assertisinstance(n,int)
99108
#END verify number types
100-
109+
101110
deftest_cmd_override(self):
102111
prev_cmd=self.git.GIT_PYTHON_GIT_EXECUTABLE
103112
try:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp