Kaydet (Commit) 93d021a7 authored tarafından Petr Mladek's avatar Petr Mladek

lo-commit-stat: allow to generate more logs at once

It takes ages to get bug summary from bugzilla => it is worh to
generate normal and wiki logs at the same time. Why not produce
all logs with one call

Add --commits option. Also rename --wikibugs to --bugs-wiki.

Use .wiki suffix for wiki logs. Also rename "commit-log" to "commits".
It is enough to use ".log" as the suffix.

Change-Id: I92bbc4d56a0ae9e23401be0677256059c777d712
üst 01db9eda
...@@ -209,12 +209,17 @@ sub get_branch_name($) ...@@ -209,12 +209,17 @@ sub get_branch_name($)
return $branch; return $branch;
} }
sub open_log_file($$$$$) sub open_log_file($$$$$$)
{ {
my ($log_dir, $log_prefix, $log_suffix, $top_dir, $branch_name) = @_; my ($log_dir, $log_prefix, $log_suffix, $top_dir, $branch_name, $wiki) = @_;
my $logfilename = "$log_prefix-$branch_name-$log_suffix.log"; my $logfilename = "$log_prefix-$branch_name-$log_suffix";
$logfilename = "$log_dir/$logfilename" if (defined $log_dir); $logfilename = "$log_dir/$logfilename" if (defined $log_dir);
if ($wiki) {
$logfilename .= ".wiki";
} else {
$logfilename .= ".log";
}
if (-f $logfilename) { if (-f $logfilename) {
print "WARNING: The log file already exists: $logfilename\n"; print "WARNING: The log file already exists: $logfilename\n";
...@@ -231,7 +236,7 @@ sub open_log_file($$$$$) ...@@ -231,7 +236,7 @@ sub open_log_file($$$$$)
return $log; return $log;
} }
sub print_summary_in_stat($$$$$$) sub print_commit_summary($$$$$$)
{ {
my ($summary, $pmodule_title, $pbugs, $pauthors, $prefix, $log) = @_; my ($summary, $pmodule_title, $pbugs, $pauthors, $prefix, $log) = @_;
...@@ -257,9 +262,9 @@ sub print_summary_in_stat($$$$$$) ...@@ -257,9 +262,9 @@ sub print_summary_in_stat($$$$$$)
print $log $prefix, $summary, $bugs, $authors, "\n"; print $log $prefix, $summary, $bugs, $authors, "\n";
} }
sub print_stat($$) sub print_commits($$$)
{ {
my ($pdata, $log) = @_; my ($pdata, $log, $wiki) = @_;
foreach my $module ( sort { $a cmp $b } keys %{$pdata}) { foreach my $module ( sort { $a cmp $b } keys %{$pdata}) {
# check if this module has any entries at all # check if this module has any entries at all
...@@ -271,7 +276,7 @@ sub print_stat($$) ...@@ -271,7 +276,7 @@ sub print_stat($$)
foreach my $id ( sort { lc $pdata->{$module}{$a}{'summary'} cmp lc $pdata->{$module}{$b}{'summary'} } keys %{$pdata->{$module}}) { foreach my $id ( sort { lc $pdata->{$module}{$a}{'summary'} cmp lc $pdata->{$module}{$b}{'summary'} } keys %{$pdata->{$module}}) {
my $summary = $pdata->{$module}{$id}{'summary'}; my $summary = $pdata->{$module}{$id}{'summary'};
if ($summary ne $old_summary) { if ($summary ne $old_summary) {
print_summary_in_stat($old_summary, \$module_title, \%bugs, \%authors, " + ", $log); print_commit_summary($old_summary, \$module_title, \%bugs, \%authors, " + ", $log);
$old_summary = $summary; $old_summary = $summary;
%authors = (); %authors = ();
%bugs = (); %bugs = ();
...@@ -286,7 +291,7 @@ sub print_stat($$) ...@@ -286,7 +291,7 @@ sub print_stat($$)
my $author = $pdata->{$module}{$id}{'author'}{'name'}; my $author = $pdata->{$module}{$id}{'author'}{'name'};
$authors{$author} = 1; $authors{$author} = 1;
} }
print_summary_in_stat($old_summary, \$module_title, \%bugs, \%authors, " + ", $log); print_commit_summary($old_summary, \$module_title, \%bugs, \%authors, " + ", $log);
} }
} }
} }
...@@ -326,7 +331,7 @@ sub get_bug_name($$) ...@@ -326,7 +331,7 @@ sub get_bug_name($$)
sub print_bugs($$$) sub print_bugs($$$)
{ {
my ($pdata, $log, $convert_func) = @_; my ($pdata, $log, $wiki) = @_;
# associate bugs with their summaries and fixers # associate bugs with their summaries and fixers
my %bugs = (); my %bugs = ();
...@@ -356,13 +361,14 @@ sub print_bugs($$$) ...@@ -356,13 +361,14 @@ sub print_bugs($$$)
$authors = " [" . join (", ", keys %{$bugs{$bug}{'author'}}) . "]"; $authors = " [" . join (", ", keys %{$bugs{$bug}{'author'}}) . "]";
} }
print $log $convert_func->($bug), " ", $summary, $authors, "\n"; $bug =~ s/(.*)\#(.*)/* {{$1|$2}}/ if ($wiki);
print $log $bug, " ", $summary, $authors, "\n";
} }
} }
sub print_bugnumbers($$) sub print_bugnumbers($$$)
{ {
my ($pdata, $log) = @_; my ($pdata, $log, $wiki) = @_;
# just collect bugs # just collect bugs
my %bugs = (); my %bugs = ();
...@@ -377,6 +383,15 @@ sub print_bugnumbers($$) ...@@ -377,6 +383,15 @@ sub print_bugnumbers($$)
print $log join ("\n", sort { $a cmp $b } keys %bugs), "\n"; print $log join ("\n", sort { $a cmp $b } keys %bugs), "\n";
} }
sub generate_log($$$$$$$$)
{
my ($pdata, $print_func, $log_dir, $log_prefix, $log_suffix, $top_dir, $branch_name, $wiki) = @_;
my $log = open_log_file($log_dir, $log_prefix, $log_suffix, $top_dir, $branch_name, $wiki);
& {$print_func} ($pdata, $log, $wiki);
close $log;
}
######################################################################## ########################################################################
# help # help
...@@ -395,9 +410,10 @@ sub usage() ...@@ -395,9 +410,10 @@ sub usage()
" --log-suffix=<string> suffix of the log file name; the result will be\n" . " --log-suffix=<string> suffix of the log file name; the result will be\n" .
" commit-log-<branch>-<log-name-suffix>.log; the branch name\n" . " commit-log-<branch>-<log-name-suffix>.log; the branch name\n" .
" is detected automatically\n" . " is detected automatically\n" .
" --bugs print just bug fixes\n" . " --commits generete log with all commits (default)\n" .
" --wikibugs print just bug fixes, use wiki markup\n" . " --bugs generate log with bugzilla entries\n" .
" --bug-numbers print just fixed bug numbers\n" . " --bugs-wiki generate log with bugzilla entries, use wiki markup\n" .
" --bugs-numbers generate log with bugzilla numbers\n" .
" --rev-list use \"git rev-list\" instead of \"git log\"; useful to check\n" . " --rev-list use \"git rev-list\" instead of \"git log\"; useful to check\n" .
" differences between branches\n" . " differences between branches\n" .
" topdir directory with the libreoffice/core clone\n" . " topdir directory with the libreoffice/core clone\n" .
...@@ -417,6 +433,7 @@ sub usage() ...@@ -417,6 +433,7 @@ sub usage()
my $module; my $module;
my %generate_log = ();
my $top_dir; my $top_dir;
my $log_prefix = "commit-log"; my $log_prefix = "commit-log";
my $log_dir; my $log_dir;
...@@ -429,6 +446,15 @@ my @git_args; ...@@ -429,6 +446,15 @@ my @git_args;
my %data; my %data;
my $print_mode = "normal"; my $print_mode = "normal";
$log_prefix = "bugfixes";
$print_mode = "bugs";
$log_prefix = "bugfixes";
$print_mode = "wikibugs";
$log_prefix = "bugnumbers";
$print_mode = "bugnumbers";
foreach my $arg (@ARGV) { foreach my $arg (@ARGV) {
if ($arg eq '--help') { if ($arg eq '--help') {
usage(); usage();
...@@ -441,15 +467,14 @@ foreach my $arg (@ARGV) { ...@@ -441,15 +467,14 @@ foreach my $arg (@ARGV) {
$log_suffix = "$1"; $log_suffix = "$1";
} elsif ($arg =~ m/--log-dir=(.*)/) { } elsif ($arg =~ m/--log-dir=(.*)/) {
$log_dir = "$1"; $log_dir = "$1";
} elsif ($arg eq '--commits') {
$generate_log{"commits"} = 1;
} elsif ($arg eq '--bugs') { } elsif ($arg eq '--bugs') {
$log_prefix = "bugfixes"; $generate_log{"bugs"} = 1;
$print_mode = "bugs"; } elsif ($arg eq '--bugs-wiki' || $arg eq '--wikibugs') {
} elsif ($arg eq '--wikibugs') { $generate_log{"bugs-wiki"} = 1;
$log_prefix = "bugfixes"; } elsif ($arg eq '--bugs-numbers' || $arg eq '--bug-numbers') {
$print_mode = "wikibugs"; $generate_log{"bugs-numbers"} = 1;
} elsif ($arg eq '--bug-numbers') {
$log_prefix = "bugnumbers";
$print_mode = "bugnumbers";
} elsif ($arg eq '--rev-list') { } elsif ($arg eq '--rev-list') {
$git_command = "git rev-list --pretty=medium" $git_command = "git rev-list --pretty=medium"
} else { } else {
...@@ -461,7 +486,12 @@ foreach my $arg (@ARGV) { ...@@ -461,7 +486,12 @@ foreach my $arg (@ARGV) {
} }
} }
# ugly hack; we want only one module # default log
if (%generate_log == 0) {
$generate_log{"commits"} = 1;
}
# we want only one module
if ($module) { if ($module) {
my $name = $module_dirname{$module}; my $name = $module_dirname{$module};
%module_dirname = (); %module_dirname = ();
...@@ -482,16 +512,7 @@ $branch_name = get_branch_name($top_dir); ...@@ -482,16 +512,7 @@ $branch_name = get_branch_name($top_dir);
load_data(\%data, $top_dir, \%module_dirname, $branch_name, $git_command); load_data(\%data, $top_dir, \%module_dirname, $branch_name, $git_command);
$log = open_log_file($log_dir, $log_prefix, $log_suffix, $top_dir, $branch_name); generate_log(\%data, \&print_commits, $log_dir, "commits", $log_suffix, $top_dir, $branch_name, 0) if (defined $generate_log{"commits"});
if ( $print_mode eq "bugs" ) { generate_log(\%data, \&print_bugs, $log_dir, "bugs", $log_suffix, $top_dir, $branch_name, 0) if (defined $generate_log{"bugs"});
# identity-transform bug ids generate_log(\%data, \&print_bugs, $log_dir, "bugs", $log_suffix, $top_dir, $branch_name, 1) if (defined $generate_log{"bugs-wiki"});
print_bugs(\%data, $log, sub { return $_[0] } ); generate_log(\%data, \&print_bugnumbers, $log_dir, "bug-numbers", $log_suffix, $top_dir, $branch_name, 0) if (defined $generate_log{"bugs-numbers"});
} elsif ( $print_mode eq "wikibugs" ) {
# wiki-ize bug ids
print_bugs(\%data, $log, sub { $_[0] =~ s/(.*)\#(.*)/* {{$1|$2}}/; return $_[0] });
} elsif ( $print_mode eq "bugnumbers" ) {
print_bugnumbers(\%data, $log);
} else {
print_stat(\%data, $log);
}
close $log;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment