mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-05 03:26:53 +00:00
Add wildcard matching to no-commit-to-branch hook so that commits can
be blocked on, for example, all release branches with 'release/*'
This commit is contained in:
parent
aa9c202b9b
commit
d6847c4827
3 changed files with 19 additions and 4 deletions
|
|
@ -44,6 +44,19 @@ def test_forbid_multiple_branches(temp_git_dir, branch_name):
|
|||
assert main(('--branch', 'b1', '--branch', 'b2'))
|
||||
|
||||
|
||||
def test_branch_wildcard_fail(temp_git_dir):
|
||||
with temp_git_dir.as_cwd():
|
||||
cmd_output('git', 'checkout', '-b', 'another/branch')
|
||||
assert is_on_branch({'another/*'}) is True
|
||||
|
||||
|
||||
@pytest.mark.parametrize('branch_name', ('master', 'another/branch'))
|
||||
def test_branch_wildcard_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/*'))
|
||||
|
||||
|
||||
def test_main_default_call(temp_git_dir):
|
||||
with temp_git_dir.as_cwd():
|
||||
cmd_output('git', 'checkout', '-b', 'anotherbranch')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue