aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar rmistry <rmistry@google.com>2015-02-26 11:52:05 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-02-26 11:52:05 -0800
commit896f3932c83c5685c440449912997651b567a182 (patch)
treef0d39f65de2d1efa984dd17145e650f326a4b167
parented0069a4c789eb65d41917f4a255b363e8d18f44 (diff)
Automatically add NOTREECHECKS when uploading CLs from non master branches
These changes are possible due to the recently submitted depot_tools change https://codereview.chromium.org/949273002/ ('Add ability to specify and run post upload hooks'). BUG=skia: Review URL: https://codereview.chromium.org/963553002
-rw-r--r--PRESUBMIT.py30
1 files changed, 28 insertions, 2 deletions
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index 75f930619f..a4d90c8a8e 100644
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -248,6 +248,10 @@ def PostUploadHook(cl, change, output_api):
This hook does the following:
* Adds a link to preview docs changes if there are any docs changes in the CL.
* Adds 'NOTRY=true' if the CL contains only docs changes.
+ * Adds 'NOTREECHECKS=true' for non master branch changes since they do not
+ need to be gated on the master branch's tree.
+ * Adds 'NOTRY=true' for non master branch changes since trybots do not yet
+ work on them.
"""
results = []
@@ -272,7 +276,7 @@ def PostUploadHook(cl, change, output_api):
# If the change includes only doc changes then add NOTRY=true in the
# CL's description if it does not exist yet.
if all_docs_changes and not re.search(
- r'^NOTRY=true$', original_description, re.M | re.I):
+ r'^NOTRY=true$', new_description, re.M | re.I):
new_description += '\nNOTRY=true'
results.append(
output_api.PresubmitNotifyResult(
@@ -282,7 +286,7 @@ def PostUploadHook(cl, change, output_api):
# If there is atleast one docs change then add preview link in the CL's
# description if it does not already exist there.
if atleast_one_docs_change and not re.search(
- r'^DOCS_PREVIEW=.*', original_description, re.M | re.I):
+ r'^DOCS_PREVIEW=.*', new_description, re.M | re.I):
# Automatically add a link to where the docs can be previewed.
new_description += '\nDOCS_PREVIEW= %s%s' % (DOCS_PREVIEW_URL, issue)
results.append(
@@ -290,6 +294,28 @@ def PostUploadHook(cl, change, output_api):
'Automatically added a link to preview the docs changes to the '
'CL\'s description'))
+ # If the target ref is not master then add NOTREECHECKS=true and NOTRY=true
+ # to the CL's description if it does not already exist there.
+ target_ref = rietveld_obj.get_issue_properties(issue, False).get(
+ 'target_ref', '')
+ if target_ref != 'refs/heads/master':
+ if not re.search(
+ r'^NOTREECHECKS=true$', new_description, re.M | re.I):
+ new_description += "\nNOTREECHECKS=true"
+ results.append(
+ output_api.PresubmitNotifyResult(
+ 'Branch changes do not need to rely on the master branch\'s '
+ 'tree status. Automatically added \'NOTREECHECKS=true\' to the '
+ 'CL\'s description'))
+ if not re.search(
+ r'^NOTRY=true$', new_description, re.M | re.I):
+ new_description += "\nNOTRY=true"
+ results.append(
+ output_api.PresubmitNotifyResult(
+ 'Trybots do not yet work for non-master branches. '
+ 'Automatically added \'NOTRY=true\' to the CL\'s description'))
+
+
# If the description has changed update it.
if new_description != original_description:
rietveld_obj.update_description(issue, new_description)