From b6a5dd41322a20b7e97c74b2f888c66e6cefd0a0 Mon Sep 17 00:00:00 2001 From: Antonin Kral Date: Thu, 16 Sep 2010 12:41:22 +0400 Subject: [PATCH] introduced new configuration option 'chengelogcmd' to be able to ommit list of changed files from the log message --- __init__.py | 1 + etc/gitzillarc | 6 ++++++ hooks.py | 12 ++++++++---- hookscripts.py | 2 ++ utils.py | 4 ++-- 5 files changed, 19 insertions(+), 6 deletions(-) diff --git a/__init__.py b/__init__.py index b89ecd3..85721bb 100644 --- a/__init__.py +++ b/__init__.py @@ -28,6 +28,7 @@ explicit or implied, to the extent permissible by law. This program might, and would be buggy. Use it at your own risk. """ +sDefaultChangeLogCommand = "whatchanged" sDefaultSeparator = "~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~." sDefaultFormatSpec = """ diff --git a/etc/gitzillarc b/etc/gitzillarc index 38b3076..6e4cf16 100644 --- a/etc/gitzillarc +++ b/etc/gitzillarc @@ -73,6 +73,12 @@ # appended to '--format=format:' in 'git whatchanged'. See the # 'git whatchanged' manpage for more info. # +# * changelogcmd +# default: whatchanged +# +# command which will be used for getting changelog from git +# another reasonable value is 'log' +# # * separator # # default: ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~. diff --git a/hooks.py b/hooks.py index 7eb382c..912da67 100644 --- a/hooks.py +++ b/hooks.py @@ -7,12 +7,12 @@ hooks - git hooks provided by gitzilla. import re import sys from utils import get_changes, init_bugzilla, get_bug_status, notify_and_exit -from gitzilla import sDefaultSeparator, sDefaultFormatSpec, oDefaultBugRegex +from gitzilla import sDefaultSeparator, sDefaultFormatSpec, sDefaultChangeLogCommand, oDefaultBugRegex from gitzilla import NullLogger import traceback -def post_receive(sBZUrl, sBZUser=None, sBZPasswd=None, sFormatSpec=None, oBugRegex=None, sSeparator=None, logger=None, bz_init=None): +def post_receive(sBZUrl, sBZUser=None, sBZPasswd=None, sFormatSpec=None, sChangeLogCommand=None, oBugRegex=None, sSeparator=None, logger=None, bz_init=None): """ a post-recieve hook handler which extracts bug ids and adds the commit info to the comment. If multiple bug ids are found, the comment is added @@ -55,6 +55,9 @@ def post_receive(sBZUrl, sBZUser=None, sBZPasswd=None, sFormatSpec=None, oBugReg if sFormatSpec is None: sFormatSpec = sDefaultFormatSpec + if sChangeLogCommand is None: + sChangeLogCommand = sDefaultChangeLogCommand + if sSeparator is None: sSeparator = sDefaultSeparator @@ -75,7 +78,7 @@ def post_receive(sBZUrl, sBZUser=None, sBZPasswd=None, sFormatSpec=None, oBugReg if sPrevRev is None: sPrevRev = sOldRev logger.debug("oldrev: '%s', newrev: '%s'" % (sOldRev, sNewRev)) - asChangeLogs = get_changes(sOldRev, sNewRev, sFormatSpec, sSeparator) + asChangeLogs = get_changes(sOldRev, sNewRev, sFormatSpec, sSeparator, sChangeLogCommand) for sMessage in asChangeLogs: logger.debug("Considering commit:\n%s" % (sMessage,)) @@ -144,6 +147,7 @@ def update(oBugRegex=None, asAllowedStatuses=None, sSeparator=None, sBZUrl=None, bz_init = init_bugzilla sFormatSpec = sDefaultFormatSpec + sChangeLogCommand = sDefaultChangeLogCommand if asAllowedStatuses is not None: # sanity checking @@ -162,7 +166,7 @@ def update(oBugRegex=None, asAllowedStatuses=None, sSeparator=None, sBZUrl=None, (sOldRev, sNewRev) = sys.argv[2:4] logger.debug("oldrev: '%s', newrev: '%s'" % (sOldRev, sNewRev)) - asChangeLogs = get_changes(sOldRev, sNewRev, sFormatSpec, sSeparator) + asChangeLogs = get_changes(sOldRev, sNewRev, sFormatSpec, sSeparator, sChangeLogCommand) for sMessage in asChangeLogs: logger.debug("Checking for bug refs in commit:\n%s" % (sMessage,)) diff --git a/hookscripts.py b/hookscripts.py index b50dae0..fdaeb72 100644 --- a/hookscripts.py +++ b/hookscripts.py @@ -146,10 +146,12 @@ def post_receive(): oBugRegex = get_bug_regex(siteconfig) sSeparator = get_or_default(siteconfig, sRepo, "separator") sFormatSpec = get_or_default(siteconfig, sRepo, "formatspec") + sChangeLogCommand = get_or_default(siteconfig, sRepo, "changelogcmd") bz_init = make_bz_init(siteconfig, bAllowDefaultAuth) gitzilla.hooks.post_receive(sBZUrl, sBZUser, sBZPasswd, sFormatSpec, + sChangeLogCommand, oBugRegex, sSeparator, logger, bz_init) diff --git a/utils.py b/utils.py index b5af709..1443f1b 100644 --- a/utils.py +++ b/utils.py @@ -51,7 +51,7 @@ def init_bugzilla(sBZUrl, sBZUser, sBZPasswd): -def get_changes(sOldRev, sNewRev, sFormatSpec, sSeparator): +def get_changes(sOldRev, sNewRev, sFormatSpec, sSeparator, sChangeLogCommand): """ returns an array of chronological changes, between sOldRev and sNewRev, according to the format spec sFormatSpec. @@ -63,7 +63,7 @@ def get_changes(sOldRev, sNewRev, sFormatSpec, sSeparator): else: sCommitRange = "%s..%s" % (sOldRev, sNewRev) - sChangeLog = execute(["git", "whatchanged", + sChangeLog = execute(["git", "%s" % (sChangeLogCommand), "--format=format:%s%s" % (sSeparator, sFormatSpec), sCommitRange]) asChangeLogs = sChangeLog.split(sSeparator)