From b229a7da7cedc5950b4f038503d42f04cd8c9d88 Mon Sep 17 00:00:00 2001 From: sky Date: Mon, 29 Aug 2016 22:37:00 -0700 Subject: [PATCH] Revert of Reland [Presubmit tests] Warn when new source files are not added to GN/GYPi files. (patchset #1 id:1 of https://codereview.chromium.org/2278093004/ ) Reason for revert: This causes warning if files are referenced in gyp file. https://codereview.chromium.org/2285703003/ triggered presubmit when it shouln't have. Original issue's description: > Reland [Presubmit tests] Warn when new source files are not added to GN/GYPi files. > > Add a presubmit check that warns when new source files are > not added to GN or gypi files. Check is done on upload only before gni includes are fixed. > > BUG=112371 > > Committed: https://crrev.com/1efc2f5f650a355056a98b6c99d4d0260742a750 > Cr-Commit-Position: refs/heads/master@{#414975} TBR=dpranke@chromium.org,maksim.sisov@intel.com # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=112371 Review-Url: https://codereview.chromium.org/2293763002 Cr-Commit-Position: refs/heads/master@{#415166} --- PRESUBMIT.py | 47 ----------------------------------------------- 1 file changed, 47 deletions(-) diff --git a/PRESUBMIT.py b/PRESUBMIT.py index 310091e538370d..e2e042336926e5 100644 --- a/PRESUBMIT.py +++ b/PRESUBMIT.py @@ -1946,52 +1946,6 @@ def _AndroidSpecificOnUploadChecks(input_api, output_api): results.extend(_CheckAndroidToastUsage(input_api, output_api)) return results -def _CheckNewSourceFileAddedToGnGypi(input_api, output_api): - """Checks new source code files were added to GN/GYPi files""" - new_source_files = [] - gn_gypi_files = [] - - """ Get lists of new source code files and GN/GYPi files in the commit""" - for f in input_api.AffectedFiles(): - if f.LocalPath().endswith(('.gn', '.gypi')): - gn_gypi_files.append(f) - continue - if f.LocalPath().endswith(('.h', '.c', '.cc', '.m', '.mm', '.java')): - if f.Action() == 'A': - new_source_files.append(f.LocalPath()) - - if not new_source_files: - return [] - - if not gn_gypi_files: - return [output_api.PresubmitPromptWarning('The following new' - ' source code files must be added to GN/GYPI files:\n ' + - '\n '.join(new_source_files))] - - """Get a list of new source code files that CAN BE FOUND in the GN/GYPI - files""" - source_files_listed = [] - for f in new_source_files: - head, sep, tail = f.rpartition('/') - source_file_match_pattern = tail - for g in gn_gypi_files: - for line in g.GenerateScmDiff().splitlines(): - if line.endswith((source_file_match_pattern + '",', - source_file_match_pattern + '\',')): - source_files_listed.append(f) - break - - """Remove files, which has been found in the GN files, from the list""" - for f in source_files_listed: - if f in new_source_files: - new_source_files.remove(f) - - if new_source_files: - return [output_api.PresubmitPromptWarning('The following new' - ' source code files must be added to GN/GYPI files:\n ' + - '\n '.join(new_source_files))] - - return [] def _CommonChecks(input_api, output_api): """Checks common to both upload and commit.""" @@ -2254,7 +2208,6 @@ def CheckChangeOnUpload(input_api, output_api): input_api.canned_checks.CheckGNFormatted(input_api, output_api)) results.extend(_CheckUmaHistogramChanges(input_api, output_api)) results.extend(_AndroidSpecificOnUploadChecks(input_api, output_api)) - results.extend(_CheckNewSourceFileAddedToGnGypi(input_api, output_api)) return results