summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetr Mladek <pmladek@suse.cz>2012-11-20 16:10:58 +0100
committerAndras Timar <atimar@suse.com>2013-01-13 22:00:03 +0100
commit74e2a439656d00f97493e4fd53b24cdbe1b9ece2 (patch)
tree499423a1cef934a3b5eeb6d02ec3e220258f58b0
parent23b330aac632ac591271daf1ebf7bd029b7fbcb1 (diff)
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-xbin/lo-commit-stat93
1 files changed, 57 insertions, 36 deletions
diff --git a/bin/lo-commit-stat b/bin/lo-commit-stat
index 4135b8b9a33d..6da5285aaf10 100755
--- a/bin/lo-commit-stat
+++ b/bin/lo-commit-stat
@@ -214,12 +214,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";
@@ -236,7 +241,7 @@ sub open_log_file($$$$$)
return $log;
}
-sub print_summary_in_stat($$$$$$)
+sub print_commit_summary($$$$$$)
{
my ($summary, $ppiece_title, $pbugs, $pauthors, $prefix, $log) = @_;
@@ -262,9 +267,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 $piece ( sort { $a cmp $b } keys %{$pdata}) {
# check if this piece has any entries at all
@@ -276,7 +281,7 @@ sub print_stat($$)
foreach my $id ( sort { lc $pdata->{$piece}{$a}{'summary'} cmp lc $pdata->{$piece}{$b}{'summary'} } keys %{$pdata->{$piece}}) {
my $summary = $pdata->{$piece}{$id}{'summary'};
if ($summary ne $old_summary) {
- print_summary_in_stat($old_summary, \$piece_title, \%bugs, \%authors, " + ", $log);
+ print_commit_summary($old_summary, \$piece_title, \%bugs, \%authors, " + ", $log);
$old_summary = $summary;
%authors = ();
%bugs = ();
@@ -291,7 +296,7 @@ sub print_stat($$)
my $author = $pdata->{$piece}{$id}{'author'}{'name'};
$authors{$author} = 1;
}
- print_summary_in_stat($old_summary, \$piece_title, \%bugs, \%authors, " + ", $log);
+ print_commit_summary($old_summary, \$piece_title, \%bugs, \%authors, " + ", $log);
}
}
}
@@ -331,7 +336,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 = ();
@@ -361,13 +366,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 = ();
@@ -382,6 +388,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
@@ -399,9 +414,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; the piece repos\n" .
@@ -422,6 +438,7 @@ sub usage()
my $piece;
+my %generate_log = ();
my $top_dir;
my $log_prefix = "commit-log";
my $log_dir;
@@ -434,6 +451,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();
@@ -446,15 +472,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 {
@@ -466,6 +491,11 @@ foreach my $arg (@ARGV) {
}
}
+# default log
+if (%generate_log == 0) {
+ $generate_log{"commits"} = 1;
+}
+
$git_command .= " " . join ' ', @git_args if (@git_args);
(defined $top_dir) || die "Error: top directory is not defined\n";
@@ -480,16 +510,7 @@ $branch_name = get_branch_name($top_dir);
load_data(\%data, $top_dir, $piece, $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"});