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

Unified Diff: presubmit_canned_checks.py

Issue 11348122: Add presubmit check to verify issue is not closed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 8 years 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 | « no previous file | tests/presubmit_unittest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: presubmit_canned_checks.py
diff --git a/presubmit_canned_checks.py b/presubmit_canned_checks.py
index af88a39b1e8b35099655b3ac1688edfb33c6171e..e6384fa0c47624bc75f7dec4de6aca9b28a5ce97 100644
--- a/presubmit_canned_checks.py
+++ b/presubmit_canned_checks.py
@@ -791,17 +791,40 @@ def CheckOwners(input_api, output_api, source_file_filter=None):
return []
+def _GetRietveldIssueProps(input_api, messages):
+ """Gets the issue properties from rietveld."""
+ issue = input_api.change.issue
+ if issue and input_api.rietveld:
+ return input_api.rietveld.get_issue_properties(
+ issue=int(issue), messages=messages)
+
+
+def CheckIssueNotClosed(input_api, output_api):
+ """Verifies issue is not closed.
+
+ We should not be working with a closed review. CQ and dcommit set this bit,
+ so it is a pretty good indicator of whether an issue has been committed.
+ """
+ issue_props = _GetRietveldIssueProps(input_api=input_api, messages=False)
+ if issue_props and issue_props['closed']:
+ return [output_api.PresubmitError(
+ 'Issue %s is closed. If this issue was already used for a commit,\n'
+ 'please reset the issue number associated with this branch with:\n'
+ 'git cl issue 0\n' % issue_props['issue']
+ )]
+ return []
+
+
def _RietveldOwnerAndReviewers(input_api, email_regexp, approval_needed=False):
"""Return the owner and reviewers of a change, if any.
If approval_needed is True, only reviewers who have approved the change
will be returned.
"""
- if not input_api.change.issue:
+ issue_props = _GetRietveldIssueProps(input_api, True)
+ if not issue_props:
return None, None
- issue_props = input_api.rietveld.get_issue_properties(
- int(input_api.change.issue), True)
if not approval_needed:
return issue_props['owner_email'], set(issue_props['reviewers'])
@@ -940,6 +963,10 @@ def PanProjectChecks(input_api, output_api,
results.extend(input_api.canned_checks.CheckOwners(
input_api, output_api, source_file_filter=None))
+ snapshot("checking review not closed")
+ results.extend(input_api.canned_checks.CheckIssueNotClosed(
+ input_api, output_api))
+
snapshot("checking long lines")
results.extend(input_api.canned_checks.CheckLongLines(
input_api, output_api, source_file_filter=sources))
« no previous file with comments | « no previous file | tests/presubmit_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698