summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetr Mladek <pmladek@suse.cz>2013-03-06 15:15:01 +0100
committerPetr Mladek <pmladek@suse.cz>2013-03-06 15:15:01 +0100
commit38ed89d2877558d96f2a3bd7f5c28a7c110a91b1 (patch)
treed20b7a91c0a3c60e59ed1bcd89e6ac23e02aaca0
parent96ce8e09ee44b6ec601c65eb16a9102253b7a369 (diff)
lo-commit-stat: new --bugs-changelog option
Add --bugs-changelog option to print the list of bugs in the style of SUSE changelog Optimized the code to check bugzilla only once when you generate more logs. Change-Id: I56eeda92628422f1b649c0fd71ae9146aeaa85c9
-rwxr-xr-xbin/lo-commit-stat167
1 files changed, 92 insertions, 75 deletions
diff --git a/bin/lo-commit-stat b/bin/lo-commit-stat
index 7dd2211f7a30..3cc3840d2bb3 100755
--- a/bin/lo-commit-stat
+++ b/bin/lo-commit-stat
@@ -258,6 +258,32 @@ sub get_branch_name($)
return $branch;
}
+sub get_bug_list($$$)
+{
+ my ($pdata, $pbugs, $check_bugzilla) = @_;
+
+ # associate bugs with their summaries and fixers
+ foreach my $piece ( keys %{$pdata}) {
+ foreach my $id ( keys %{$pdata->{$piece}}) {
+ foreach my $bug (keys %{$pdata->{$piece}{$id}{'bugs'}}) {
+ %{$pbugs->{$bug}} = () if (! defined %{$pbugs->{$bug}});
+ my $author = $pdata->{$piece}{$id}{'author'}{'name'};
+ my $summary = $pdata->{$piece}{$id}{'summary'};
+ $pbugs->{$bug}{'summary'} = $summary;
+ $pbugs->{$bug}{'author'}{$author} = 1;
+ }
+ }
+ }
+
+ # try to replace summaries with bug names from bugzilla
+ if ($check_bugzilla) {
+ print "Getting bug titles:\n";
+ foreach my $bug ( sort { $a cmp $b } keys %{$pbugs}) {
+ $pbugs->{$bug}{'summary'} = get_bug_name($bug, $pbugs->{$bug}{'summary'});
+ }
+ }
+}
+
sub open_log_file($$$$$$)
{
my ($log_dir, $log_prefix, $log_suffix, $top_dir, $branch_name, $wiki) = @_;
@@ -378,36 +404,16 @@ sub get_bug_name($$)
return $summary;
}
-sub print_bugs($$$)
+sub print_bugs($$$$)
{
- my ($pdata, $log, $wiki) = @_;
-
- # associate bugs with their summaries and fixers
- my %bugs = ();
- foreach my $piece ( keys %{$pdata}) {
- foreach my $id ( keys %{$pdata->{$piece}}) {
- foreach my $bug (keys %{$pdata->{$piece}{$id}{'bugs'}}) {
- my $author = $pdata->{$piece}{$id}{'author'}{'name'};
- my $summary = $pdata->{$piece}{$id}{'summary'};
- $bugs{$bug}{'summary'} = $summary;
- $bugs{$bug}{'author'}{$author} = 1;
- }
- }
- }
+ my ($pbugs, $log, $wiki) = @_;
- # try to replace summaries with bug names from bugzilla
- print "Getting bug titles:\n";
- foreach my $bug ( sort { $a cmp $b } keys %bugs) {
- $bugs{$bug}{'summary'} = get_bug_name($bug, $bugs{$bug}{'summary'});
- }
-
- # print
- foreach my $bug ( sort { $a cmp $b } keys %bugs) {
- my $summary = $bugs{$bug}{'summary'};
+ foreach my $bug ( sort { $a cmp $b } keys %{$pbugs}) {
+ my $summary = $pbugs->{$bug}{'summary'};
my $authors = "";
- if ( %{$bugs{$bug}{'author'}} ) {
- $authors = " [" . join (", ", keys %{$bugs{$bug}{'author'}}) . "]";
+ if ( %{$pbugs->{$bug}{'author'}} ) {
+ $authors = " [" . join (", ", keys %{$pbugs->{$bug}{'author'}}) . "]";
}
$bug =~ s/(.*)\#(.*)/* {{$1|$2}}/ if ($wiki);
@@ -415,29 +421,35 @@ sub print_bugs($$$)
}
}
-sub print_bugnumbers($$$)
+sub print_bugs_changelog($$$$)
{
- my ($pdata, $log, $wiki) = @_;
+ my ($pbugs, $log, $wiki) = @_;
- # just collect bugs
- my %bugs = ();
- foreach my $piece ( keys %{$pdata}) {
- foreach my $id ( keys %{$pdata->{$piece}}) {
- foreach my $bug (keys %{$pdata->{$piece}{$id}{'bugs'}}) {
- $bugs{$bug} = 1;
- }
+ foreach my $bug ( sort { $a cmp $b } keys %{$pbugs}) {
+ my $summary = $pbugs->{$bug}{'summary'};
+
+ my $authors = "";
+ if ( %{$pbugs->{$bug}{'author'}} ) {
+ $authors = " [" . join (", ", keys %{$pbugs->{$bug}{'author'}}) . "]";
}
+
+ print $log " + $summary ($bug)$authors\n";
}
+}
+
+sub print_bugnumbers($$$$)
+{
+ my ($pbugs, $log, $wiki) = @_;
- print $log join ("\n", sort { $a cmp $b } keys %bugs), "\n";
+ print $log join ("\n", sort { $a cmp $b } keys %{$pbugs}), "\n";
}
sub generate_log($$$$$$$$)
{
- my ($pdata, $print_func, $log_dir, $log_prefix, $log_suffix, $top_dir, $branch_name, $wiki) = @_;
+ my ($pused_data, $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);
+ & {$print_func} ($pused_data, $log, $wiki);
close $log;
}
@@ -451,30 +463,31 @@ sub usage()
"Usage: lo-commit-stat [--help] [--no-pieces] [--piece=<piece>] --log-dir=<dir> --log-suffix=<string> topdir [git_arg...]\n\n" .
"Options:\n" .
- " --help print this help\n" .
- " --no-pieces read changes just from the main repository, ignore other cloned repos\n" .
- " --piece=<piece> summarize just changes from the given piece\n" .
- " --log-dir=<dir> directory where to put the generated log\n" .
+ " --help print this help\n" .
+ " --no-pieces read changes just from the main repository, ignore other cloned repos\n" .
+ " --piece=<piece> summarize just changes from the given piece\n" .
+ " --log-dir=<dir> directory where to put the generated log\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" .
- " is detected automatically\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" .
- " --cherry use \"git cherry\" instead of \"git log\"; detects cherry-picked\n" .
- " commits between branches\n" .
- " topdir directory with the libreoffice/core clone; the piece repos\n" .
- " must be cloned in the main-repo-root/clone/<piece> subdirectories\n" .
- " git_arg extra parameters passed to the git command to define\n" .
- " the area of interest; The default command is \"git log\" and\n" .
- " parameters might be, for example, --after=\"2010-09-27\" or\n" .
- " TAG..HEAD; with the option --rev-list, useful might be, for\n" .
- " example origin/master ^origin/libreoffice-3-3; with the option\n" .
- " --rev-list, useful might be, for example libreoffice-3.6.3.2\n" .
- " libreoffice-3.6.4.1\n";
+ " commit-log-<branch>-<log-name-suffix>.log; the branch name\n" .
+ " is detected automatically\n" .
+ " --commits generete log with all commits (default)\n" .
+ " --bugs generate log with bugzilla entries\n" .
+ " --bugs-changelog generate log with bugzilla entries, use changelog style\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" .
+ " --cherry use \"git cherry\" instead of \"git log\"; detects cherry-picked\n" .
+ " commits between branches\n" .
+ " topdir directory with the libreoffice/core clone; the piece repos\n" .
+ " must be cloned in the main-repo-root/clone/<piece> subdirectories\n" .
+ " git_arg extra parameters passed to the git command to define\n" .
+ " the area of interest; The default command is \"git log\" and\n" .
+ " parameters might be, for example, --after=\"2010-09-27\" or\n" .
+ " TAG..HEAD; with the option --rev-list, useful might be, for\n" .
+ " example origin/master ^origin/libreoffice-3-3; with the option\n" .
+ " --rev-list, useful might be, for example libreoffice-3.6.3.2\n" .
+ " libreoffice-3.6.4.1\n";
}
@@ -488,25 +501,18 @@ sub usage()
my $piece;
my %generate_log = ();
my $top_dir;
-my $log_prefix = "commit-log";
my $log_dir;
my $log_suffix;
my $log;
+my $list_bugs = 0;
+my $check_bugzilla = 0;
my $branch_name;
my $git_command = "git log";
my $git_cherry;
my $git_args = "";
my $branch_name;
my %data;
-my $print_mode = "normal";
-
- $log_prefix = "bugfixes";
- $print_mode = "bugs";
- $log_prefix = "bugfixes";
- $print_mode = "wikibugs";
- $log_prefix = "bugnumbers";
- $print_mode = "bugnumbers";
-
+my %bugs = ();
foreach my $arg (@ARGV) {
@@ -525,10 +531,19 @@ foreach my $arg (@ARGV) {
$generate_log{"commits"} = 1;
} elsif ($arg eq '--bugs') {
$generate_log{"bugs"} = 1;
+ $check_bugzilla = 1;
+ $list_bugs = 1;
+ } elsif ($arg eq '--bugs-changelog') {
+ $generate_log{"bugs-changelog"} = 1;
+ $check_bugzilla = 1;
+ $list_bugs = 1;
} elsif ($arg eq '--bugs-wiki' || $arg eq '--wikibugs') {
$generate_log{"bugs-wiki"} = 1;
+ $check_bugzilla = 1;
+ $list_bugs = 1;
} elsif ($arg eq '--bugs-numbers' || $arg eq '--bug-numbers') {
$generate_log{"bugs-numbers"} = 1;
+ $list_bugs = 1;
} elsif ($arg eq '--rev-list') {
$git_command = "git rev-list --pretty=medium"
} elsif ($arg eq '--cherry') {
@@ -559,8 +574,10 @@ if (%generate_log == 0) {
$branch_name = get_branch_name($top_dir);
load_data(\%data, $top_dir, $piece, $branch_name, $git_command, $git_cherry, $git_args);
+get_bug_list(\%data, \%bugs, $check_bugzilla) if ($list_bugs);
-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"});
+generate_log(\%data, \&print_commits, $log_dir, "commits", $log_suffix, $top_dir, $branch_name, 0) if (defined $generate_log{"commits"});
+generate_log(\%bugs, \&print_bugs, $log_dir, "bugs", $log_suffix, $top_dir, $branch_name, 0) if (defined $generate_log{"bugs"});
+generate_log(\%bugs, \&print_bugs, $log_dir, "bugs", $log_suffix, $top_dir, $branch_name, 1) if (defined $generate_log{"bugs-wiki"});
+generate_log(\%bugs, \&print_bugs_changelog, $log_dir, "bugs-changelog", $log_suffix, $top_dir, $branch_name, 0) if (defined $generate_log{"bugs-changelog"});
+generate_log(\%bugs, \&print_bugnumbers, $log_dir, "bug-numbers", $log_suffix, $top_dir, $branch_name, 0) if (defined $generate_log{"bugs-numbers"});