Last active
December 30, 2015 07:19
-
-
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}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Норм чо