1
0
Fork 0

Merging upstream version 2.20.0.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-09 21:34:34 +01:00
parent 65a743ec23
commit eea7a7b6f9
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
18 changed files with 165 additions and 87 deletions

View file

@ -154,6 +154,42 @@ def test_run_ns_commit_msg():
assert ns.commit_msg_filename == '.git/COMMIT_MSG'
def test_run_ns_prepare_commit_msg_one_arg():
ns = hook_impl._run_ns(
'prepare-commit-msg', False,
('.git/COMMIT_MSG',), b'',
)
assert ns is not None
assert ns.hook_stage == 'prepare-commit-msg'
assert ns.color is False
assert ns.commit_msg_filename == '.git/COMMIT_MSG'
def test_run_ns_prepare_commit_msg_two_arg():
ns = hook_impl._run_ns(
'prepare-commit-msg', False,
('.git/COMMIT_MSG', 'message'), b'',
)
assert ns is not None
assert ns.hook_stage == 'prepare-commit-msg'
assert ns.color is False
assert ns.commit_msg_filename == '.git/COMMIT_MSG'
assert ns.prepare_commit_message_source == 'message'
def test_run_ns_prepare_commit_msg_three_arg():
ns = hook_impl._run_ns(
'prepare-commit-msg', False,
('.git/COMMIT_MSG', 'message', 'HEAD'), b'',
)
assert ns is not None
assert ns.hook_stage == 'prepare-commit-msg'
assert ns.color is False
assert ns.commit_msg_filename == '.git/COMMIT_MSG'
assert ns.prepare_commit_message_source == 'message'
assert ns.commit_object_name == 'HEAD'
def test_run_ns_post_commit():
ns = hook_impl._run_ns('post-commit', True, (), b'')
assert ns is not None

View file

@ -810,7 +810,12 @@ def test_prepare_commit_msg_hook(cap_out, store, prepare_commit_msg_repo):
cap_out,
store,
prepare_commit_msg_repo,
{'hook_stage': 'prepare-commit-msg', 'commit_msg_filename': filename},
{
'hook_stage': 'prepare-commit-msg',
'commit_msg_filename': filename,
'prepare_commit_message_source': 'commit',
'commit_object_name': 'HEAD',
},
expected_outputs=[b'Add "Signed off by:"', b'Passed'],
expected_ret=0,
stage=False,

View file

@ -21,24 +21,6 @@ from testing.util import cwd
from testing.util import git_commit
@pytest.fixture(autouse=True)
def no_warnings(recwarn):
yield
warnings = []
for warning in recwarn: # pragma: no cover
message = str(warning.message)
# ImportWarning: Not importing directory '...' missing __init__(.py)
if not (
isinstance(warning.message, ImportWarning) and
message.startswith('Not importing directory ') and
' missing __init__' in message
):
warnings.append(
f'{warning.filename}:{warning.lineno} {message}',
)
assert not warnings
@pytest.fixture
def tempdir_factory(tmpdir):
class TmpdirFactory:

View file

@ -45,9 +45,11 @@ def test_error_handler_fatal_error(mocked_log_and_exit):
r'Traceback \(most recent call last\):\n'
r' File ".+pre_commit.error_handler.py", line \d+, in error_handler\n'
r' yield\n'
r'( \^\^\^\^\^\n)?'
r' File ".+tests.error_handler_test.py", line \d+, '
r'in test_error_handler_fatal_error\n'
r' raise exc\n'
r'( \^\^\^\^\^\^\^\^\^\n)?'
r'(pre_commit\.errors\.)?FatalError: just a test\n',
)
pattern.assert_matches(mocked_log_and_exit.call_args[0][3])
@ -69,9 +71,11 @@ def test_error_handler_uncaught_error(mocked_log_and_exit):
r'Traceback \(most recent call last\):\n'
r' File ".+pre_commit.error_handler.py", line \d+, in error_handler\n'
r' yield\n'
r'( \^\^\^\^\^\n)?'
r' File ".+tests.error_handler_test.py", line \d+, '
r'in test_error_handler_uncaught_error\n'
r' raise exc\n'
r'( \^\^\^\^\^\^\^\^\^\n)?'
r'ValueError: another test\n',
)
pattern.assert_matches(mocked_log_and_exit.call_args[0][3])
@ -93,9 +97,11 @@ def test_error_handler_keyboardinterrupt(mocked_log_and_exit):
r'Traceback \(most recent call last\):\n'
r' File ".+pre_commit.error_handler.py", line \d+, in error_handler\n'
r' yield\n'
r'( \^\^\^\^\^\n)?'
r' File ".+tests.error_handler_test.py", line \d+, '
r'in test_error_handler_keyboardinterrupt\n'
r' raise exc\n'
r'( \^\^\^\^\^\^\^\^\^\n)?'
r'KeyboardInterrupt\n',
)
pattern.assert_matches(mocked_log_and_exit.call_args[0][3])

View file

@ -332,6 +332,13 @@ def test_run_a_ruby_hook(tempdir_factory, store):
)
def test_run_a_ruby_hook_with_user_install_set(tempdir_factory, store, tmpdir):
gemrc = tmpdir.join('gemrc')
gemrc.write('gem: --user-install\n')
with envcontext((('GEMRC', str(gemrc)),)):
test_run_a_ruby_hook(tempdir_factory, store)
@xfailif_windows # pragma: win32 no cover
def test_run_versioned_ruby_hook(tempdir_factory, store):
_test_hook_repo(