From 6aa75f775f8530eea40cbe7bd228115dd7cc1ecd Mon Sep 17 00:00:00 2001 From: Miklos Espak Date: Sun, 11 Sep 2011 15:23:02 +0200 Subject: [PATCH 1/3] Package name fixed. --- extensions/Gitzilla/Config.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/Gitzilla/Config.pm b/extensions/Gitzilla/Config.pm index c25f65e..f369e29 100644 --- a/extensions/Gitzilla/Config.pm +++ b/extensions/Gitzilla/Config.pm @@ -1,4 +1,4 @@ -package Bugzilla::Extension::Striiv; +package Bugzilla::Extension::Gitzilla; use strict; use constant NAME => 'Gitzilla'; From aef251e57a387fa83ad3bfbeb18fd14fa2be0349 Mon Sep 17 00:00:00 2001 From: Miklos Espak Date: Sun, 11 Sep 2011 18:43:43 +0200 Subject: [PATCH 2/3] Fixes for replacing commits by links --- etc/gitzillarc | 31 ++++++++++++++++++++++++++++--- extensions/Gitzilla/Extension.pm | 14 ++++++++++---- 2 files changed, 38 insertions(+), 7 deletions(-) diff --git a/etc/gitzillarc b/etc/gitzillarc index 591ab3a..6439353 100644 --- a/etc/gitzillarc +++ b/etc/gitzillarc @@ -5,6 +5,9 @@ # [Section_Name] # item: value # another_item: value2 +# third_item: +# line 1 +# line 2 # @@ -81,6 +84,18 @@ # 'git whatchanged' manpage for more info. Newlines are automatically # converted to '%n'. # +# If you want to replace the commits by links your GitWeb site, +# then enable the Bugzilla extension and use a formatspec like this: +# +# formatspec: +# MyProject.git commit %H +# MyProject.git parents %P +# Author %aN (%aE) +# ... +# +# The repository name will not appear in the output, it is only needed +# by the extension to create the link. +# # * include_diffstat # # default: True @@ -111,12 +126,12 @@ # - Bug #123 # # * git_ref_prefix -# +# # the string which must start a git reference for its commits to be # processed. Defaults to 'refs/heads/' so that we don't process 'tags/' and # run the risk of processing many commits multiple times. You can set it # to the empty string to process all git references. -# +# # * logfile # # the file to log to. Must be writable by the uid of the git @@ -143,4 +158,14 @@ # bugzilla_password: barbarblah # allowed_bug_states: NEW, ASSIGNED, REOPENED # user_config: deny - +# formatspec: +# commit %H +# parents %P +# Author %aN (%aE) +# Date %aD +# Commit By %cN (%cE) +# Commit Date %cD +# %n +# %s +# %n +# %b diff --git a/extensions/Gitzilla/Extension.pm b/extensions/Gitzilla/Extension.pm index 1dccc98..7b3de29 100644 --- a/extensions/Gitzilla/Extension.pm +++ b/extensions/Gitzilla/Extension.pm @@ -8,22 +8,28 @@ use Data::Dumper; our $VERSION = '1.0'; -#this relies on using a formatspec in /etc/gitzillarc like this (replace tmp.git appropriately): -#formatspec: tmp.git commit %H%d%n%aE%n%s%n%n%b +# this relies on using a formatspec in /etc/gitzillarc like this +# (replace MyProject.git appropriately): +# +# formatspec: +# MyProject.git commit %H +# MyProject.git parents %P +# Author %aN (%aE) +# ... sub bug_format_comment { my ($self, $args) = @_; my $regexes = $args->{'regexes'}; - my $commit_match = qr/\b((\S+\.git)\s+(?:commit|parents)\b\s+([0-9a-fA-F]{7,40}))/; + my $commit_match = qr/\b((\S+\.git)\s+((?:commit|parents)\b\s+)([0-9a-fA-F]{7,40}))/; push(@$regexes, { match => $commit_match, replace => \&_replace_commit }); } sub _replace_commit { my $args = shift; my $matches = $args->{matches}; - return qq{$matches->[0]}; + return qq{$matches->[2]$matches->[3]}; } __PACKAGE__->NAME; From ca13202791d0f622f0d4cc5dbb11f760e553d07e Mon Sep 17 00:00:00 2001 From: Miklos Espak Date: Sun, 11 Sep 2011 23:07:55 +0200 Subject: [PATCH 3/3] Support for tree hashes. Format string improvements. --- __init__.py | 2 +- etc/gitzillarc | 36 +++++++++++++++++++------------- extensions/Gitzilla/Extension.pm | 11 +--------- extensions/Gitzilla/README | 15 +++++++++---- 4 files changed, 34 insertions(+), 30 deletions(-) diff --git a/__init__.py b/__init__.py index abaecea..ad51eef 100644 --- a/__init__.py +++ b/__init__.py @@ -34,7 +34,7 @@ sDefaultFormatSpec = """ commit %H -parents %P +parent %P Author %aN (%aE) Date %aD Commit By %cN (%cE) diff --git a/etc/gitzillarc b/etc/gitzillarc index 6439353..22fceac 100644 --- a/etc/gitzillarc +++ b/etc/gitzillarc @@ -68,7 +68,7 @@ # default: True # # whether the update hook should allow commits which do not contain -# a bug number. True or false. +# a bug number. True or False. # # * allowed_bug_states # @@ -78,30 +78,36 @@ # # * formatspec # -# default: commit %H%nparents %P%nAuthor %aN (%aE)%nDate %aD%nCommit By %cN (%cE)%nCommit Date %cD%n%n%s%n%n%b%n +# default: commit %H%nparent %P%nAuthor %aN (%aE)%nDate %aD%nCommit By %cN (%cE)%nCommit Date %cD%n%n%s%n%n%b%n # -# appended to '--format=format:' in 'git whatchanged'. See the -# 'git whatchanged' manpage for more info. Newlines are automatically -# converted to '%n'. +# appended to '--format=format:' in 'git whatchanged' or 'git log'. +# See the 'git-whatchanged' manpage for more info. Newlines are +# automatically converted to '%n'. # -# If you want to replace the commits by links your GitWeb site, -# then enable the Bugzilla extension and use a formatspec like this: +# If you want to replace the commits hashes by links to your GitWeb site, +# then enable the Bugzilla extension and put the project name +# before the "commit", "parent" or "tree" words, like in the example +# below. The extension will remove the project name from the output +# while resolving the links. # # formatspec: +# author %aN <%aE>%n %aD +# committer %cN <%cE>%n %cD # MyProject.git commit %H -# MyProject.git parents %P -# Author %aN (%aE) -# ... -# -# The repository name will not appear in the output, it is only needed -# by the extension to create the link. +# MyProject.git parent %P +# MyProject.git tree %T +# %n +# %s +# %n +# %b # # * include_diffstat # # default: True # # include the diffstat (a list of changed files with a histogram). -# If False, the diffstat is not included. True or False. +# If False, the diffstat is not included. In this case 'git log' +# is used in favour of 'git whatchanged'. True or False. # # * separator # @@ -160,7 +166,7 @@ # user_config: deny # formatspec: # commit %H -# parents %P +# parent %P # Author %aN (%aE) # Date %aD # Commit By %cN (%cE) diff --git a/extensions/Gitzilla/Extension.pm b/extensions/Gitzilla/Extension.pm index 7b3de29..f9d21ad 100644 --- a/extensions/Gitzilla/Extension.pm +++ b/extensions/Gitzilla/Extension.pm @@ -8,21 +8,12 @@ use Data::Dumper; our $VERSION = '1.0'; -# this relies on using a formatspec in /etc/gitzillarc like this -# (replace MyProject.git appropriately): -# -# formatspec: -# MyProject.git commit %H -# MyProject.git parents %P -# Author %aN (%aE) -# ... - sub bug_format_comment { my ($self, $args) = @_; my $regexes = $args->{'regexes'}; - my $commit_match = qr/\b((\S+\.git)\s+((?:commit|parents)\b\s+)([0-9a-fA-F]{7,40}))/; + my $commit_match = qr/\b((\S+\.git)\s+((?:commit|parent|tree)\b\s+)([0-9a-fA-F]{7,40}))/; push(@$regexes, { match => $commit_match, replace => \&_replace_commit }); } diff --git a/extensions/Gitzilla/README b/extensions/Gitzilla/README index ca43ef8..b940052 100644 --- a/extensions/Gitzilla/README +++ b/extensions/Gitzilla/README @@ -1,6 +1,13 @@ -Move this dir into the bugzilla/extensions/ dir +Move this directory into the bugzilla/extensions/ directory. -edit /etc/gitzillarc to have a formatspec like this (replace tmp.git appropriately): -formatspec: tmp.git commit %H%d%n%aE%n%s%n%n%b +Edit /etc/gitzillarc to have a formatspec like this (replace +MyProject.git appropriately): -edit Extension.pm - change "www.example.com" to your gitweb url +formatspec: + ... + MyProject.git commit %H + MyProject.git parent %P + MyProject.git tree %T + ... + +Edit Extension.pm - change "www.example.com" to your gitweb url