diff options
-rw-r--r-- | lib/git_python/git.py | 4 | ||||
-rw-r--r-- | test/git/test_git.py | 26 | ||||
-rw-r--r-- | test/git/test_utils.py | 6 |
3 files changed, 9 insertions, 27 deletions
diff --git a/lib/git_python/git.py b/lib/git_python/git.py index 8711c1fb..2cec4954 100644 --- a/lib/git_python/git.py +++ b/lib/git_python/git.py @@ -25,6 +25,7 @@ class Git(MethodMissingMixin): The command to execute """ print ' '.join(command) + print self.git_dir proc = subprocess.Popen(command, cwd = self.git_dir, stdout=subprocess.PIPE @@ -74,7 +75,8 @@ class Git(MethodMissingMixin): str """ opt_args = self.transform_kwargs(**kwargs) - args = opt_args + list(args) + ext_args = map(lambda a: (a == '--') and a or "%s" % a, args) + args = opt_args + ext_args call = ['git-'+dashify(method)] call.extend(args) diff --git a/test/git/test_git.py b/test/git/test_git.py index 0634a5dd..43fd231c 100644 --- a/test/git/test_git.py +++ b/test/git/test_git.py @@ -4,9 +4,8 @@ from git_python import * class TestGit(object): def setup(self): - base = os.path.join(os.path.dirname(__file__), "../.."), + base = os.path.join(os.path.dirname(__file__), "../..") self.git = Git(base) - self.git_bin_base = "%s --git-dir=%s" % (Git.git_binary, base) @patch(Git, 'execute') def test_method_missing_calls_execute(self, git): @@ -17,7 +16,7 @@ class TestGit(object): def test_it_transforms_kwargs_into_git_command_arguments(self): assert_equal(["-s"], self.git.transform_kwargs(**{'s': True})) - assert_equal(["-s 5"], self.git.transform_kwargs(**{'s': 5})) + assert_equal(["-s", 5], self.git.transform_kwargs(**{'s': 5})) assert_equal(["--max-count"], self.git.transform_kwargs(**{'max_count': True})) assert_equal(["--max-count=5"], self.git.transform_kwargs(**{'max_count': 5})) @@ -25,23 +24,4 @@ class TestGit(object): assert_equal(["-s", "-t"], self.git.transform_kwargs(**{'s': True, 't': True})) def test_it_executes_git_to_shell_and_returns_result(self): - assert_match('^git version [\d\.]*$', self.git.execute("%s version" % Git.git_binary)) - - def test_it_transforms_kwargs_shell_escapes_arguments(self): - assert_equal(["--foo=\"bazz'er\""], self.git.transform_kwargs(**{'foo': "bazz'er"})) - assert_equal(["-x \"bazz'er\""], self.git.transform_kwargs(**{'x': "bazz'er"})) - - @patch(Git, 'execute') - def test_it_really_shell_escapes_arguments_to_the_git_shell_1(self, git): - self.git.foo(**{'bar': "bazz'er"}) - assert_true(git.called) - assert_equal(git.call_args, ((("%s foo --bar=\"bazz'er\"" % self.git_bin_base),), {})) - - @patch(Git, 'execute') - def test_it_really_shell_escapes_arguments_to_the_git_shell_2(self, git): - self.git.bar(**{'x': "quu'x"}) - assert_true(git.called) - assert_equal(git.call_args, ((("%s bar -x \"quu'x\"" % self.git_bin_base),), {})) - - def test_it_shell_escapes_the_standalone_argument(self): - self.git.foo("bar's", {}) + assert_match('^git version [\d\.]*$', self.git.execute(["git","version"])) diff --git a/test/git/test_utils.py b/test/git/test_utils.py index a9af2040..b2b42a1c 100644 --- a/test/git/test_utils.py +++ b/test/git/test_utils.py @@ -6,10 +6,10 @@ class TestUtils(object): def setup(self): base = os.path.join(os.path.dirname(__file__), "../.."), self.git = Git(base) - self.git_bin_base = "%s --git-dir='%s'" % (Git.git_binary, base) +# self.git_bin_base = "%s --git-dir='%s'" % (Git.git_binary, base) - def test_it_escapes_single_quotes_with_shell_escape(self): - assert_equal("\\\\'foo", shell_escape("'foo")) +# def test_it_escapes_single_quotes_with_shell_escape(self): +# assert_equal("\\\\'foo", shell_escape("'foo")) def test_it_should_dashify(self): assert_equal('this-is-my-argument', dashify('this_is_my_argument')) |