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

Unified Diff: sitescripts/hg/bin/update_issues.py

Issue 29344546: Issue 4070 - Correctly handle multiline commit messages in the mercurial hook (Closed)
Patch Set: Created May 25, 2016, 5:13 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | sitescripts/hg/template/issue_commit_comment.tmpl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sitescripts/hg/bin/update_issues.py
===================================================================
--- a/sitescripts/hg/bin/update_issues.py
+++ b/sitescripts/hg/bin/update_issues.py
@@ -63,23 +63,36 @@
if not updates:
return
with _trac_proxy(ui, config, 'updating issue {}'.format(issue_id)) as tp:
tp.ticket.update(issue_id, comment, changes, True)
ui.status('updated {}:\n{}\n'.format(issue_url, '\n'.join(updates)))
+def _format_description(change):
+ lines = change.description().split('\n')
kzar 2016/05/25 18:40:18 Is it possible for people to use DOS style CR+LF n
Vasily Kuznetsov 2016/05/26 09:23:17 Not sure, but better safe then sorry. Done
+ message = lines[0].rstrip()
+ if len(lines) == 1 or lines[1] == '':
+ return message
+ if message.endswith('.'):
kzar 2016/05/25 18:40:18 IMHO if the first line ends with a "." then we sho
kzar 2016/05/26 08:14:10 (We discussed this in IRC, I didn't realise that t
Vasily Kuznetsov 2016/05/26 09:23:17 Acknowledged.
+ message = message.rstrip('.')
+ return message + '...'
+
+
def _post_comments(ui, repo, config, refs):
repo_name = posixpath.split(repo.url())[1]
template = get_template('hg/template/issue_commit_comment.tmpl',
autoescape=False)
for ref in refs:
- comment_text = template.render({'repository_name': repo_name,
- 'changes': ref.commits})
+ comment_text = template.render({
+ 'repository_name': repo_name,
+ 'changes': ref.commits,
+ 'format_description': _format_description
+ })
with _trac_proxy(ui, config, 'getting issue {}'.format(ref.id)) as tp:
attrs = tp.ticket.get(ref.id)[3]
changes = {'_ts': attrs['_ts'], 'action': 'leave'}
_update_issue(ui, config, ref.id, changes, comment_text)
def _compile_module_regexps(ui, config, modules):
for module, regexp in config.items('hg_module_milestones'):
« 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