Catch CalledProcessError when running outside a git repository

This commit is contained in:
Edgar Geier 2019-07-23 00:40:51 +02:00
parent 3d8a6a5b81
commit 28f0d16073

View file

@ -42,7 +42,11 @@ def _file_path(path):
elif os.path.exists(path):
msg = '{} is not a regular file'.format(path)
raise argparse.ArgumentTypeError(msg)
git_path = os.path.join(git.get_root(), path)
try:
git_path = os.path.join(git.get_root(), path)
except CalledProcessError:
msg = '{} does not exist'.format(path)
raise argparse.ArgumentTypeError(msg)
if os.path.isfile(git_path):
return git_path
else: