mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-03-30 18:26:53 +00:00
Add test for multiple patterns
This commit is contained in:
parent
e01e1717b1
commit
ac248b5011
1 changed files with 15 additions and 1 deletions
|
|
@ -20,6 +20,18 @@ def test_current_branch(temp_git_dir):
|
|||
|
||||
# Input, expected value, branch, template
|
||||
TESTS = (
|
||||
(
|
||||
b'',
|
||||
b'',
|
||||
'test', # this should not trigger anything
|
||||
'prepare_commit_msg_prepend.j2',
|
||||
),
|
||||
(
|
||||
b'',
|
||||
b'[1.0.0] ',
|
||||
'release/1.0.0', # but this should
|
||||
'prepare_commit_msg_prepend.j2',
|
||||
),
|
||||
(
|
||||
b'',
|
||||
b'[TT-01] ',
|
||||
|
|
@ -64,7 +76,8 @@ def test_update_commit_file(
|
|||
with temp_git_dir.as_cwd():
|
||||
path = temp_git_dir.join('COMMIT_EDITMSG')
|
||||
path.write_binary(input_s)
|
||||
ticket = branch_name.split('/')[1]
|
||||
parts = branch_name.split('/')
|
||||
ticket = parts[1] if len(parts) > 1 else parts[0]
|
||||
jinja = get_jinja_env()
|
||||
update_commit_file(jinja, path, template, ticket)
|
||||
|
||||
|
|
@ -89,6 +102,7 @@ def test_main(
|
|||
argv=[
|
||||
'-t', template,
|
||||
'-p', '(?<=feature/).*',
|
||||
'-p', '(?<=release/).*',
|
||||
str(path),
|
||||
],
|
||||
) == 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue