summaryrefslogtreecommitdiffstats
path: root/pre_commit/commands
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2021-03-08 17:48:47 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2021-03-08 17:48:47 +0000
commit4db15c5b771323f1acdeb06e4acc671856da5ea9 (patch)
tree1cde2767753275f2f87a34a2606b2415a467ff09 /pre_commit/commands
parentAdding upstream version 2.10.1. (diff)
downloadpre-commit-4db15c5b771323f1acdeb06e4acc671856da5ea9.tar.xz
pre-commit-4db15c5b771323f1acdeb06e4acc671856da5ea9.zip
Adding upstream version 2.11.0.upstream/2.11.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'pre_commit/commands')
-rw-r--r--pre_commit/commands/hook_impl.py5
-rw-r--r--pre_commit/commands/run.py5
2 files changed, 9 insertions, 1 deletions
diff --git a/pre_commit/commands/hook_impl.py b/pre_commit/commands/hook_impl.py
index 25c5fdf..a766ee9 100644
--- a/pre_commit/commands/hook_impl.py
+++ b/pre_commit/commands/hook_impl.py
@@ -76,6 +76,7 @@ def _ns(
remote_url: Optional[str] = None,
commit_msg_filename: Optional[str] = None,
checkout_type: Optional[str] = None,
+ is_squash_merge: Optional[str] = None,
) -> argparse.Namespace:
return argparse.Namespace(
color=color,
@@ -88,6 +89,7 @@ def _ns(
commit_msg_filename=commit_msg_filename,
all_files=all_files,
checkout_type=checkout_type,
+ is_squash_merge=is_squash_merge,
files=(),
hook=None,
verbose=False,
@@ -158,6 +160,7 @@ _EXPECTED_ARG_LENGTH_BY_HOOK = {
'post-commit': 0,
'pre-commit': 0,
'pre-merge-commit': 0,
+ 'post-merge': 1,
'pre-push': 2,
}
@@ -199,6 +202,8 @@ def _run_ns(
hook_type, color,
from_ref=args[0], to_ref=args[1], checkout_type=args[2],
)
+ elif hook_type == 'post-merge':
+ return _ns(hook_type, color, is_squash_merge=args[0])
else:
raise AssertionError(f'unexpected hook type: {hook_type}')
diff --git a/pre_commit/commands/run.py b/pre_commit/commands/run.py
index 891488d..05c3268 100644
--- a/pre_commit/commands/run.py
+++ b/pre_commit/commands/run.py
@@ -245,7 +245,7 @@ def _compute_cols(hooks: Sequence[Hook]) -> int:
def _all_filenames(args: argparse.Namespace) -> Collection[str]:
# these hooks do not operate on files
- if args.hook_stage in {'post-checkout', 'post-commit'}:
+ if args.hook_stage in {'post-checkout', 'post-commit', 'post-merge'}:
return ()
elif args.hook_stage in {'prepare-commit-msg', 'commit-msg'}:
return (args.commit_msg_filename,)
@@ -379,6 +379,9 @@ def run(
if args.checkout_type:
environ['PRE_COMMIT_CHECKOUT_TYPE'] = args.checkout_type
+ if args.is_squash_merge:
+ environ['PRE_COMMIT_IS_SQUASH_MERGE'] = args.is_squash_merge
+
# Set pre_commit flag
environ['PRE_COMMIT'] = '1'