mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-04 11:16:53 +00:00
Fix no-commit-to-branch when not on a branch
This commit is contained in:
parent
2f1e5e2abf
commit
93f319c1f8
2 changed files with 20 additions and 13 deletions
|
|
@ -29,19 +29,22 @@ def test_master_branch(temp_git_dir):
|
|||
assert is_on_branch('master') is True
|
||||
|
||||
|
||||
def test_main_b_call(temp_git_dir):
|
||||
with temp_git_dir.as_cwd():
|
||||
cmd_output('git', 'checkout', '-b', 'other')
|
||||
assert main(['-b', 'other']) == 1
|
||||
|
||||
|
||||
def test_main_branch_call(temp_git_dir):
|
||||
with temp_git_dir.as_cwd():
|
||||
cmd_output('git', 'checkout', '-b', 'other')
|
||||
assert main(['--branch', 'other']) == 1
|
||||
assert main(('--branch', 'other')) == 1
|
||||
|
||||
|
||||
def test_main_default_call(temp_git_dir):
|
||||
with temp_git_dir.as_cwd():
|
||||
cmd_output('git', 'checkout', '-b', 'anotherbranch')
|
||||
assert main() == 0
|
||||
assert main(()) == 0
|
||||
|
||||
|
||||
def test_not_on_a_branch(temp_git_dir):
|
||||
with temp_git_dir.as_cwd():
|
||||
cmd_output('git', 'commit', '--no-gpg-sign', '--allow-empty', '-m1')
|
||||
head = cmd_output('git', 'rev-parse', 'HEAD').strip()
|
||||
cmd_output('git', 'checkout', head)
|
||||
# we're not on a branch!
|
||||
assert main(()) == 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue