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: Remove redundant check for the final period in the first line of the commit message Created May 26, 2016, 7:32 p.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 return message.rstrip('.') + '...'
77
78
71 def _post_comments(ui, repo, config, refs): 79 def _post_comments(ui, repo, config, refs):
72 repo_name = posixpath.split(repo.url())[1] 80 repo_name = posixpath.split(repo.url())[1]
73 template = get_template('hg/template/issue_commit_comment.tmpl', 81 template = get_template('hg/template/issue_commit_comment.tmpl',
74 autoescape=False) 82 autoescape=False)
75 for ref in refs: 83 for ref in refs:
76 comment_text = template.render({'repository_name': repo_name, 84 comment_text = template.render({
77 'changes': ref.commits}) 85 'repository_name': repo_name,
86 'changes': ref.commits,
87 'format_description': _format_description
88 })
78 with _trac_proxy(ui, config, 'getting issue {}'.format(ref.id)) as tp: 89 with _trac_proxy(ui, config, 'getting issue {}'.format(ref.id)) as tp:
79 attrs = tp.ticket.get(ref.id)[3] 90 attrs = tp.ticket.get(ref.id)[3]
80 changes = {'_ts': attrs['_ts'], 'action': 'leave'} 91 changes = {'_ts': attrs['_ts'], 'action': 'leave'}
81 _update_issue(ui, config, ref.id, changes, comment_text) 92 _update_issue(ui, config, ref.id, changes, comment_text)
82 93
83 94
84 def _compile_module_regexps(ui, config, modules): 95 def _compile_module_regexps(ui, config, modules):
85 for module, regexp in config.items('hg_module_milestones'): 96 for module, regexp in config.items('hg_module_milestones'):
86 try: 97 try:
87 yield module, re.compile('^{}$'.format(regexp), re.I) 98 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], 203 added_revs = repo.changelog.findmissingrevs([old_master_rev],
193 [new_master_rev]) 204 [new_master_rev])
194 added_commits = [repo[rev] for rev in added_revs] 205 added_commits = [repo[rev] for rev in added_revs]
195 refs = [ref for ref in _collect_references(ui, added_commits) 206 refs = [ref for ref in _collect_references(ui, added_commits)
196 if ref.is_fixed] 207 if ref.is_fixed]
197 _declare_fixed(ui, config, refs) 208 _declare_fixed(ui, config, refs)
198 209
199 210
200 # Alias for backward compatibility. 211 # Alias for backward compatibility.
201 hook = changegroup_hook 212 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