Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: sitescripts/hg/bin/update_issues.py

Issue 30048555: Issue 7334 - Remove handling of "Fixes XXXX - ..." commit messages (Closed) Base URL: https://hg.adblockplus.org/sitescripts
Left Patch Set: Created April 18, 2019, 3:48 p.m.
Right Patch Set: Address review comments on PS1 Created May 14, 2019, 10:22 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « sitescripts/hg/README.md ('k') | sitescripts/hg/test/test_update_issues.py » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 # This file is part of Adblock Plus <https://adblockplus.org/>, 1 # This file is part of Adblock Plus <https://adblockplus.org/>,
2 # Copyright (C) 2006-present eyeo GmbH 2 # Copyright (C) 2006-present eyeo GmbH
3 # 3 #
4 # Adblock Plus is free software: you can redistribute it and/or modify 4 # Adblock Plus is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License version 3 as 5 # it under the terms of the GNU General Public License version 3 as
6 # published by the Free Software Foundation. 6 # published by the Free Software Foundation.
7 # 7 #
8 # Adblock Plus is distributed in the hope that it will be useful, 8 # Adblock Plus is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details. 11 # GNU General Public License for more details.
12 # 12 #
13 # You should have received a copy of the GNU General Public License 13 # You should have received a copy of the GNU General Public License
14 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 14 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
15 15
16 """A changegroup (or pretxnchangegroup) hook for Trac integration. 16 """A changegroup (or pretxnchangegroup) hook for Trac integration.
mathias 2019/05/14 09:32:02 Why do you insist on naming the type(s) of hook?
Vasily Kuznetsov 2019/05/14 10:28:59 This is the intended use and I haven't checked if
17 17
18 Checks commit messages for issue references and posts comments linking to the 18 Checks commit messages for issue references and posts comments linking to the
19 commits into referenced issues. 19 commits into referenced issues.
20 """ 20 """
21 21
22 import collections 22 import collections
23 import posixpath 23 import posixpath
24 import re 24 import re
25 import xmlrpclib 25 import xmlrpclib
26 26
27 from sitescripts.utils import get_config, get_template 27 from sitescripts.utils import get_config, get_template
28 28
29 29
30 ISSUE_NUMBER_REGEX = re.compile(r'\bissue\s+(\d+)\b', re.I) 30 ISSUE_NUMBER_REGEX = re.compile(r'\bissue\s+(\d+)\b', re.I)
mathias 2019/05/13 12:23:43 Shouldn't this one include the separating dash? I.
Vasily Kuznetsov 2019/05/13 15:14:15 Yeah I see what you mean, but I'd rather leave it
mathias 2019/05/14 09:32:01 Acknowledged.
31 NOISSUE_REGEX = re.compile(r'^noissue\b', re.I) 31 NOISSUE_REGEX = re.compile(r'^noissue\b', re.I)
32 32
33 33
34 def _format_description(change): 34 def _format_description(change):
35 lines = change.description().splitlines() 35 lines = change.description().splitlines()
36 message = lines[0].rstrip() 36 message = lines[0].rstrip()
37 if len(lines) == 1 or lines[1].strip() == '': 37 if len(lines) == 1 or lines[1].strip() == '':
38 return message 38 return message
39 return message.rstrip('.') + '...' 39 return message.rstrip('.') + '...'
40 40
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 elif not NOISSUE_REGEX.search(description): 83 elif not NOISSUE_REGEX.search(description):
84 ui.warn('warning: invalid commit message format in changeset {}\n' 84 ui.warn('warning: invalid commit message format in changeset {}\n'
85 .format(commit)) 85 .format(commit))
86 86
87 repository_name = posixpath.split(repo.url())[1] 87 repository_name = posixpath.split(repo.url())[1]
88 comments = _generate_comments(repository_name, changes_by_issue) 88 comments = _generate_comments(repository_name, changes_by_issue)
89 89
90 issue_url_template = get_config().get('hg', 'issue_url_template') 90 issue_url_template = get_config().get('hg', 'issue_url_template')
91 for issue_id, comment in comments.items(): 91 for issue_id, comment in comments.items():
92 issue_url = issue_url_template.format(id=issue_id) 92 issue_url = issue_url_template.format(id=issue_id)
93 ui.status('updating {}\n'.format(issue_url))
93 try: 94 try:
94 _post_comment(issue_id, comment) 95 _post_comment(issue_id, comment)
95 ui.status('updating {}\n'.format(issue_url))
mathias 2019/05/14 09:32:02 This should not be in the `try` block. It should e
Vasily Kuznetsov 2019/05/14 10:28:59 Makes sense. Done.
96 except Exception as exc: 96 except Exception as exc:
97 ui.warn('warning: failed to update {}\n'.format(issue_url)) 97 ui.warn('warning: failed to update {}\n'.format(issue_url))
98 ui.warn('error message: {}\n'.format(exc)) 98 ui.warn('error message: {}\n'.format(exc))
99
100 # Alias for smooth migration.
101 changegroup_hook = hook
mathias 2019/05/14 09:32:01 This should not be necessary at all: hg@hg-2:
Vasily Kuznetsov 2019/05/14 10:29:00 👍 Done!
LEFTRIGHT

Powered by Google App Engine
This is Rietveld