diff --git a/pre_commit/main.py b/pre_commit/main.py index c195dabaa..a8886b6ed 100644 --- a/pre_commit/main.py +++ b/pre_commit/main.py @@ -137,9 +137,11 @@ def _add_run_options(parser: argparse.ArgumentParser) -> None: ), ) parser.add_argument( - '--is-squash-merge', + '--squash-merge', action='store_const', const='1', + default='0', + dest='is_squash_merge', help=( 'During a post-merge hook, indicates whether the merge was a ' 'squash merge' diff --git a/tests/commands/hook_impl_test.py b/tests/commands/hook_impl_test.py index fe2fec3c9..c38b9caa1 100644 --- a/tests/commands/hook_impl_test.py +++ b/tests/commands/hook_impl_test.py @@ -97,7 +97,7 @@ def call(*_, **__): ('pre-push', ['branch_name', 'remote_name']), ('commit-msg', ['.git/COMMIT_EDITMSG']), ('post-commit', []), - ('post-merge', [True]), + ('post-merge', ['1']), ('post-checkout', ['old_head', 'new_head', '1']), # multiple choices for commit-editmsg ('prepare-commit-msg', ['.git/COMMIT_EDITMSG']), diff --git a/tests/commands/install_uninstall_test.py b/tests/commands/install_uninstall_test.py index 49aa4d8a9..c7d392ab8 100644 --- a/tests/commands/install_uninstall_test.py +++ b/tests/commands/install_uninstall_test.py @@ -791,9 +791,12 @@ def test_post_merge_integration(tempdir_factory, store): cmd_output('git', 'add', '.') git_commit() - cmd_output('git', 'switch', 'master') + cmd_output('git', 'checkout', 'master') install(C.CONFIG_FILE, store, hook_types=['post-merge']) - retc, stdout, stderr = cmd_output('git', 'merge', 'branch') + 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')