1
0
Fork 0

Adding upstream version 3.0.2.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-09 21:35:53 +01:00
parent cf86d7d6dd
commit ca00e08dce
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
107 changed files with 1775 additions and 2323 deletions

View file

@ -248,7 +248,7 @@ def test_install_idempotent(tempdir_factory, store):
def _path_without_us():
# Choose a path which *probably* doesn't include us
env = dict(os.environ)
exe = find_executable('pre-commit', _environ=env)
exe = find_executable('pre-commit', env=env)
while exe:
parts = env['PATH'].split(os.pathsep)
after = [
@ -258,7 +258,7 @@ def _path_without_us():
if parts == after:
raise AssertionError(exe, parts)
env['PATH'] = os.pathsep.join(after)
exe = find_executable('pre-commit', _environ=env)
exe = find_executable('pre-commit', env=env)
return env['PATH']
@ -276,18 +276,19 @@ def test_environment_not_sourced(tempdir_factory, store):
# Use a specific homedir to ignore --user installs
homedir = tempdir_factory.get()
ret, out = git_commit(
env={
'HOME': homedir,
'PATH': _path_without_us(),
# Git needs this to make a commit
'GIT_AUTHOR_NAME': os.environ['GIT_AUTHOR_NAME'],
'GIT_COMMITTER_NAME': os.environ['GIT_COMMITTER_NAME'],
'GIT_AUTHOR_EMAIL': os.environ['GIT_AUTHOR_EMAIL'],
'GIT_COMMITTER_EMAIL': os.environ['GIT_COMMITTER_EMAIL'],
},
check=False,
)
env = {
'HOME': homedir,
'PATH': _path_without_us(),
# Git needs this to make a commit
'GIT_AUTHOR_NAME': os.environ['GIT_AUTHOR_NAME'],
'GIT_COMMITTER_NAME': os.environ['GIT_COMMITTER_NAME'],
'GIT_AUTHOR_EMAIL': os.environ['GIT_AUTHOR_EMAIL'],
'GIT_COMMITTER_EMAIL': os.environ['GIT_COMMITTER_EMAIL'],
}
if os.name == 'nt' and 'PATHEXT' in os.environ: # pragma: no cover
env['PATHEXT'] = os.environ['PATHEXT']
ret, out = git_commit(env=env, check=False)
assert ret == 1
assert out == (
'`pre-commit` not found. '
@ -739,20 +740,22 @@ def test_commit_msg_legacy(commit_msg_repo, tempdir_factory, store):
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'],
}],
},
]
config = {
'repos': [
{
'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)
@ -765,20 +768,22 @@ def test_post_commit_integration(tempdir_factory, store):
def test_post_merge_integration(tempdir_factory, store):
path = git_dir(tempdir_factory)
config = [
{
'repo': 'local',
'hooks': [{
'id': 'post-merge',
'name': 'Post merge',
'entry': 'touch post-merge.tmp',
'language': 'system',
'always_run': True,
'verbose': True,
'stages': ['post-merge'],
}],
},
]
config = {
'repos': [
{
'repo': 'local',
'hooks': [{
'id': 'post-merge',
'name': 'Post merge',
'entry': 'touch post-merge.tmp',
'language': 'system',
'always_run': True,
'verbose': True,
'stages': ['post-merge'],
}],
},
],
}
write_config(path, config)
with cwd(path):
# create a simple diamond of commits for a non-trivial merge
@ -807,20 +812,22 @@ def test_post_merge_integration(tempdir_factory, store):
def test_post_rewrite_integration(tempdir_factory, store):
path = git_dir(tempdir_factory)
config = [
{
'repo': 'local',
'hooks': [{
'id': 'post-rewrite',
'name': 'Post rewrite',
'entry': 'touch post-rewrite.tmp',
'language': 'system',
'always_run': True,
'verbose': True,
'stages': ['post-rewrite'],
}],
},
]
config = {
'repos': [
{
'repo': 'local',
'hooks': [{
'id': 'post-rewrite',
'name': 'Post rewrite',
'entry': 'touch post-rewrite.tmp',
'language': 'system',
'always_run': True,
'verbose': True,
'stages': ['post-rewrite'],
}],
},
],
}
write_config(path, config)
with cwd(path):
open('init', 'a').close()
@ -836,21 +843,23 @@ def test_post_rewrite_integration(tempdir_factory, store):
def test_post_checkout_integration(tempdir_factory, store):
path = git_dir(tempdir_factory)
config = [
{
'repo': 'local',
'hooks': [{
'id': 'post-checkout',
'name': 'Post checkout',
'entry': 'bash -c "echo ${PRE_COMMIT_TO_REF}"',
'language': 'system',
'always_run': True,
'verbose': True,
'stages': ['post-checkout'],
}],
},
{'repo': 'meta', 'hooks': [{'id': 'identity'}]},
]
config = {
'repos': [
{
'repo': 'local',
'hooks': [{
'id': 'post-checkout',
'name': 'Post checkout',
'entry': 'bash -c "echo ${PRE_COMMIT_TO_REF}"',
'language': 'system',
'always_run': True,
'verbose': True,
'stages': ['post-checkout'],
}],
},
{'repo': 'meta', 'hooks': [{'id': 'identity'}]},
],
}
write_config(path, config)
with cwd(path):
cmd_output('git', 'add', '.')