Adding upstream version 2.15.0.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
dcfd04081c
commit
d3b459fcc0
38 changed files with 396 additions and 59 deletions
|
@ -99,6 +99,7 @@ def test_run_legacy_recursive(tmpdir):
|
|||
('post-commit', []),
|
||||
('post-merge', ['1']),
|
||||
('post-checkout', ['old_head', 'new_head', '1']),
|
||||
('post-rewrite', ['amend']),
|
||||
# multiple choices for commit-editmsg
|
||||
('prepare-commit-msg', ['.git/COMMIT_EDITMSG']),
|
||||
('prepare-commit-msg', ['.git/COMMIT_EDITMSG', 'message']),
|
||||
|
@ -166,6 +167,14 @@ def test_run_ns_post_merge():
|
|||
assert ns.is_squash_merge == '1'
|
||||
|
||||
|
||||
def test_run_ns_post_rewrite():
|
||||
ns = hook_impl._run_ns('post-rewrite', True, ('amend',), b'')
|
||||
assert ns is not None
|
||||
assert ns.hook_stage == 'post-rewrite'
|
||||
assert ns.color is True
|
||||
assert ns.rewrite_command == 'amend'
|
||||
|
||||
|
||||
def test_run_ns_post_checkout():
|
||||
ns = hook_impl._run_ns('post-checkout', True, ('a', 'b', 'c'), b'')
|
||||
assert ns is not None
|
||||
|
|
|
@ -817,6 +817,35 @@ def test_post_merge_integration(tempdir_factory, store):
|
|||
assert os.path.exists('post-merge.tmp')
|
||||
|
||||
|
||||
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'],
|
||||
}],
|
||||
},
|
||||
]
|
||||
write_config(path, config)
|
||||
with cwd(path):
|
||||
open('init', 'a').close()
|
||||
cmd_output('git', 'add', '.')
|
||||
install(C.CONFIG_FILE, store, hook_types=['post-rewrite'])
|
||||
git_commit()
|
||||
|
||||
assert not os.path.exists('post-rewrite.tmp')
|
||||
|
||||
git_commit('--amend', '-m', 'ammended message')
|
||||
assert os.path.exists('post-rewrite.tmp')
|
||||
|
||||
|
||||
def test_post_checkout_integration(tempdir_factory, store):
|
||||
path = git_dir(tempdir_factory)
|
||||
config = [
|
||||
|
@ -948,7 +977,7 @@ def test_pre_merge_commit_integration(tempdir_factory, store):
|
|||
output_pattern = re_assert.Matches(
|
||||
r'^\[INFO\] Initializing environment for .+\n'
|
||||
r'Bash hook\.+Passed\n'
|
||||
r"Merge made by the 'recursive' strategy.\n"
|
||||
r"Merge made by the '(ort|recursive)' strategy.\n"
|
||||
r' foo \| 0\n'
|
||||
r' 1 file changed, 0 insertions\(\+\), 0 deletions\(-\)\n'
|
||||
r' create mode 100644 foo\n$',
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
import pytest
|
||||
|
||||
import pre_commit.constants as C
|
||||
from pre_commit.clientlib import InvalidConfigError
|
||||
from pre_commit.commands.migrate_config import migrate_config
|
||||
|
||||
|
||||
|
@ -130,13 +127,3 @@ def test_migrate_config_sha_to_rev(tmpdir):
|
|||
' rev: v1.2.0\n'
|
||||
' hooks: []\n'
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('contents', ('', '\n'))
|
||||
def test_migrate_config_invalid_configuration(tmpdir, contents):
|
||||
cfg = tmpdir.join(C.CONFIG_FILE)
|
||||
cfg.write(contents)
|
||||
with tmpdir.as_cwd(), pytest.raises(InvalidConfigError):
|
||||
migrate_config(C.CONFIG_FILE)
|
||||
# even though the config is invalid, this should be a noop
|
||||
assert cfg.read() == contents
|
||||
|
|
|
@ -504,6 +504,15 @@ def test_is_squash_merge(cap_out, store, repo_with_passing_hook):
|
|||
assert environ['PRE_COMMIT_IS_SQUASH_MERGE'] == '1'
|
||||
|
||||
|
||||
def test_rewrite_command(cap_out, store, repo_with_passing_hook):
|
||||
args = run_opts(rewrite_command='amend')
|
||||
environ: MutableMapping[str, str] = {}
|
||||
ret, printed = _do_run(
|
||||
cap_out, store, repo_with_passing_hook, args, environ,
|
||||
)
|
||||
assert environ['PRE_COMMIT_REWRITE_COMMAND'] == 'amend'
|
||||
|
||||
|
||||
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