Skip to content

Commit

Permalink
fix: catch missing arg if using {prepare-}commit-msg stage
Browse files Browse the repository at this point in the history
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 pre-commit#1336]

chore: improve error message for hook stage check
  • Loading branch information
particledecay committed Feb 23, 2020
1 parent 1c641b1 commit fc8ced7
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pre_commit/commands/run.py
Expand Up @@ -306,6 +306,9 @@ 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 `--hook-stage {args.hook_stage}`')
return 1

# Expose origin / source as environment variables for hooks to consume
if args.origin and args.source:
Expand Down

0 comments on commit fc8ced7

Please sign in to comment.