diff options
author | Petr Mladek <pmladek@suse.cz> | 2012-11-20 16:10:58 +0100 |
---|---|---|
committer | Petr Mladek <pmladek@suse.cz> | 2012-11-20 16:10:58 +0100 |
commit | 93d021a7803bc897b0f52928a7562bb2b9860566 (patch) | |
tree | 3c5554e491fbd61402614f91966ccf1a35dd6294 | |
parent | bump product version to 4.0.0.0.alpha1+, release number to 1 (diff) | |
download | core-93d021a7803bc897b0f52928a7562bb2b9860566.tar.gz core-93d021a7803bc897b0f52928a7562bb2b9860566.zip |
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
-rwxr-xr-x | bin/lo-commit-stat | 95 |
1 files changed, 58 insertions, 37 deletions
diff --git a/bin/lo-commit-stat b/bin/lo-commit-stat index 910d4ad89a7e..c64e125d0196 100755 --- a/bin/lo-commit-stat +++ b/bin/lo-commit-stat @@ -209,12 +209,17 @@ sub get_branch_name($) 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); + if ($wiki) { + $logfilename .= ".wiki"; + } else { + $logfilename .= ".log"; + } if (-f $logfilename) { print "WARNING: The log file already exists: $logfilename\n"; @@ -231,7 +236,7 @@ sub open_log_file($$$$$) return $log; } -sub print_summary_in_stat($$$$$$) +sub print_commit_summary($$$$$$) { my ($summary, $pmodule_title, $pbugs, $pauthors, $prefix, $log) = @_; @@ -257,9 +262,9 @@ sub print_summary_in_stat($$$$$$) 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}) { # check if this module has any entries at all @@ -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}}) { my $summary = $pdata->{$module}{$id}{'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; %authors = (); %bugs = (); @@ -286,7 +291,7 @@ sub print_stat($$) my $author = $pdata->{$module}{$id}{'author'}{'name'}; $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($$) sub print_bugs($$$) { - my ($pdata, $log, $convert_func) = @_; + my ($pdata, $log, $wiki) = @_; # associate bugs with their summaries and fixers my %bugs = (); @@ -356,13 +361,14 @@ sub print_bugs($$$) $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 my %bugs = (); @@ -377,6 +383,15 @@ sub print_bugnumbers($$) 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 @@ -395,9 +410,10 @@ sub usage() " --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" . " is detected automatically\n" . - " --bugs print just bug fixes\n" . - " --wikibugs print just bug fixes, use wiki markup\n" . - " --bug-numbers print just fixed bug numbers\n" . + " --commits generete log with all commits (default)\n" . + " --bugs generate log with bugzilla entries\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" . " differences between branches\n" . " topdir directory with the libreoffice/core clone\n" . @@ -417,6 +433,7 @@ sub usage() my $module; +my %generate_log = (); my $top_dir; my $log_prefix = "commit-log"; my $log_dir; @@ -429,6 +446,15 @@ my @git_args; my %data; 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) { if ($arg eq '--help') { usage(); @@ -441,15 +467,14 @@ foreach my $arg (@ARGV) { $log_suffix = "$1"; } elsif ($arg =~ m/--log-dir=(.*)/) { $log_dir = "$1"; + } elsif ($arg eq '--commits') { + $generate_log{"commits"} = 1; } elsif ($arg eq '--bugs') { - $log_prefix = "bugfixes"; - $print_mode = "bugs"; - } elsif ($arg eq '--wikibugs') { - $log_prefix = "bugfixes"; - $print_mode = "wikibugs"; - } elsif ($arg eq '--bug-numbers') { - $log_prefix = "bugnumbers"; - $print_mode = "bugnumbers"; + $generate_log{"bugs"} = 1; + } elsif ($arg eq '--bugs-wiki' || $arg eq '--wikibugs') { + $generate_log{"bugs-wiki"} = 1; + } elsif ($arg eq '--bugs-numbers' || $arg eq '--bug-numbers') { + $generate_log{"bugs-numbers"} = 1; } elsif ($arg eq '--rev-list') { $git_command = "git rev-list --pretty=medium" } else { @@ -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) { my $name = $module_dirname{$module}; %module_dirname = (); @@ -482,16 +512,7 @@ $branch_name = get_branch_name($top_dir); 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); -if ( $print_mode eq "bugs" ) { - # identity-transform bug ids - print_bugs(\%data, $log, sub { return $_[0] } ); -} 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; +generate_log(\%data, \&print_commits, $log_dir, "commits", $log_suffix, $top_dir, $branch_name, 0) if (defined $generate_log{"commits"}); +generate_log(\%data, \&print_bugs, $log_dir, "bugs", $log_suffix, $top_dir, $branch_name, 0) if (defined $generate_log{"bugs"}); +generate_log(\%data, \&print_bugs, $log_dir, "bugs", $log_suffix, $top_dir, $branch_name, 1) if (defined $generate_log{"bugs-wiki"}); +generate_log(\%data, \&print_bugnumbers, $log_dir, "bug-numbers", $log_suffix, $top_dir, $branch_name, 0) if (defined $generate_log{"bugs-numbers"}); |