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

Side by Side Diff: appengine/chromium_rietveld/codereview/utils.py

Issue 2128173005: Rietveld: don't email on "Dry Run: CQ is trying da patch" (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Fix. 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 unified diff | Download patch
« no previous file with comments | « no previous file | appengine/chromium_rietveld/codereview/views.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2011 Google Inc. 1 # Copyright 2011 Google Inc.
2 # 2 #
3 # Licensed under the Apache License, Version 2.0 (the "License"); 3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License. 4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at 5 # You may obtain a copy of the License at
6 # 6 #
7 # http://www.apache.org/licenses/LICENSE-2.0 7 # http://www.apache.org/licenses/LICENSE-2.0
8 # 8 #
9 # Unless required by applicable law or agreed to in writing, software 9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS, 10 # distributed under the License is distributed on an "AS IS" BASIS,
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 89
90 Args: 90 Args:
91 text: a string. 91 text: a string.
92 92
93 Returns: 93 Returns:
94 A string with all line breaks converted to LF. 94 A string with all line breaks converted to LF.
95 """ 95 """
96 return text.replace('\r\n', '\n').replace('\r', '\n') 96 return text.replace('\r\n', '\n').replace('\r', '\n')
97 97
98 98
99 _CQ_STATUS_REGEX = re.compile( 99 _CQ_STATUS_URL_REGEX = re.compile(
100 '(dry run: )?CQ is trying da patch. Follow status at\s+' 100 '^(dry run: )?CQ is trying da patch.\s+Follow status at\s+'
101 '(https://.+/patch-status/(.+/)?(\d+)/(\d+))\s*', re.I) 101 '(https://.+/patch-status/(.+/)?(\d+)/(\d+))', re.I)
102
103 # This is different from above, because status url is not configured for all
104 # CQs, in which case CQ posts something like:
105 # CQ is trying da patch.
106 # Reference: codereview/xxxx/yyy
107 _CQ_DRY_RUN_START_REGEX = re.compile(
108 '^dry run: CQ is trying da patch.\s+'
109 '(Follow status at|Reference:)', re.I)
110
111 _CQ_DRY_RUN_MESSAGE = re.compile('^dry run', re.I)
102 112
103 113
104 def parse_cq_status_url_message(msg): 114 def parse_cq_status_url_message(msg):
105 """Returns url, issue, patchset parsed from CQ status message. 115 """Returns url, issue, patchset parsed from CQ status message.
106 116
107 If parsing failed, returns None, None, None. 117 If parsing failed, returns None, None, None.
108 """ 118 """
109 # Example of message, Dry Run prefix is optional. 119 # Example of message, Dry Run prefix is optional.
110 # Dry run: CQ is trying da patch. Follow status at 120 # Dry run: CQ is trying da patch. Follow status at
111 # https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.o rg/2131593002/1 121 # https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.o rg/2131593002/1
112 match = _CQ_STATUS_REGEX.match(msg) 122 match = _CQ_STATUS_URL_REGEX.match(msg)
113 if not match: 123 if not match:
114 return None, None, None 124 return None, None, None
115 _, url, _, issue, patchset = match.groups() 125 _, url, _, issue, patchset = match.groups()
116 return url, int(issue), int(patchset) 126 return url, int(issue), int(patchset)
127
128
129 def is_cq_dry_run_start_message(msg):
130 return bool(_CQ_DRY_RUN_START_REGEX.match(msg))
131
132
133 def is_cq_dry_message(msg):
134 return bool(_CQ_DRY_RUN_MESSAGE.match(msg))
OLDNEW
« no previous file with comments | « no previous file | appengine/chromium_rietveld/codereview/views.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698