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

Commit27ceafb

Browse files
committed
Merge git://gitorious.org/git-python/apollo13
2 parents7c60b88 +7009473 commit27ceafb

File tree

6 files changed

+39
-59
lines changed

6 files changed

+39
-59
lines changed

‎lib/git_python/__init__.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
fromgit_python.statsimportStats
1212
fromgit_python.tagimportTag
1313
fromgit_python.treeimportTree
14-
fromgit_python.utilsimportshell_escape,dashify,touch
14+
fromgit_python.utilsimportdashify,touch
1515

1616
__all__= [nameforname,objinlocals().items()
1717
ifnot (name.startswith('_')orinspect.ismodule(obj)) ]

‎lib/git_python/git.py‎

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,27 @@ class Git(MethodMissingMixin):
1111
def__init__(self,git_dir):
1212
super(Git,self).__init__()
1313
self.git_dir=git_dir
14-
15-
git_binary="/usr/bin/env git"
16-
14+
1715
@property
1816
defget_dir(self):
1917
returnself.git_dir
20-
18+
2119
defexecute(self,command):
2220
"""
2321
Handles executing the command on the shell and consumes and returns
2422
the returned information (stdout)
25-
23+
2624
``command``
2725
The command to execute
2826
"""
29-
printcommand
30-
proc=subprocess.Popen(command,
31-
shell=True,
32-
stdout=subprocess.PIPE
27+
print' '.join(command)
28+
proc=subprocess.Popen(command,
29+
cwd=self.git_dir,
30+
stdout=subprocess.PIPE
3331
)
34-
stdout_value=proc.communicate()[0]
32+
proc.wait()
33+
stdout_value=proc.stdout.read()
34+
proc.stdout.close()
3535
returnstdout_value
3636

3737
deftransform_kwargs(self,**kwargs):
@@ -44,38 +44,41 @@ def transform_kwargs(self, **kwargs):
4444
ifvisTrue:
4545
args.append("-%s"%k)
4646
else:
47-
args.append("-%s %r"% (k,v))
47+
args.append("-%s"%k)
48+
args.append(v)
4849
else:
4950
ifvisTrue:
5051
args.append("--%s"%dashify(k))
5152
else:
52-
args.append("--%s=%r"% (dashify(k),v))
53+
args.append("--%s=%s"% (dashify(k),v))
5354
returnargs
54-
55+
5556
defmethod_missing(self,method,*args,**kwargs):
5657
"""
5758
Run the given git command with the specified arguments and return
5859
the result as a String
59-
60+
6061
``method``
6162
is the command
62-
63+
6364
``args``
6465
is the list of arguments
65-
66+
6667
``kwargs``
6768
is a dict of keyword arguments
6869
6970
Examples
7071
git.rev_list('master', max_count=10, header=True)
71-
72+
7273
Returns
7374
str
7475
"""
7576
opt_args=self.transform_kwargs(**kwargs)
76-
ext_args=map(lambdaa: (a=='--')andaor"%s"%shell_escape(a),args)
77+
ext_args=map(lambdaa: (a=='--')andaor"%s"%a,args)
7778
args=opt_args+ext_args
78-
79-
call="%s --git-dir=%s %s %s"% (self.git_binary,self.git_dir,dashify(method),' '.join(args))
79+
80+
call= ['git-'+dashify(method)]
81+
call.extend(args)
82+
8083
stdout_value=self.execute(call)
8184
returnstdout_value

‎lib/git_python/utils.py‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
defshell_escape(string):
2-
returnstr(string).replace("'","\\\\'")
3-
41
defdashify(string):
52
returnstring.replace('_','-')
63

‎test/git/test_git.py‎

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44

55
classTestGit(object):
66
defsetup(self):
7-
base=os.path.join(os.path.dirname(__file__),"../.."),
7+
base=os.path.join(os.path.dirname(__file__),"../..")
88
self.git=Git(base)
9-
self.git_bin_base="%s --git-dir=%s"% (Git.git_binary,base)
109

1110
@patch(Git,'execute')
1211
deftest_method_missing_calls_execute(self,git):
@@ -17,31 +16,12 @@ def test_method_missing_calls_execute(self, git):
1716

1817
deftest_it_transforms_kwargs_into_git_command_arguments(self):
1918
assert_equal(["-s"],self.git.transform_kwargs(**{'s':True}))
20-
assert_equal(["-s 5"],self.git.transform_kwargs(**{'s':5}))
19+
assert_equal(["-s",5],self.git.transform_kwargs(**{'s':5}))
2120

2221
assert_equal(["--max-count"],self.git.transform_kwargs(**{'max_count':True}))
2322
assert_equal(["--max-count=5"],self.git.transform_kwargs(**{'max_count':5}))
2423

2524
assert_equal(["-s","-t"],self.git.transform_kwargs(**{'s':True,'t':True}))
2625

2726
deftest_it_executes_git_to_shell_and_returns_result(self):
28-
assert_match('^git version [\d\.]*$',self.git.execute("%s version"%Git.git_binary))
29-
30-
deftest_it_transforms_kwargs_shell_escapes_arguments(self):
31-
assert_equal(["--foo=\"bazz'er\""],self.git.transform_kwargs(**{'foo':"bazz'er"}))
32-
assert_equal(["-x\"bazz'er\""],self.git.transform_kwargs(**{'x':"bazz'er"}))
33-
34-
@patch(Git,'execute')
35-
deftest_it_really_shell_escapes_arguments_to_the_git_shell_1(self,git):
36-
self.git.foo(**{'bar':"bazz'er"})
37-
assert_true(git.called)
38-
assert_equal(git.call_args, ((("%s foo --bar=\"bazz'er\""%self.git_bin_base),), {}))
39-
40-
@patch(Git,'execute')
41-
deftest_it_really_shell_escapes_arguments_to_the_git_shell_2(self,git):
42-
self.git.bar(**{'x':"quu'x"})
43-
assert_true(git.called)
44-
assert_equal(git.call_args, ((("%s bar -x\"quu'x\""%self.git_bin_base),), {}))
45-
46-
deftest_it_shell_escapes_the_standalone_argument(self):
47-
self.git.foo("bar's", {})
27+
assert_match('^git version [\d\.]*$',self.git.execute(["git","version"]))

‎test/git/test_repo.py‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def test_new_should_raise_on_invalid_repo_location(self):
1313

1414
@raises(NoSuchPathError)
1515
deftest_new_should_raise_on_non_existant_path(self):
16-
Repo("/foobar")
16+
Repo("~/foobar")
1717

1818
deftest_description(self):
1919
assert_equal("Unnamed repository; edit this file to name it for gitweb.",self.repo.description)
@@ -108,45 +108,45 @@ def test_blob(self, git):
108108
deftest_init_bare(self,repo,git):
109109
git.return_value=True
110110

111-
Repo.init_bare("/foo/bar.git")
111+
Repo.init_bare("~/foo/bar.git")
112112

113113
assert_true(git.called)
114114
assert_equal(git.call_args, (('init',), {}))
115115
assert_true(repo.called)
116-
assert_equal(repo.call_args, (('/foo/bar.git',), {}))
116+
assert_equal(repo.call_args, (('~/foo/bar.git',), {}))
117117

118118
@patch(Repo,'__init__')
119119
@patch(Git,'method_missing')
120120
deftest_init_bare_with_options(self,repo,git):
121121
git.return_value=True
122122

123-
Repo.init_bare("/foo/bar.git",**{'template':"/baz/sweet"})
123+
Repo.init_bare("~/foo/bar.git",**{'template':"/baz/sweet"})
124124

125125
assert_true(git.called)
126126
assert_equal(git.call_args, (('init',), {'template':'/baz/sweet'}))
127127
assert_true(repo.called)
128-
assert_equal(repo.call_args, (('/foo/bar.git',), {}))
128+
assert_equal(repo.call_args, (('~/foo/bar.git',), {}))
129129

130130
@patch(Repo,'__init__')
131131
@patch(Git,'method_missing')
132132
deftest_fork_bare(self,repo,git):
133133
git.return_value=None
134134

135-
self.repo.fork_bare("/foo/bar.git")
135+
self.repo.fork_bare("~/foo/bar.git")
136136

137137
assert_true(git.called)
138-
assert_equal(git.call_args, (('clone','%s/.git'%absolute_project_path(),'/foo/bar.git'), {'bare':True}))
138+
assert_equal(git.call_args, (('clone','%s/.git'%absolute_project_path(),'~/foo/bar.git'), {'bare':True}))
139139
assert_true(repo.called)
140140

141141
@patch(Repo,'__init__')
142142
@patch(Git,'method_missing')
143143
deftest_fork_bare_with_options(self,repo,git):
144144
git.return_value=None
145145

146-
self.repo.fork_bare("/foo/bar.git",**{'template':'/awesome'})
146+
self.repo.fork_bare("~/foo/bar.git",**{'template':'/awesome'})
147147

148148
assert_true(git.called)
149-
assert_equal(git.call_args, (('clone','%s/.git'%absolute_project_path(),'/foo/bar.git'),
149+
assert_equal(git.call_args, (('clone','%s/.git'%absolute_project_path(),'~/foo/bar.git'),
150150
{'bare':True,'template':'/awesome'}))
151151
assert_true(repo.called)
152152

‎test/git/test_utils.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ class TestUtils(object):
66
defsetup(self):
77
base=os.path.join(os.path.dirname(__file__),"../.."),
88
self.git=Git(base)
9-
self.git_bin_base="%s --git-dir='%s'"% (Git.git_binary,base)
9+
# self.git_bin_base = "%s --git-dir='%s'" % (Git.git_binary, base)
1010

11-
deftest_it_escapes_single_quotes_with_shell_escape(self):
12-
assert_equal("\\\\'foo",shell_escape("'foo"))
11+
# def test_it_escapes_single_quotes_with_shell_escape(self):
12+
# assert_equal("\\\\'foo", shell_escape("'foo"))
1313

1414
deftest_it_should_dashify(self):
1515
assert_equal('this-is-my-argument',dashify('this_is_my_argument'))

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2026 Movatter.jp