aboutsummaryrefslogtreecommitdiff
path: root/pw_presubmit
diff options
context:
space:
mode:
authorRob Mohr <mohrr@google.com>2021-12-03 11:26:14 -0800
committerCQ Bot Account <pigweed-scoped@luci-project-accounts.iam.gserviceaccount.com>2021-12-06 16:34:17 +0000
commit3e32619b590a790e1b378936ca5e876b40997ddc (patch)
treedcdfcfca3c65fe172593c32291ba775e840e71b5 /pw_presubmit
parent4cdb51b54d81ffc4a5f4adb189ea278e151a220a (diff)
downloadpigweed-3e32619b590a790e1b378936ca5e876b40997ddc.tar.gz
pw_presubmit: Fix Check.with_filter()
Fix Check.with_filter() so when there's an existing endswith value but not a new endswith value we don't add '' to the end. Change-Id: I1cd72627b03f7b4b295397bab27d01a3f3838c9c Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/71860 Pigweed-Auto-Submit: Rob Mohr <mohrr@google.com> Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com> Reviewed-by: Wyatt Hepler <hepler@google.com>
Diffstat (limited to 'pw_presubmit')
-rw-r--r--pw_presubmit/py/pw_presubmit/presubmit.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/pw_presubmit/py/pw_presubmit/presubmit.py b/pw_presubmit/py/pw_presubmit/presubmit.py
index d9a63774d..17b4fdd6d 100644
--- a/pw_presubmit/py/pw_presubmit/presubmit.py
+++ b/pw_presubmit/py/pw_presubmit/presubmit.py
@@ -500,12 +500,13 @@ class Check:
endswith: Iterable[str] = '',
exclude: Iterable[Union[Pattern[str], str]] = ()
) -> Check:
+ endswith = self.filter.endswith
+ if endswith:
+ endswith = endswith + _make_str_tuple(endswith)
+ exclude = self.filter.exclude + tuple(re.compile(e) for e in exclude)
+
return Check(check_function=self._check,
- path_filter=_Filter(endswith=self.filter.endswith +
- _make_str_tuple(endswith),
- exclude=self.filter.exclude +
- tuple(re.compile(e)
- for e in exclude)),
+ path_filter=_Filter(endswith=endswith, exclude=exclude),
always_run=self.always_run)
@property