diff --git a/powerline/lib/vcs/git.py b/powerline/lib/vcs/git.py index 60ee0fc0..d7d5733a 100644 --- a/powerline/lib/vcs/git.py +++ b/powerline/lib/vcs/git.py @@ -9,6 +9,7 @@ from powerline.lib.shell import readlines from powerline.lib.path import join from powerline.lib.encoding import (get_preferred_file_name_encoding, get_preferred_file_contents_encoding) +from powerline.lib.shell import which _ref_pat = re.compile(br'ref:\s*refs/heads/(.+)') @@ -155,6 +156,11 @@ try: return r if r != ' ' else None except ImportError: class Repository(GitRepository): + def __init__(self, *args, **kwargs): + if not which('git'): + raise OSError('git executable is not available') + super(Repository, self).__init__(*args, **kwargs) + @staticmethod def ignore_event(path, name): # Ignore changes to the index.lock file, since they happen diff --git a/tests/test_shells/test.sh b/tests/test_shells/test.sh index c645baff..fb4c4984 100755 --- a/tests/test_shells/test.sh +++ b/tests/test_shells/test.sh @@ -183,6 +183,7 @@ mkdir tests/shell/path ln -s "$(which "${PYTHON}")" tests/shell/path/python ln -s "$(which screen)" tests/shell/path ln -s "$(which env)" tests/shell/path +ln -s "$(which git)" tests/shell/path ln -s "$(which sleep)" tests/shell/path ln -s "$(which cat)" tests/shell/path ln -s "$(which false)" tests/shell/path