Skip to content

Commit

Permalink
Attempt to fix broken build
Browse files Browse the repository at this point in the history
  • Loading branch information
msiemens committed Aug 17, 2015
1 parent 3527b7c commit c6a99f0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
2 changes: 1 addition & 1 deletion PyGitUp/gitup.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def get_git_dir():
if os.path.isdir(git_dir):
return abspath
else:
return execute('git rev-parse --show-toplevel')
return execute(['git', 'rev-parse', '--show-toplevel'])


class GitUp(object):
Expand Down
17 changes: 10 additions & 7 deletions PyGitUp/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,18 @@ def uniq(seq):

def execute(cmd):
""" Execute a command and return it's output. """
try:
lines = subprocess.check_output(cmd).splitlines()
except subprocess.CalledProcessError:
process = subprocess.Popen(cmd, stdout=subprocess.PIPE)
output, _ = process.communicate()
retcode = process.poll()

if retcode:
return None

lines = output.splitlines()
if lines:
return lines[0].strip()
else:
if lines:
return lines[0].strip()
else:
return None
return None


def decode(s):
Expand Down
12 changes: 7 additions & 5 deletions tests/test_git_not_in_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ def test_not_a_git_repo():
environ = os.environ.copy()
os.environ['PATH'] = ''

with assert_raises(GitError) as e:
from PyGitUp.gitup import GitUp
GitUp(testing=True)
try:
with assert_raises(GitError) as e:
from PyGitUp.gitup import GitUp
GitUp(testing=True)

assert e.exception.message == "The git executable could not be found"
assert e.exception.message == "The git executable could not be found"

os.environ.update(environ)
finally:
os.environ.update(environ)

0 comments on commit c6a99f0

Please sign in to comment.