From 66c50ea1f11a8776355f50800fe7e77e9eea4ce1 Mon Sep 17 00:00:00 2001 From: Wez Date: Fri, 6 Jan 2017 16:02:22 -0800 Subject: [PATCH] Fix OWNERS canned check to avoid duplicate output. 1. Update PanProjectChecks() to supply source_filter to CheckOwners(). This prevents files under e.g. third_party/WebKit being checked both by the top-level and sub-directory PRESUBMIT rules. 2. Fix CheckOwners() to list missing-OWNERS only for the sub-directory it is invoked on, rather than the whole CL. This prevents files under sub-directories with their own PRESUBMIT rule, within the same repo, from causing OWNERS to be checked for files outside that directory. BUG= Change-Id: I9bd5677a69efe9c78b4174a917780d6688991a38 Reviewed-on: https://chromium-review.googlesource.com/426003 Commit-Queue: James Weatherall Reviewed-by: Dirk Pranke --- presubmit_canned_checks.py | 4 ++-- tests/presubmit_unittest.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/presubmit_canned_checks.py b/presubmit_canned_checks.py index c38c013be..8f2e1a253 100644 --- a/presubmit_canned_checks.py +++ b/presubmit_canned_checks.py @@ -872,7 +872,7 @@ def CheckOwners(input_api, output_api, source_file_filter=None): output = output_api.PresubmitNotifyResult affected_files = set([f.LocalPath() for f in - input_api.change.AffectedFiles(file_filter=source_file_filter)]) + input_api.AffectedFiles(file_filter=source_file_filter)]) owners_db = input_api.owners_db owner_email, reviewers = GetCodereviewOwnerAndReviewers( @@ -1090,7 +1090,7 @@ def PanProjectChecks(input_api, output_api, if owners_check: snapshot("checking owners") results.extend(input_api.canned_checks.CheckOwners( - input_api, output_api, source_file_filter=None)) + input_api, output_api, source_file_filter=sources)) snapshot("checking long lines") results.extend(input_api.canned_checks.CheckLongLines( diff --git a/tests/presubmit_unittest.py b/tests/presubmit_unittest.py index 5e9a7cc60..c078c3212 100755 --- a/tests/presubmit_unittest.py +++ b/tests/presubmit_unittest.py @@ -2196,7 +2196,7 @@ class CannedChecksUnittest(PresubmitTestsBase): if not is_committing or (not tbr and issue): if not dry_run: affected_file.LocalPath().AndReturn('foo/xyz.cc') - change.AffectedFiles(file_filter=None).AndReturn([affected_file]) + input_api.AffectedFiles(file_filter=None).AndReturn([affected_file]) if issue and not rietveld_response and not gerrit_response: rietveld_response = { "owner_email": change.author_email,