Skip to content

Instantly share code, notes, and snippets.

@movEAX
Last active December 30, 2015 07:19
Show Gist options
  • Save movEAX/7794950 to your computer and use it in GitHub Desktop.
Save movEAX/7794950 to your computer and use it in GitHub Desktop.
Hg 'commit' hook implementation for auto comment link of changeset to redmine./path/to/project/.hg/hgrc[hooks]commit.autocomment = python:path/to/script.py:comment_to_redmine[redmine]url = https://...key = note = some note https://.../changeset/{rev}
# coding: utf-8
#------------------------------------------------------------------------------
# Imports
#------------------------------------------------------------------------------
# Stdlib
import os
import re
# 3rdparty
from redmine import Redmine
#------------------------------------------------------------------------------
# Mercurial commit callback
#------------------------------------------------------------------------------
def note_to_redmine(ui, repo, node, **kwargs)
redmine_url = ui.config('redmine', 'url')
note_format = ui.config('redmine', 'note')
api_key = ui.config('redmine', 'key')
commit_message = repo[node].description()
issues = re.findall(r'(?<=#)\d+', commit_message)
if os.fork() == 0:
rm = Redmine(redmine_url, key=api_key)
note = note_format.format(rev=node)
for issue_num in issues:
issue = rm.issues[issue_num]
issue.save(note)
@damirazo
Copy link

damirazo commented Dec 5, 2013

Норм чо

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment