Skip to content

Commit

Permalink
Add default '0' for squash-merge, fix post-merge tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Paweł Sacawa committed Feb 22, 2021
1 parent 0df2712 commit 19c01a5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
4 changes: 3 additions & 1 deletion pre_commit/main.py
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion tests/commands/hook_impl_test.py
Expand Up @@ -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']),
Expand Down
7 changes: 5 additions & 2 deletions tests/commands/install_uninstall_test.py
Expand Up @@ -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')

Expand Down

0 comments on commit 19c01a5

Please sign in to comment.