mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-04-15 01:51:46 +04:00
Add: post-merge hook support
This commit is contained in:
parent
d7b189ce56
commit
6b73138c73
9 changed files with 82 additions and 5 deletions
|
|
@ -759,6 +759,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 = [
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue