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

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

Issue 2123093009: Rietveld: add CQ status URL instead of comment. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Created 4 years, 5 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 | « appengine/chromium_rietveld/codereview/models.py ('k') | appengine/chromium_rietveld/codereview/views.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/chromium_rietveld/codereview/utils.py
diff --git a/appengine/chromium_rietveld/codereview/utils.py b/appengine/chromium_rietveld/codereview/utils.py
index 7f1b36943428e8cf53d368a093ce2624a62773a5..1d3ae98b3c67585010c3bc5fb1e0eb4825c97600 100644
--- a/appengine/chromium_rietveld/codereview/utils.py
+++ b/appengine/chromium_rietveld/codereview/utils.py
@@ -14,6 +14,7 @@
"""Collection of helper functions."""
+import re
import urlparse
from google.appengine.ext import db
@@ -93,3 +94,23 @@ def unify_linebreaks(text):
A string with all line breaks converted to LF.
"""
return text.replace('\r\n', '\n').replace('\r', '\n')
+
+
+_CQ_STATUS_REGEX = re.compile(
+ '(dry run: )?CQ is trying da patch. Follow status at\s+'
+ '(https://.+/patch-status/(.+/)?(\d+)/(\d+))\s*', re.I)
+
+
+def parse_cq_status_url_message(msg):
+ """Returns url, issue, patchset parsed from CQ status message.
+
+ If parsing failed, returns None, None, None.
+ """
+ # Example of message, Dry Run prefix is optional.
+ # Dry run: CQ is trying da patch. Follow status at
+ # https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2131593002/1
+ match = _CQ_STATUS_REGEX.match(msg)
+ if not match:
+ return None, None, None
+ _, url, _, issue, patchset = match.groups()
+ return url, int(issue), int(patchset)
« no previous file with comments | « appengine/chromium_rietveld/codereview/models.py ('k') | appengine/chromium_rietveld/codereview/views.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698