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 Try::Tiny;
use lib "$FindBin::Bin/../lib";
use WWW::Bugzilla;
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(
- join( "\n", $header, @{ $info->{info} }, '', @{ $info->{log} }, '----', @{ $info->{diffstat} } ) );
+ join( "\n",
+ $header, @{ $info->{info} }, '',
+ @{ $info->{log} }, '----', @{ $info->{diffstat} } )
+ );
}
else {
$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} );
}
# ------------------------------------------------------------------------
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;
}
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,
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 );
'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';
- $cfg->{lastref} = -f $cfg->{lasttag} ? read_file( $cfg->{lasttag} ) : 'HEAD';
+ $cfg->{lastref} =
+ -f $cfg->{lasttag} ? read_file( $cfg->{lasttag} ) : 'HEAD';
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) {