mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
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:
parent
1c641b1c28
commit
5258dce73b
2 changed files with 20 additions and 8 deletions
|
|
@ -663,12 +663,7 @@ def test_stages(cap_out, store, repo_with_passing_hook):
|
|||
'language': 'pygrep',
|
||||
'stages': [stage],
|
||||
}
|
||||
for i, stage in enumerate(
|
||||
(
|
||||
'commit', 'push', 'manual', 'prepare-commit-msg',
|
||||
'commit-msg',
|
||||
), 1,
|
||||
)
|
||||
for i, stage in enumerate(('commit', 'push', 'manual'), 1)
|
||||
],
|
||||
}
|
||||
add_config_to_repo(repo_with_passing_hook, config)
|
||||
|
|
@ -686,8 +681,6 @@ def test_stages(cap_out, store, repo_with_passing_hook):
|
|||
assert _run_for_stage('commit').startswith(b'hook 1...')
|
||||
assert _run_for_stage('push').startswith(b'hook 2...')
|
||||
assert _run_for_stage('manual').startswith(b'hook 3...')
|
||||
assert _run_for_stage('prepare-commit-msg').startswith(b'hook 4...')
|
||||
assert _run_for_stage('commit-msg').startswith(b'hook 5...')
|
||||
|
||||
|
||||
def test_commit_msg_hook(cap_out, store, commit_msg_repo):
|
||||
|
|
@ -819,6 +812,16 @@ def test_error_with_unstaged_config(cap_out, store, modified_config_repo):
|
|||
assert ret == 1
|
||||
|
||||
|
||||
def test_commit_msg_missing_filename(cap_out, store, repo_with_passing_hook):
|
||||
args = run_opts(hook_stage='commit-msg')
|
||||
ret, printed = _do_run(cap_out, store, repo_with_passing_hook, args)
|
||||
assert ret == 1
|
||||
assert printed == (
|
||||
b'[ERROR] `--commit-msg-filename` is required for '
|
||||
b'`--hook-stage commit-msg`\n'
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
'opts', (run_opts(all_files=True), run_opts(files=[C.CONFIG_FILE])),
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue