1
0
Fork 0

Merging upstream version 2.5.1.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-09 21:20:28 +01:00
parent 344ec6ad68
commit 46a56c0856
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
37 changed files with 457 additions and 213 deletions

View file

@ -726,6 +726,32 @@ def test_commit_msg_legacy(commit_msg_repo, tempdir_factory, store):
assert second_line.startswith('Must have "Signed off by:"...')
def test_post_commit_integration(tempdir_factory, store):
path = git_dir(tempdir_factory)
config = [
{
'repo': 'local',
'hooks': [{
'id': 'post-commit',
'name': 'Post commit',
'entry': 'touch post-commit.tmp',
'language': 'system',
'always_run': True,
'verbose': True,
'stages': ['post-commit'],
}],
},
]
write_config(path, config)
with cwd(path):
_get_commit_output(tempdir_factory)
assert not os.path.exists('post-commit.tmp')
install(C.CONFIG_FILE, store, hook_types=['post-commit'])
_get_commit_output(tempdir_factory)
assert os.path.exists('post-commit.tmp')
def test_post_checkout_integration(tempdir_factory, store):
path = git_dir(tempdir_factory)
config = [
@ -763,6 +789,37 @@ def test_post_checkout_integration(tempdir_factory, store):
assert 'some_file' not in stderr
def test_skips_post_checkout_unstaged_changes(tempdir_factory, store):
path = git_dir(tempdir_factory)
config = {
'repo': 'local',
'hooks': [{
'id': 'fail',
'name': 'fail',
'entry': 'fail',
'language': 'fail',
'always_run': True,
'stages': ['post-checkout'],
}],
}
write_config(path, config)
with cwd(path):
cmd_output('git', 'add', '.')
_get_commit_output(tempdir_factory)
install(C.CONFIG_FILE, store, hook_types=['pre-commit'])
install(C.CONFIG_FILE, store, hook_types=['post-checkout'])
# make an unstaged change so staged_files_only fires
open('file', 'a').close()
cmd_output('git', 'add', 'file')
with open('file', 'w') as f:
f.write('unstaged changes')
retc, out = _get_commit_output(tempdir_factory, all_files=False)
assert retc == 0
def test_prepare_commit_msg_integration_failing(
failing_prepare_commit_msg_repo, tempdir_factory, store,
):