Adding upstream version 2.11.0.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
bee1fee448
commit
0c77307851
33 changed files with 586 additions and 19 deletions
|
@ -97,6 +97,7 @@ def test_run_legacy_recursive(tmpdir):
|
|||
('pre-push', ['branch_name', 'remote_name']),
|
||||
('commit-msg', ['.git/COMMIT_EDITMSG']),
|
||||
('post-commit', []),
|
||||
('post-merge', ['1']),
|
||||
('post-checkout', ['old_head', 'new_head', '1']),
|
||||
# multiple choices for commit-editmsg
|
||||
('prepare-commit-msg', ['.git/COMMIT_EDITMSG']),
|
||||
|
@ -157,6 +158,14 @@ def test_run_ns_post_commit():
|
|||
assert ns.color is True
|
||||
|
||||
|
||||
def test_run_ns_post_merge():
|
||||
ns = hook_impl._run_ns('post-merge', True, ('1',), b'')
|
||||
assert ns is not None
|
||||
assert ns.hook_stage == 'post-merge'
|
||||
assert ns.color is True
|
||||
assert ns.is_squash_merge == '1'
|
||||
|
||||
|
||||
def test_run_ns_post_checkout():
|
||||
ns = hook_impl._run_ns('post-checkout', True, ('a', 'b', 'c'), b'')
|
||||
assert ns is not None
|
||||
|
|
|
@ -259,7 +259,10 @@ def _path_without_us():
|
|||
exe = find_executable('pre-commit', _environ=env)
|
||||
while exe:
|
||||
parts = env['PATH'].split(os.pathsep)
|
||||
after = [x for x in parts if x.lower() != os.path.dirname(exe).lower()]
|
||||
after = [
|
||||
x for x in parts
|
||||
if x.lower().rstrip(os.sep) != os.path.dirname(exe).lower()
|
||||
]
|
||||
if parts == after:
|
||||
raise AssertionError(exe, parts)
|
||||
env['PATH'] = os.pathsep.join(after)
|
||||
|
@ -759,6 +762,48 @@ def test_post_commit_integration(tempdir_factory, store):
|
|||
assert os.path.exists('post-commit.tmp')
|
||||
|
||||
|
||||
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'],
|
||||
}],
|
||||
},
|
||||
]
|
||||
write_config(path, config)
|
||||
with cwd(path):
|
||||
# create a simple diamond of commits for a non-trivial merge
|
||||
open('init', 'a').close()
|
||||
cmd_output('git', 'add', '.')
|
||||
git_commit()
|
||||
|
||||
open('master', 'a').close()
|
||||
cmd_output('git', 'add', '.')
|
||||
git_commit()
|
||||
|
||||
cmd_output('git', 'checkout', '-b', 'branch', 'HEAD^')
|
||||
open('branch', 'a').close()
|
||||
cmd_output('git', 'add', '.')
|
||||
git_commit()
|
||||
|
||||
cmd_output('git', 'checkout', 'master')
|
||||
install(C.CONFIG_FILE, store, hook_types=['post-merge'])
|
||||
retc, stdout, stderr = cmd_output_mocked_pre_commit_home(
|
||||
'git', 'merge', 'branch',
|
||||
tempdir_factory=tempdir_factory,
|
||||
)
|
||||
assert retc == 0
|
||||
assert os.path.exists('post-merge.tmp')
|
||||
|
||||
|
||||
def test_post_checkout_integration(tempdir_factory, store):
|
||||
path = git_dir(tempdir_factory)
|
||||
config = [
|
||||
|
|
|
@ -494,6 +494,15 @@ def test_all_push_options_ok(cap_out, store, repo_with_passing_hook):
|
|||
assert b'Specify both --from-ref and --to-ref.' not in printed
|
||||
|
||||
|
||||
def test_is_squash_merge(cap_out, store, repo_with_passing_hook):
|
||||
args = run_opts(is_squash_merge='1')
|
||||
environ: MutableMapping[str, str] = {}
|
||||
ret, printed = _do_run(
|
||||
cap_out, store, repo_with_passing_hook, args, environ,
|
||||
)
|
||||
assert environ['PRE_COMMIT_IS_SQUASH_MERGE'] == '1'
|
||||
|
||||
|
||||
def test_checkout_type(cap_out, store, repo_with_passing_hook):
|
||||
args = run_opts(from_ref='', to_ref='', checkout_type='1')
|
||||
environ: MutableMapping[str, str] = {}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue