summaryrefslogtreecommitdiffstats
path: root/pre_commit/commands
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2021-09-06 04:23:53 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2021-09-06 04:24:09 +0000
commit1968ada2d36e4508ef787e57f0e5f63214bcbad7 (patch)
tree69c01b5108b09faafa39e56ae48add8a2439f9db /pre_commit/commands
parentReleasing debian version 2.14.0-2. (diff)
downloadpre-commit-1968ada2d36e4508ef787e57f0e5f63214bcbad7.tar.xz
pre-commit-1968ada2d36e4508ef787e57f0e5f63214bcbad7.zip
Merging upstream version 2.15.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/migrate_config.py4
-rw-r--r--pre_commit/commands/run.py7
3 files changed, 11 insertions, 5 deletions
diff --git a/pre_commit/commands/hook_impl.py b/pre_commit/commands/hook_impl.py
index c544167..90bb33b 100644
--- a/pre_commit/commands/hook_impl.py
+++ b/pre_commit/commands/hook_impl.py
@@ -78,6 +78,7 @@ def _ns(
commit_msg_filename: Optional[str] = None,
checkout_type: Optional[str] = None,
is_squash_merge: Optional[str] = None,
+ rewrite_command: Optional[str] = None,
) -> argparse.Namespace:
return argparse.Namespace(
color=color,
@@ -92,6 +93,7 @@ def _ns(
all_files=all_files,
checkout_type=checkout_type,
is_squash_merge=is_squash_merge,
+ rewrite_command=rewrite_command,
files=(),
hook=None,
verbose=False,
@@ -166,6 +168,7 @@ _EXPECTED_ARG_LENGTH_BY_HOOK = {
'pre-commit': 0,
'pre-merge-commit': 0,
'post-merge': 1,
+ 'post-rewrite': 1,
'pre-push': 2,
}
@@ -209,6 +212,8 @@ def _run_ns(
)
elif hook_type == 'post-merge':
return _ns(hook_type, color, is_squash_merge=args[0])
+ elif hook_type == 'post-rewrite':
+ return _ns(hook_type, color, rewrite_command=args[0])
else:
raise AssertionError(f'unexpected hook type: {hook_type}')
diff --git a/pre_commit/commands/migrate_config.py b/pre_commit/commands/migrate_config.py
index a155f6b..fef14cd 100644
--- a/pre_commit/commands/migrate_config.py
+++ b/pre_commit/commands/migrate_config.py
@@ -3,7 +3,6 @@ import textwrap
import yaml
-from pre_commit.clientlib import load_config
from pre_commit.util import yaml_load
@@ -40,9 +39,6 @@ def _migrate_sha_to_rev(contents: str) -> str:
def migrate_config(config_file: str, quiet: bool = False) -> int:
- # ensure that the configuration is a valid pre-commit configuration
- load_config(config_file)
-
with open(config_file) as f:
orig_contents = contents = f.read()
diff --git a/pre_commit/commands/run.py b/pre_commit/commands/run.py
index d906d5b..95ad5e9 100644
--- a/pre_commit/commands/run.py
+++ b/pre_commit/commands/run.py
@@ -245,7 +245,9 @@ 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', 'post-merge'}:
+ if args.hook_stage in {
+ 'post-checkout', 'post-commit', 'post-merge', 'post-rewrite',
+ }:
return ()
elif args.hook_stage in {'prepare-commit-msg', 'commit-msg'}:
return (args.commit_msg_filename,)
@@ -386,6 +388,9 @@ def run(
if args.is_squash_merge:
environ['PRE_COMMIT_IS_SQUASH_MERGE'] = args.is_squash_merge
+ if args.rewrite_command:
+ environ['PRE_COMMIT_REWRITE_COMMAND'] = args.rewrite_command
+
# Set pre_commit flag
environ['PRE_COMMIT'] = '1'