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

Unified Diff: appengine/chromium_rietveld/codereview/views.py

Issue 806373005: Allow target_ref to be modified by subsequent patchsets with logging (Closed) Base URL: https://chromium.googlesource.com/infra/infra@master
Patch Set: Cleanup II Created 6 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/chromium_rietveld/codereview/views.py
diff --git a/appengine/chromium_rietveld/codereview/views.py b/appengine/chromium_rietveld/codereview/views.py
index cd2cc504a28a45d4a9db4c9bf2348999a97f0895..7329215a25d5cc064cdb46450e6c1c7dcd302cde 100644
--- a/appengine/chromium_rietveld/codereview/views.py
+++ b/appengine/chromium_rietveld/codereview/views.py
@@ -1336,6 +1336,21 @@ def upload_complete(request, patchset_id=None):
return HttpTextResponse('OK')
+def _get_target_ref(form, issue_key, project):
+ target_ref = form.cleaned_data.get('target_ref', None)
+ # The following is a hack to ensure that all target_refs for chromium and v8
+ # start with 'refs/pending/'. More context here:
+ # https://code.google.com/p/chromium/issues/detail?id=435702#c10
+ # TODO(rmistry): Remove the below hack when the logged warning stops showing
+ # up.
+ if (target_ref and not target_ref.startswith('refs/pending/') and
+ project in ('chromium', 'v8')):
+ target_ref = target_ref.replace('refs/', 'refs/pending/')
+ logging.warn('Issue %d for %s did not start with refs/pending/',
agable 2014/12/19 17:52:56 nit: "Target ref %s for issue %d in project %s did
+ issue_key.id(), project)
+ return target_ref
+
+
def _make_new(request, form):
"""Creates new issue and fill relevant fields from given form data.
@@ -1371,17 +1386,7 @@ def _make_new(request, form):
issue_key = ndb.Key(models.Issue, first_issue_id)
project = form.cleaned_data['project']
- target_ref = form.cleaned_data.get('target_ref', None)
- # The following is a hack to ensure that all target_refs for chromium and v8
- # start with 'refs/pending/'. More context here:
- # https://code.google.com/p/chromium/issues/detail?id=435702#c10
- # TODO(rmistry): Remove the below hack when the logged warning stops showing
- # up.
- if (target_ref and not target_ref.startswith('refs/pending/') and
- project in ('chromium', 'v8')):
- target_ref = target_ref.replace('refs/', 'refs/pending/')
- logging.warn('Issue %d for %s did not start with refs/pending/',
- issue_key.id(), project)
+ target_ref = _get_target_ref(form, issue_key, project)
issue = models.Issue(subject=form.cleaned_data['subject'],
description=form.cleaned_data['description'],
@@ -1527,8 +1532,12 @@ def _add_patchset_from_form(request, issue, form, message_key='message',
issue.reviewers, issue.required_reviewers = _get_emails(form, 'reviewers')
issue.cc, _ = _get_emails(form, 'cc')
issue.commit = False
+ issue.target_ref = _get_target_ref(form, issue.key, issue.project)
issue.calculate_updates_for()
issue.put()
+ # Log for auditing purposes.
+ logging.info("Patchset id %s for issue %s has target_ref %s",
+ patchset.key.id(), issue.key.id(), issue.target_ref)
if form.cleaned_data.get('send_mail'):
msg = make_message(request, issue, message, '', True)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698