mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-04-16 10:31:46 +04:00
Catch CalledProcessError when running outside a git repository
This commit is contained in:
parent
3d8a6a5b81
commit
28f0d16073
1 changed files with 5 additions and 1 deletions
|
|
@ -42,7 +42,11 @@ def _file_path(path):
|
||||||
elif os.path.exists(path):
|
elif os.path.exists(path):
|
||||||
msg = '{} is not a regular file'.format(path)
|
msg = '{} is not a regular file'.format(path)
|
||||||
raise argparse.ArgumentTypeError(msg)
|
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):
|
if os.path.isfile(git_path):
|
||||||
return git_path
|
return git_path
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue