summaryrefslogtreecommitdiffstats
path: root/pre_commit/commands/run.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2021-01-27 16:04:10 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2021-01-27 16:04:10 +0000
commita971f38b11f5955f6ea4f7922233d8324a5c6753 (patch)
tree5a424740e9cee97bc1c8053fea07db935c27b659 /pre_commit/commands/run.py
parentAdding upstream version 2.8.2. (diff)
downloadpre-commit-a971f38b11f5955f6ea4f7922233d8324a5c6753.tar.xz
pre-commit-a971f38b11f5955f6ea4f7922233d8324a5c6753.zip
Adding upstream version 2.9.3.upstream/2.9.3
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.py22
1 files changed, 18 insertions, 4 deletions
diff --git a/pre_commit/commands/run.py b/pre_commit/commands/run.py
index 0d335e2..1e8fad2 100644
--- a/pre_commit/commands/run.py
+++ b/pre_commit/commands/run.py
@@ -83,20 +83,32 @@ class Classifier:
self,
names: Sequence[str],
types: Collection[str],
+ types_or: Collection[str],
exclude_types: Collection[str],
) -> List[str]:
- types, exclude_types = frozenset(types), frozenset(exclude_types)
+ types = frozenset(types)
+ types_or = frozenset(types_or)
+ exclude_types = frozenset(exclude_types)
ret = []
for filename in names:
tags = self._types_for_file(filename)
- if tags >= types and not tags & exclude_types:
+ if (
+ tags >= types and
+ (not types_or or tags & types_or) and
+ not tags & exclude_types
+ ):
ret.append(filename)
return ret
def filenames_for_hook(self, hook: Hook) -> Tuple[str, ...]:
names = self.filenames
names = filter_by_include_exclude(names, hook.files, hook.exclude)
- names = self.by_types(names, hook.types, hook.exclude_types)
+ names = self.by_types(
+ names,
+ hook.types,
+ hook.types_or,
+ hook.exclude_types,
+ )
return tuple(names)
@classmethod
@@ -250,7 +262,9 @@ def _all_filenames(args: argparse.Namespace) -> Collection[str]:
def _get_diff() -> bytes:
- _, out, _ = cmd_output_b('git', 'diff', '--no-ext-diff', retcode=None)
+ _, out, _ = cmd_output_b(
+ 'git', 'diff', '--no-ext-diff', '--ignore-submodules', retcode=None,
+ )
return out