mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-04 19:26:52 +00:00
Amend approach for no-commit-to-branch to use regex matching based on
feedback. Adds --pattern optional argument which can be used alongside --branch to block commits to a branch which matches a supplied regex expression
This commit is contained in:
parent
d6847c4827
commit
8d2785b9d6
3 changed files with 22 additions and 9 deletions
|
|
@ -44,17 +44,17 @@ def test_forbid_multiple_branches(temp_git_dir, branch_name):
|
|||
assert main(('--branch', 'b1', '--branch', 'b2'))
|
||||
|
||||
|
||||
def test_branch_wildcard_fail(temp_git_dir):
|
||||
def test_branch_pattern_fail(temp_git_dir):
|
||||
with temp_git_dir.as_cwd():
|
||||
cmd_output('git', 'checkout', '-b', 'another/branch')
|
||||
assert is_on_branch({'another/*'}) is True
|
||||
assert is_on_branch(set(), {'another/.*'}) is True
|
||||
|
||||
|
||||
@pytest.mark.parametrize('branch_name', ('master', 'another/branch'))
|
||||
def test_branch_wildcard_multiple_branches_fail(temp_git_dir, branch_name):
|
||||
def test_branch_pattern_multiple_branches_fail(temp_git_dir, branch_name):
|
||||
with temp_git_dir.as_cwd():
|
||||
cmd_output('git', 'checkout', '-b', branch_name)
|
||||
assert main(('--branch', 'master', '--branch', 'another/*'))
|
||||
assert main(('--branch', 'master', '--pattern', 'another/.*'))
|
||||
|
||||
|
||||
def test_main_default_call(temp_git_dir):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue