summaryrefslogtreecommitdiff
path: root/bin/lo-commit-stat
diff options
context:
space:
mode:
Diffstat (limited to 'bin/lo-commit-stat')
-rwxr-xr-xbin/lo-commit-stat77
1 files changed, 48 insertions, 29 deletions
diff --git a/bin/lo-commit-stat b/bin/lo-commit-stat
index 51029fff25cd..8c53ec96fc85 100755
--- a/bin/lo-commit-stat
+++ b/bin/lo-commit-stat
@@ -67,9 +67,9 @@ sub standardize_summary($)
return $line;
}
-sub load_git_log($$$$)
+sub load_git_log($$$$$)
{
- my ($pdata, $repo_dir, $piece, $git_command) = @_;
+ my ($pdata, $repo_dir, $piece, $branch_name, $git_command) = @_;
my $cmd = "cd $repo_dir; $git_command";
my $commit_id;
@@ -77,6 +77,13 @@ sub load_git_log($$$$)
print STDERR "Analyzing log from the git repo: $piece...\n";
+ my $repo_branch_name = get_branch_name($repo_dir);
+ if ( $branch_name ne $repo_branch_name ) {
+ die "Error: mismatch of branches:\n" .
+ " main repo is on the branch: $branch_name\n" .
+ " $piece repo is on the branch: $repo_branch_name\n";
+ }
+
open (GIT, "$cmd 2>&1|") || die "Can't run $cmd: $!";
%{$pdata->{$piece}} = ();
@@ -144,9 +151,9 @@ sub get_repo_name($)
die "Error: can't find repo name in \"$$repo_dir/.git/config\"\n";
}
-sub load_data($$$$)
+sub load_data($$$$$)
{
- my ($pdata, $top_dir, $piece, $git_command) = @_;
+ my ($pdata, $top_dir, $piece, $branch_name, $git_command) = @_;
if (defined $piece) {
my $piece_dir;
@@ -155,11 +162,11 @@ sub load_data($$$$)
} else {
$piece_dir = "$top_dir/clone/$piece";
}
- load_git_log($pdata, $piece_dir, $piece, $git_command);
+ load_git_log($pdata, $piece_dir, $piece, $branch_name, $git_command);
} else {
- load_git_log($pdata, $top_dir, $main_repo, $git_command);
+ load_git_log($pdata, $top_dir, $main_repo, $branch_name, $git_command);
foreach my $piece (@pieces) {
- load_git_log($pdata, "$top_dir/clone/$piece", $piece, $git_command);
+ load_git_log($pdata, "$top_dir/clone/$piece", $piece, $branch_name, $git_command);
}
}
}
@@ -171,8 +178,6 @@ sub get_branch_name($)
my $branch;
my $cmd = "cd $top_dir && git branch";
- print STDERR "Analyzing git branch: ";
-
open (GIT, "$cmd 2>&1|") || die "Can't run $cmd: $!";
while (my $line = <GIT>) {
@@ -184,19 +189,16 @@ sub get_branch_name($)
}
close GIT;
-
- die "Error: did not detect git branch name\n" unless defined ($branch);
-
- print STDERR "$branch\n";
+
+ die "Error: did not detect git branch name in $top_dir\n" unless defined ($branch);
return $branch;
}
-sub open_log_file($$$)
+sub open_log_file($$$$)
{
- my ($log_prefix, $log_suffix, $top_dir) = @_;
+ my ($log_prefix, $log_suffix, $top_dir, $branch_name) = @_;
- my $branch_name = get_branch_name($top_dir);
my $logfilename = "$log_prefix-$branch_name-$log_suffix.log";
if (-f $logfilename) {
@@ -214,12 +216,12 @@ sub open_log_file($$$)
return $log;
}
-sub print_summary_in_stat($$$$$$$$)
+sub print_summary_in_stat($$$$$$$$$)
{
- my ($summary, $pprint_filters, $ppiece_title, $pflags, $pbugs, $pauthors, $prefix, $log) = @_;
+ my ($summary, $pprint_filters, $print_mode, $ppiece_title, $pflags, $pbugs, $pauthors, $prefix, $log) = @_;
return if ( $summary eq "" );
-
+
# do we want to print this summary at all?
my $print;
if (%{$pprint_filters}) {
@@ -232,7 +234,7 @@ sub print_summary_in_stat($$$$$$$$)
return unless (defined $print);
# print piece title if not done yet
- if (defined ${$ppiece_title}) {
+ if ( defined ${$ppiece_title} && $print_mode ne "bugnumbers" ) {
printf $log "${$ppiece_title}\n";
${$ppiece_title} = undef;
}
@@ -240,7 +242,11 @@ sub print_summary_in_stat($$$$$$$$)
# finally print the summary line
my $bugs = "";
if ( %{$pbugs} ) {
- $bugs = " (" . join (", ", keys %{$pbugs}) . ")";
+ if ( $print_mode eq "bugnumbers" ) {
+ $bugs = join ("\n", keys %{$pbugs}) . "\n";
+ } else {
+ $bugs = " (" . join (", ", keys %{$pbugs}) . ")";
+ }
}
my $authors = "";
@@ -248,12 +254,16 @@ sub print_summary_in_stat($$$$$$$$)
$authors = " [" . join (", ", keys %{$pauthors}) . "]";
}
- printf $log $prefix . $summary . $bugs . $authors . "\n";
+ if ( $print_mode eq "bugnumbers" ) {
+ printf $log $bugs;
+ } else {
+ printf $log $prefix . $summary . $bugs . $authors . "\n";
+ }
}
-sub print_stat($$$)
+sub print_stat($$$$)
{
- my ($pdata, $pprint_filters, $log) = @_;
+ my ($pdata, $pprint_filters, $print_mode, $log) = @_;
foreach my $piece ( sort { $a cmp $b } keys %{$pdata}) {
# check if this piece has any entries at all
@@ -266,7 +276,7 @@ sub print_stat($$$)
foreach my $id ( sort { $pdata->{$piece}{$a}{'summary'} cmp $pdata->{$piece}{$b}{'summary'} } keys %{$pdata->{$piece}}) {
my $summary = $pdata->{$piece}{$id}{'summary'};
if ($summary ne $old_summary) {
- print_summary_in_stat($old_summary, $pprint_filters, \$piece_title, \%flags, \%bugs, \%authors, " + ", $log);
+ print_summary_in_stat($old_summary, $pprint_filters, $print_mode, \$piece_title, \%flags, \%bugs, \%authors, " + ", $log);
$old_summary = $summary;
%authors = ();
%bugs = ();
@@ -286,7 +296,7 @@ sub print_stat($$$)
$flags{$flag} = 1;
}
}
- print_summary_in_stat($old_summary, $pprint_filters, \$piece_title, \%flags, \%bugs, \%authors, " + ", $log);
+ print_summary_in_stat($old_summary, $pprint_filters, $print_mode, \$piece_title, \%flags, \%bugs, \%authors, " + ", $log);
}
}
}
@@ -308,6 +318,7 @@ sub usage()
" commit-log-<branch>-<log-name-suffix>.log; the branch name\n" .
" is detected automatically\n" .
" --bugs print just bug fixes\n" .
+ " --bug-numbers print just fixed bug numbers\n" .
" --rev-list use \"git rev-list\" instead of \"git log\"; useful to check\n" .
" differences between branches\n" .
" topdir directory with the libreoffice/bootstrap clone; the piece repos\n" .
@@ -333,9 +344,11 @@ my $log_prefix = "commit-log";
my $log_suffix;
my $log;
my $git_command = "git log";
+my $branch_name;
my @git_args;
my %data;
my %print_filters = ();
+my $print_mode = "normal";
foreach my $arg (@ARGV) {
if ($arg eq '--help') {
@@ -350,6 +363,10 @@ foreach my $arg (@ARGV) {
} elsif ($arg eq '--bugs') {
$print_filters{'bug'} = 1;
$log_prefix = "bugfixes"
+ } elsif ($arg eq '--bug-numbers') {
+ $print_filters{'bug'} = 1;
+ $log_prefix = "bugnumbers";
+ $print_mode = "bugnumbers";
} elsif ($arg eq '--rev-list') {
$git_command = "git rev-list --pretty=medium"
} else {
@@ -369,8 +386,10 @@ $git_command .= " " . join ' ', @git_args if (@git_args);
(defined $log_suffix) || die "Error: define log suffix using --log-suffix=<string>\n";
-load_data(\%data, $top_dir,$piece, $git_command);
+$branch_name = get_branch_name($top_dir);
+
+load_data(\%data, $top_dir, $piece, $branch_name, $git_command);
-$log = open_log_file($log_prefix, $log_suffix, $top_dir);
-print_stat(\%data, \%print_filters, $log);
+$log = open_log_file($log_prefix, $log_suffix, $top_dir, $branch_name);
+print_stat(\%data, \%print_filters, $print_mode, $log);
close $log;