Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(223)

Unified Diff: presubmit_canned_checks.py

Issue 11786007: Escape paths used in regexs for pylint (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: presubmit_canned_checks.py
diff --git a/presubmit_canned_checks.py b/presubmit_canned_checks.py
index 422ba422d2dd4d73e3d85ea3893e3bfc9ee59fb3..1e0d4c1729597e9c9deb40cc73a0d41801e7da22 100644
--- a/presubmit_canned_checks.py
+++ b/presubmit_canned_checks.py
@@ -641,8 +641,11 @@ def RunPylint(input_api, output_api, white_list=None, black_list=None,
error_type = output_api.PresubmitPromptWarning
# Only trigger if there is at least one python file affected.
- rel_path = lambda x : input_api.os_path.join(input_api.os_path.relpath(
- input_api.PresubmitLocalPath(), input_api.change.RepositoryRoot()), x)
+ def rel_path(regex):
+ """Modifies a regex for a subject to accept paths relative to root."""
+ prefix = input_api.os_path.join(input_api.os_path.relpath(
+ input_api.PresubmitLocalPath(), input_api.change.RepositoryRoot()), '')
+ return input_api.re.escape(prefix) + regex
src_filter = lambda x: input_api.FilterSourceFile(
x, map(rel_path, white_list), map(rel_path, black_list))
if not input_api.AffectedSourceFiles(src_filter):
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698