fix: catch missing arg if using {prepare-}commit-msg stage

If using the prepare-commit-msg and commit-msg stages specifically (such
    as with the try-repo command), the `--commit-msg-filename` arg must be
provided.

[fixes #1336]

chore: improve error message for hook stage check
This commit is contained in:
Joey Espinosa 2020-02-22 00:22:19 -05:00 committed by Anthony Sottile
parent 1c641b1c28
commit 5258dce73b
2 changed files with 20 additions and 8 deletions

View file

@ -306,6 +306,15 @@ def run(
f'`git add {config_file}` to fix this.',
)
return 1
if (
args.hook_stage in {'prepare-commit-msg', 'commit-msg'} and
not args.commit_msg_filename
):
logger.error(
f'`--commit-msg-filename` is required for '
f'`--hook-stage {args.hook_stage}`',
)
return 1
# Expose origin / source as environment variables for hooks to consume
if args.origin and args.source: