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

Unified Diff: presubmit_support.py

Issue 115616: Add repository root presubmit support. (Closed)
Patch Set: Fix diff to not include the prior patches. Created 11 years, 7 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 | « gcl.py ('k') | tests/gcl_unittest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: presubmit_support.py
diff --git a/presubmit_support.py b/presubmit_support.py
index 7c73ab05ad4f235674e2e728c8426f7d3200286e..96d138040ef5bfd1c57e57f86969347de7086fed 100755
--- a/presubmit_support.py
+++ b/presubmit_support.py
@@ -603,7 +603,8 @@ def DoPresubmitChecks(change_info,
committing,
verbose,
output_stream,
- input_stream):
+ input_stream,
+ default_presubmit):
"""Runs all presubmit checks that apply to the files in the change.
This finds all PRESUBMIT.py files in directories enclosing the files in the
@@ -619,19 +620,24 @@ def DoPresubmitChecks(change_info,
verbose: Prints debug info.
output_stream: A stream to write output from presubmit tests to.
input_stream: A stream to read input from the user.
+ default_presubmit: A default presubmit script to execute in any case.
Return:
True if execution can continue, False if not.
"""
presubmit_files = ListRelevantPresubmitFiles(change_info.FileList())
if not presubmit_files and verbose:
- print "Warning, no presubmit.py found."
+ output_stream.write("Warning, no presubmit.py found.")
results = []
executer = PresubmitExecuter(change_info, committing)
+ if default_presubmit:
+ if verbose:
+ output_stream.write("Running default presubmit script")
+ results += executer.ExecPresubmitScript(default_presubmit, 'PRESUBMIT.py')
for filename in presubmit_files:
filename = os.path.abspath(filename)
if verbose:
- print "Running %s" % filename
+ output_stream.write("Running %s" % filename)
# Accept CRLF presubmit script.
presubmit_script = gcl.ReadFile(filename, 'rU')
results += executer.ExecPresubmitScript(presubmit_script, filename)
@@ -701,11 +707,12 @@ def Main(argv):
files = ParseFiles(args, options.recursive)
if options.verbose:
print "Found %d files." % len(files)
- return DoPresubmitChecks(gcl.ChangeInfo(name='temp', files=files),
- options.commit,
- options.verbose,
- sys.stdout,
- sys.stdin)
+ return not DoPresubmitChecks(gcl.ChangeInfo(name='temp', files=files),
+ options.commit,
+ options.verbose,
+ sys.stdout,
+ sys.stdin,
+ default_presubmit=None)
if __name__ == '__main__':
« no previous file with comments | « gcl.py ('k') | tests/gcl_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698