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

Side by Side Diff: sitescripts/hg/bin/update_issues.py

Issue 29344546: Issue 4070 - Correctly handle multiline commit messages in the mercurial hook (Closed)
Patch Set: Handle CRLF line breaks and whitespace in the second line Created May 26, 2016, 9:22 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | sitescripts/hg/template/issue_commit_comment.tmpl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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-2016 Eyeo GmbH 2 # Copyright (C) 2006-2016 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
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 if changes['action'] == 'resolve': 61 if changes['action'] == 'resolve':
62 updates.append(' - closed') 62 updates.append(' - closed')
63 if not updates: 63 if not updates:
64 return 64 return
65 65
66 with _trac_proxy(ui, config, 'updating issue {}'.format(issue_id)) as tp: 66 with _trac_proxy(ui, config, 'updating issue {}'.format(issue_id)) as tp:
67 tp.ticket.update(issue_id, comment, changes, True) 67 tp.ticket.update(issue_id, comment, changes, True)
68 ui.status('updated {}:\n{}\n'.format(issue_url, '\n'.join(updates))) 68 ui.status('updated {}:\n{}\n'.format(issue_url, '\n'.join(updates)))
69 69
70 70
71 def _format_description(change):
72 lines = change.description().splitlines()
73 message = lines[0].rstrip()
74 if len(lines) == 1 or lines[1].strip() == '':
75 return message
76 if message.endswith('.'):
Sebastian Noack 2016/05/26 10:44:07 This check seems redundant.
Vasily Kuznetsov 2016/05/26 19:34:00 Indeed. Done.
77 message = message.rstrip('.')
78 return message + '...'
79
80
71 def _post_comments(ui, repo, config, refs): 81 def _post_comments(ui, repo, config, refs):
72 repo_name = posixpath.split(repo.url())[1] 82 repo_name = posixpath.split(repo.url())[1]
73 template = get_template('hg/template/issue_commit_comment.tmpl', 83 template = get_template('hg/template/issue_commit_comment.tmpl',
74 autoescape=False) 84 autoescape=False)
75 for ref in refs: 85 for ref in refs:
76 comment_text = template.render({'repository_name': repo_name, 86 comment_text = template.render({
77 'changes': ref.commits}) 87 'repository_name': repo_name,
88 'changes': ref.commits,
89 'format_description': _format_description
90 })
78 with _trac_proxy(ui, config, 'getting issue {}'.format(ref.id)) as tp: 91 with _trac_proxy(ui, config, 'getting issue {}'.format(ref.id)) as tp:
79 attrs = tp.ticket.get(ref.id)[3] 92 attrs = tp.ticket.get(ref.id)[3]
80 changes = {'_ts': attrs['_ts'], 'action': 'leave'} 93 changes = {'_ts': attrs['_ts'], 'action': 'leave'}
81 _update_issue(ui, config, ref.id, changes, comment_text) 94 _update_issue(ui, config, ref.id, changes, comment_text)
82 95
83 96
84 def _compile_module_regexps(ui, config, modules): 97 def _compile_module_regexps(ui, config, modules):
85 for module, regexp in config.items('hg_module_milestones'): 98 for module, regexp in config.items('hg_module_milestones'):
86 try: 99 try:
87 yield module, re.compile('^{}$'.format(regexp), re.I) 100 yield module, re.compile('^{}$'.format(regexp), re.I)
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 added_revs = repo.changelog.findmissingrevs([old_master_rev], 205 added_revs = repo.changelog.findmissingrevs([old_master_rev],
193 [new_master_rev]) 206 [new_master_rev])
194 added_commits = [repo[rev] for rev in added_revs] 207 added_commits = [repo[rev] for rev in added_revs]
195 refs = [ref for ref in _collect_references(ui, added_commits) 208 refs = [ref for ref in _collect_references(ui, added_commits)
196 if ref.is_fixed] 209 if ref.is_fixed]
197 _declare_fixed(ui, config, refs) 210 _declare_fixed(ui, config, refs)
198 211
199 212
200 # Alias for backward compatibility. 213 # Alias for backward compatibility.
201 hook = changegroup_hook 214 hook = changegroup_hook
OLDNEW
« no previous file with comments | « no previous file | sitescripts/hg/template/issue_commit_comment.tmpl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld