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

Unified Diff: PRESUBMIT.py

Issue 2203283003: Require gn format in presubmit (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 4 years, 4 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 | « BUILD.gn ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: PRESUBMIT.py
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index e0e01fb30fd7b3918b1c184a5a57be4c9072704b..95fea4f8dbfddd6054492980d9ccd4fa242d96b9 100644
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -185,6 +185,23 @@ def _RecipeSimulationTest(input_api, output_api):
'`%s` failed:\n%s' % (' '.join(cmd), e.output)))
return results
+def _CheckGNFormatted(input_api, output_api):
+ """Make sure any .gn files we're changing have been formatted."""
+ results = []
+ for f in input_api.AffectedFiles():
+ if not f.LocalPath().endswith('.gn'):
+ continue
+
+ cmd = ['gn', 'format', '--dry-run', f.LocalPath()]
+ try:
+ subprocess.check_output(cmd)
+ except subprocess.CalledProcessError:
+ fix = cmd[:]
+ fix[2] = '--in-place'
+ results.append(output_api.PresubmitError(
+ '`%s` failed, try\n\t%s' % (' '.join(cmd), ' '.join(fix))))
+ return results
+
def _CommonChecks(input_api, output_api):
"""Presubmit checks common to upload and commit."""
@@ -222,6 +239,7 @@ def CheckChangeOnUpload(input_api, output_api):
# Run on upload, not commit, since the presubmit bot apparently doesn't have
# coverage installed.
results.extend(_RecipeSimulationTest(input_api, output_api))
+ results.extend(_CheckGNFormatted(input_api, output_api))
return results
« no previous file with comments | « BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698