git://git.exim.org
/
git-perl-utils.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
ab0b3dc
)
Attempt to fix failing issue on update
author
Nigel Metheringham
<nigel@exim.org>
Sat, 30 May 2015 09:08:52 +0000
(10:08 +0100)
committer
Nigel Metheringham
<nigel@exim.org>
Sat, 30 May 2015 09:08:52 +0000
(10:08 +0100)
script/git-to-bugzilla.pl
patch
|
blob
|
history
diff --git
a/script/git-to-bugzilla.pl
b/script/git-to-bugzilla.pl
index 9fbddbac8659f5ff50a0122d22a6ab34f42ca1ab..c073b11d6c2925db0d5463a48bfdf32a8b25fd88 100755
(executable)
--- a/
script/git-to-bugzilla.pl
+++ b/
script/git-to-bugzilla.pl
@@
-5,11
+5,12
@@
use strict;
use warnings;
use Carp;
use Config::Any;
use warnings;
use Carp;
use Config::Any;
-use Data::
Dump
;
+use Data::
Printer
;
use File::Slurp;
use FindBin;
use Getopt::Long;
use Git::Repository;
use File::Slurp;
use FindBin;
use Getopt::Long;
use Git::Repository;
+use Try::Tiny;
use lib "$FindBin::Bin/../lib";
use WWW::Bugzilla;
use lib "$FindBin::Bin/../lib";
use WWW::Bugzilla;
@@
-29,13
+30,18
@@
sub update_bugzilla {
password => $cfg->{bugzilla}{pass},
bug_number => $set->{bug}
) || croak "Cannot open bz - $!";
password => $cfg->{bugzilla}{pass},
bug_number => $set->{bug}
) || croak "Cannot open bz - $!";
+ p $bz if ($debug);
- my $header = sprintf( "Git commit: %s/commitdiff/%s\n", $cfg->{gitweb}, $info->{rev} );
+ my $header =
+ sprintf( "Git commit: %s/commitdiff/%s\n", $cfg->{gitweb}, $info->{rev} );
if ( scalar( @{ $info->{diff} } ) > 50 ) {
# big diff - we skip the diff
$bz->additional_comments(
if ( scalar( @{ $info->{diff} } ) > 50 ) {
# big diff - we skip the diff
$bz->additional_comments(
- join( "\n", $header, @{ $info->{info} }, '', @{ $info->{log} }, '----', @{ $info->{diffstat} } ) );
+ join( "\n",
+ $header, @{ $info->{info} }, '',
+ @{ $info->{log} }, '----', @{ $info->{diffstat} } )
+ );
}
else {
}
else {
@@
-45,10
+51,12
@@
sub update_bugzilla {
$bz->change_status("fixed") if ( $set->{action} =~ /fixes/ );
$bz->change_status("closed") if ( $set->{action} =~ /closes/ );
$bz->change_status("fixed") if ( $set->{action} =~ /fixes/ );
$bz->change_status("closed") if ( $set->{action} =~ /closes/ );
+ p $bz if ($debug);
-
$bz->commit
;
+
try { $bz->commit; } catch { warn "Error from bugzilla commit - $_"; }
;
- printf( "[%d] %s %s [%s]\n", $set->{bug}, $info->{rev}, $info->{log}[0], $set->{action} );
+ printf( "[%d] %s %s [%s]\n",
+ $set->{bug}, $info->{rev}, $info->{log}[0], $set->{action} );
}
# ------------------------------------------------------------------------
}
# ------------------------------------------------------------------------
@@
-61,7
+69,9
@@
sub find_bugzilla_references {
my $bugid;
foreach my $line ( @{ $info->{log} } ) {
$line = lc($line);
my $bugid;
foreach my $line ( @{ $info->{log} } ) {
$line = lc($line);
- if ( $line =~ /(closes|fixes|references):?\s*(?:bug(?:zilla)?)?\s*\#?(\d+)/ ) {
+ if ( $line =~
+ /(closes|fixes|references):?\s*(?:bug(?:zilla)?)?\s*\#?(\d+)/ )
+ {
$action = $1;
$bugid = $2;
}
$action = $1;
$bugid = $2;
}
@@
-87,7
+97,9
@@
sub git_commit_info {
my $git = shift;
my $rev = shift;
my $git = shift;
my $rev = shift;
- my @lines = $git->run( 'show', '-M', '-C', '--patch-with-stat', '--pretty=fuller', $rev );
+ my @lines =
+ $git->run( 'show', '-M', '-C', '--patch-with-stat', '--pretty=fuller',
+ $rev );
my $info = {
rev => $rev,
my $info = {
rev => $rev,
@@
-130,7
+142,8
@@
sub walk_git_commits {
return if ( $lastrev eq $headrev );
return if ( $lastrev eq $headrev );
- my @revs = $git->run( 'rev-list', '--topo-order', '--no-merges', ( $lastrev . '..' . $headrev ) );
+ my @revs = $git->run( 'rev-list', '--topo-order', '--no-merges',
+ ( $lastrev . '..' . $headrev ) );
foreach my $rev ( reverse(@revs) ) {
my $info = git_commit_info( $git, $rev );
foreach my $rev ( reverse(@revs) ) {
my $info = git_commit_info( $git, $rev );
@@
-157,16
+170,24
@@
sub walk_git_commits {
'verbose!' => \$verbose,
) or die "Incorrect options";
die "No config file given\n" unless ( $config and -f $config );
'verbose!' => \$verbose,
) or die "Incorrect options";
die "No config file given\n" unless ( $config and -f $config );
- my $cfg = ( values( %{ Config::Any->load_files( { files => [$config], use_ext => 1 } )->[0] } ) )[0];
+ my $cfg = (
+ values(
+ %{ Config::Any->load_files( { files => [$config], use_ext => 1 } )
+ ->[0]
+ }
+ )
+ )[0];
die "No git_dir specified\n" unless ( $cfg->{git_dir} );
$cfg->{lasttag} ||= $cfg->{git_dir} . '/refs/tags/BugzillaDone';
$cfg->{branch_head} ||= 'HEAD';
die "No git_dir specified\n" unless ( $cfg->{git_dir} );
$cfg->{lasttag} ||= $cfg->{git_dir} . '/refs/tags/BugzillaDone';
$cfg->{branch_head} ||= 'HEAD';
- $cfg->{lastref} = -f $cfg->{lasttag} ? read_file( $cfg->{lasttag} ) : 'HEAD';
+ $cfg->{lastref} =
+ -f $cfg->{lasttag} ? read_file( $cfg->{lasttag} ) : 'HEAD';
chomp( $cfg->{lastref} );
chomp( $cfg->{lastref} );
- my $git = Git::Repository->new( git_dir => $cfg->{git_dir} ) || die "No valid git repo\n";
+ my $git = Git::Repository->new( git_dir => $cfg->{git_dir} )
+ || die "No valid git repo\n";
my $newlast = walk_git_commits( $git, $cfg );
if ($newlast) {
my $newlast = walk_git_commits( $git, $cfg );
if ($newlast) {