Skip to content

Commit 73114f3

Browse files
committed
Minor tweaks from ages back
1 parent 937f560 commit 73114f3

File tree

1 file changed

+31
-10
lines changed

1 file changed

+31
-10
lines changed

script/git-to-bugzilla.pl

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,20 @@ sub update_bugzilla {
2727
server => $cfg->{bugzilla}{server},
2828
email => $cfg->{bugzilla}{user},
2929
password => $cfg->{bugzilla}{pass},
30+
use_ssl=>1,
3031
bug_number => $set->{bug}
3132
) || croak "Cannot open bz - $!";
3233

33-
my $header = sprintf( "Git commit: %s/commitdiff/%s\n", $cfg->{gitweb}, $info->{rev} );
34+
my $header =
35+
sprintf( "Git commit: %s/commitdiff/%s\n", $cfg->{gitweb}, $info->{rev} );
3436
if ( scalar( @{ $info->{diff} } ) > 50 ) {
3537

3638
# big diff - we skip the diff
3739
$bz->additional_comments(
38-
join( "\n", $header, @{ $info->{info} }, '', @{ $info->{log} }, '----', @{ $info->{diffstat} } ) );
40+
join( "\n",
41+
$header, @{ $info->{info} }, '',
42+
@{ $info->{log} }, '----', @{ $info->{diffstat} } )
43+
);
3944
}
4045
else {
4146

@@ -48,7 +53,9 @@ sub update_bugzilla {
4853

4954
$bz->commit;
5055

51-
printf( "[%d] %s %s [%s]\n", $set->{bug}, $info->{rev}, $info->{log}[0], $set->{action} );
56+
printf( "[%d] %s %s [%s]\n",
57+
$set->{bug}, $info->{rev}, $info->{log}[0], $set->{action} )
58+
if ($verbose);
5259
}
5360

5461
# ------------------------------------------------------------------------
@@ -61,7 +68,9 @@ sub find_bugzilla_references {
6168
my $bugid;
6269
foreach my $line ( @{ $info->{log} } ) {
6370
$line = lc($line);
64-
if ( $line =~ /(closes|fixes|references):?\s*(?:bug(?:zilla|s)?)?\s*\#?(\d+)/ ) {
71+
if ( $line =~
72+
/(closes|fixes|references):?\s*(?:bug(?:zilla|s)?)?\s*\#?(\d+)/ )
73+
{
6574
$action = $1;
6675
$bugid = $2;
6776
}
@@ -76,7 +85,8 @@ sub find_bugzilla_references {
7685
# remap actions
7786

7887
push( @results, { bug => $bugid, action => $action } );
79-
##printf( "%s\n\taction = %s bugid = %s\n", $info->{rev}, $action, $bugid );
88+
printf( "%s\n\taction = %s bugid = %s\n",
89+
$info->{rev}, $action, $bugid );
8090
}
8191
return @results;
8292
}
@@ -87,7 +97,9 @@ sub git_commit_info {
8797
my $git = shift;
8898
my $rev = shift;
8999

90-
my @lines = $git->run( 'show', '-M', '-C', '--patch-with-stat', '--pretty=fuller', $rev );
100+
my @lines =
101+
$git->run( 'show', '-M', '-C', '--patch-with-stat', '--pretty=fuller',
102+
$rev );
91103

92104
my $info = {
93105
rev => $rev,
@@ -130,7 +142,8 @@ sub walk_git_commits {
130142

131143
return if ( $lastrev eq $headrev );
132144

133-
my @revs = $git->run( 'rev-list', '--topo-order', '--no-merges', ( $lastrev . '..' . $headrev ) );
145+
my @revs = $git->run( 'rev-list', '--topo-order', '--no-merges',
146+
( $lastrev . '..' . $headrev ) );
134147

135148
foreach my $rev ( reverse(@revs) ) {
136149
my $info = git_commit_info( $git, $rev );
@@ -157,16 +170,24 @@ sub walk_git_commits {
157170
'verbose!' => \$verbose,
158171
) or die "Incorrect options";
159172
die "No config file given\n" unless ( $config and -f $config );
160-
my $cfg = ( values( %{ Config::Any->load_files( { files => [$config], use_ext => 1 } )->[0] } ) )[0];
173+
my $cfg = (
174+
values(
175+
%{ Config::Any->load_files( { files => [$config], use_ext => 1 } )
176+
->[0]
177+
}
178+
)
179+
)[0];
161180

162181
die "No git_dir specified\n" unless ( $cfg->{git_dir} );
163182
$cfg->{lasttag} ||= $cfg->{git_dir} . '/refs/tags/BugzillaDone';
164183
$cfg->{branch_head} ||= 'HEAD';
165184

166-
$cfg->{lastref} = -f $cfg->{lasttag} ? read_file( $cfg->{lasttag} ) : 'HEAD';
185+
$cfg->{lastref} =
186+
-f $cfg->{lasttag} ? read_file( $cfg->{lasttag} ) : 'HEAD';
167187
chomp( $cfg->{lastref} );
168188

169-
my $git = Git::Repository->new( git_dir => $cfg->{git_dir} ) || die "No valid git repo\n";
189+
my $git = Git::Repository->new( git_dir => $cfg->{git_dir} )
190+
|| die "No valid git repo\n";
170191

171192
my $newlast = walk_git_commits( $git, $cfg );
172193
if ($newlast) {

0 commit comments

Comments
 (0)