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: Remove redundant check for the final period in the first line of the commit message Created May 26, 2016, 7:32 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,34 @@
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().splitlines()
+ message = lines[0].rstrip()
+ if len(lines) == 1 or lines[1].strip() == '':
+ return message
+ return message.rstrip('.') + '...'
+
+
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