diff options
author | Florian Apolloner <florian@apolloner.eu> | 2008-08-11 20:48:41 +0200 |
---|---|---|
committer | Florian Apolloner <florian@apolloner.eu> | 2008-08-11 20:48:41 +0200 |
commit | cf37099ea8d1d8c7fbf9b6d12d7ec0249d3acb8b (patch) | |
tree | 01fb5ddba393df486d850c37f40c9a87f4a28a14 | |
parent | bfdc8e26d36833b3a7106c306fdbe6d38dec817e (diff) | |
download | gitpython-cf37099ea8d1d8c7fbf9b6d12d7ec0249d3acb8b.tar.gz |
use shell=True in windows (git.exe needs to be on %PATH%)
One bug remaining: git on windows is returning status 0 for `git this-does-not-exist`, so no GitCommandError is raised.
-rw-r--r-- | lib/git/cmd.py | 11 | ||||
-rw-r--r-- | test/git/test_git.py | 7 | ||||
-rw-r--r-- | test/git/test_repo.py | 16 |
3 files changed, 24 insertions, 10 deletions
diff --git a/lib/git/cmd.py b/lib/git/cmd.py index 38cfe3bd..c7ec38f6 100644 --- a/lib/git/cmd.py +++ b/lib/git/cmd.py @@ -1,10 +1,10 @@ -# cmd.py +# cmd.py # Copyright (C) 2008 Michael Trier (mtrier@gmail.com) and contributors # # This module is part of GitPython and is released under # the BSD License: http://www.opensource.org/licenses/bsd-license.php -import os +import os, sys import subprocess import re from utils import * @@ -16,6 +16,10 @@ GIT_PYTHON_TRACE = os.environ.get("GIT_PYTHON_TRACE", False) execute_kwargs = ('istream', 'with_keep_cwd', 'with_extended_output', 'with_exceptions', 'with_raw_output') +extra = {} +if sys.platform == 'win32': + extra = {'shell': True} + class Git(object): """ The Git class manages communication with the Git binary @@ -83,7 +87,8 @@ class Git(object): cwd=cwd, stdin=istream, stderr=subprocess.PIPE, - stdout=subprocess.PIPE + stdout=subprocess.PIPE, + **extra ) # Wait for the process to return diff --git a/test/git/test_git.py b/test/git/test_git.py index d649bb1b..4618ecf2 100644 --- a/test/git/test_git.py +++ b/test/git/test_git.py @@ -4,7 +4,7 @@ # This module is part of GitPython and is released under # the BSD License: http://www.opensource.org/licenses/bsd-license.php -import os +import os, sys from test.testlib import * from git import Git, GitCommandError @@ -45,7 +45,10 @@ class TestGit(object): fh.close() def test_it_handles_large_input(self): - output = self.git.execute(["cat", "/bin/bash"]) + if sys.platform == 'win32': + output = self.git.execute(["type", "C:\WINDOWS\system32\cmd.exe"]) + else: + output = self.git.execute(["cat", "/bin/bash"]) assert_true(len(output) > 4096) # at least 4k @patch(Git, 'execute') diff --git a/test/git/test_repo.py b/test/git/test_repo.py index ea3032c1..e720856b 100644 --- a/test/git/test_repo.py +++ b/test/git/test_repo.py @@ -4,7 +4,7 @@ # This module is part of GitPython and is released under # the BSD License: http://www.opensource.org/licenses/bsd-license.php -import os +import os, sys import time from test.testlib import * from git import * @@ -15,7 +15,10 @@ class TestRepo(object): @raises(InvalidGitRepositoryError) def test_new_should_raise_on_invalid_repo_location(self): - Repo("/tmp") + if sys.platform == "win32": + Repo("C:\\WINDOWS\\Temp") + else: + Repo("/tmp") @raises(NoSuchPathError) def test_new_should_raise_on_non_existant_path(self): @@ -141,7 +144,8 @@ class TestRepo(object): self.repo.fork_bare("repos/foo/bar.git") assert_true(git.called) - assert_equal(git.call_args, (('clone', '%s/.git' % absolute_project_path(), 'repos/foo/bar.git'), {'bare': True})) + path = os.path.join(absolute_project_path(), '.git') + assert_equal(git.call_args, (('clone', path, 'repos/foo/bar.git'), {'bare': True})) assert_true(repo.called) @patch(Repo, '__init__') @@ -152,7 +156,8 @@ class TestRepo(object): self.repo.fork_bare("repos/foo/bar.git", **{'template': '/awesome'}) assert_true(git.called) - assert_equal(git.call_args, (('clone', '%s/.git' % absolute_project_path(), 'repos/foo/bar.git'), + path = os.path.join(absolute_project_path(), '.git') + assert_equal(git.call_args, (('clone', path, 'repos/foo/bar.git'), {'bare': True, 'template': '/awesome'})) assert_true(repo.called) @@ -246,7 +251,8 @@ class TestRepo(object): assert_true(os.called) def test_repr(self): - assert_equal('<GitPython.Repo "%s/.git">' % os.path.abspath(GIT_REPO), repr(self.repo)) + path = os.path.join(os.path.abspath(GIT_REPO), '.git') + assert_equal('<GitPython.Repo "%s">' % path, repr(self.repo)) @patch(Git, '_call_process') def test_log(self, git): |