summaryrefslogtreecommitdiffstats
path: root/pre_commit/commands/run.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-01-04 07:22:18 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-01-04 07:22:18 +0000
commit58a809aa43ae21566be4613eb42ac56faf54f901 (patch)
tree371b9cc8a265cbabea4b12e5508b8bde6edf0b89 /pre_commit/commands/run.py
parentAdding upstream version 2.20.0. (diff)
downloadpre-commit-58a809aa43ae21566be4613eb42ac56faf54f901.tar.xz
pre-commit-58a809aa43ae21566be4613eb42ac56faf54f901.zip
Adding upstream version 2.21.0.upstream/2.21.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'pre_commit/commands/run.py')
-rw-r--r--pre_commit/commands/run.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/pre_commit/commands/run.py b/pre_commit/commands/run.py
index ad3d766..429e04c 100644
--- a/pre_commit/commands/run.py
+++ b/pre_commit/commands/run.py
@@ -263,7 +263,7 @@ def _all_filenames(args: argparse.Namespace) -> Collection[str]:
def _get_diff() -> bytes:
_, out, _ = cmd_output_b(
- 'git', 'diff', '--no-ext-diff', '--ignore-submodules', retcode=None,
+ 'git', 'diff', '--no-ext-diff', '--ignore-submodules', check=False,
)
return out
@@ -318,7 +318,7 @@ def _has_unmerged_paths() -> bool:
def _has_unstaged_config(config_file: str) -> bool:
retcode, _, _ = cmd_output_b(
'git', 'diff', '--no-ext-diff', '--exit-code', config_file,
- retcode=None,
+ check=False,
)
# be explicit, other git errors don't mean it has an unstaged config.
return retcode == 1
@@ -333,7 +333,7 @@ def run(
stash = not args.all_files and not args.files
# Check if we have unresolved merge conflict files and fail fast.
- if _has_unmerged_paths():
+ if stash and _has_unmerged_paths():
logger.error('Unmerged files. Resolve before committing.')
return 1
if bool(args.from_ref) != bool(args.to_ref):
@@ -420,7 +420,11 @@ def run(
return 1
skips = _get_skips(environ)
- to_install = [hook for hook in hooks if hook.id not in skips]
+ to_install = [
+ hook
+ for hook in hooks
+ if hook.id not in skips and hook.alias not in skips
+ ]
install_hook_envs(to_install, store)
return _run_hooks(config, hooks, skips, args)