Skip to content

Commit

Permalink
Revert of Reland [Presubmit tests] Warn when new source files are not…
Browse files Browse the repository at this point in the history
… added to GN/GYPi files. (patchset chromium#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}
  • Loading branch information
sky authored and Commit bot committed Aug 30, 2016
1 parent 887b2bd commit b229a7d
Showing 1 changed file with 0 additions and 47 deletions.
47 changes: 0 additions & 47 deletions PRESUBMIT.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down Expand Up @@ -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


Expand Down

0 comments on commit b229a7d

Please sign in to comment.