mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-09 21:04:17 +00:00
Increase robustness of tests involving git
1. Disable automatic `git commit` GPG-signing, since that requires interaction. This issue was encountered in practice by me, causing spurious test failures 2. In case path operands could turn out to start with dashes, escape the operand list with '--'.
This commit is contained in:
parent
6b1aa19425
commit
9e89b7616a
4 changed files with 23 additions and 16 deletions
|
|
@ -80,11 +80,18 @@ xfailif_no_gitlfs = pytest.mark.xfail(
|
|||
def test_allows_gitlfs(temp_git_dir): # pragma: no cover
|
||||
with temp_git_dir.as_cwd():
|
||||
# Work around https://github.com/github/git-lfs/issues/913
|
||||
cmd_output('git', 'commit', '--allow-empty', '-m', 'foo')
|
||||
cmd_output(
|
||||
'git',
|
||||
'commit',
|
||||
'--no-gpg-sign',
|
||||
'--allow-empty',
|
||||
'-m',
|
||||
'foo',
|
||||
)
|
||||
cmd_output('git', 'lfs', 'install')
|
||||
temp_git_dir.join('f.py').write('a' * 10000)
|
||||
cmd_output('git', 'lfs', 'track', 'f.py')
|
||||
cmd_output('git', 'add', '.')
|
||||
cmd_output('git', 'add', '--', '.')
|
||||
# Should succeed
|
||||
assert main(('--maxkb', '9', 'f.py')) == 0
|
||||
|
||||
|
|
@ -96,8 +103,8 @@ def test_moves_with_gitlfs(temp_git_dir): # pragma: no cover
|
|||
cmd_output('git', 'lfs', 'track', 'a.bin', 'b.bin')
|
||||
# First add the file we're going to move
|
||||
temp_git_dir.join('a.bin').write('a' * 10000)
|
||||
cmd_output('git', 'add', '.')
|
||||
cmd_output('git', 'commit', '-am', 'foo')
|
||||
cmd_output('git', 'add', '--', '.')
|
||||
cmd_output('git', 'commit', '--no-gpg-sign', '-am', 'foo')
|
||||
# Now move it and make sure the hook still succeeds
|
||||
cmd_output('git', 'mv', 'a.bin', 'b.bin')
|
||||
assert main(('--maxkb', '9', 'b.bin')) == 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue