[Libreoffice-commits] .: 3 commits - bin/lo-commit-stat
Petr Mladek
pmladek at kemper.freedesktop.org
Fri May 18 09:08:34 PDT 2012
bin/lo-commit-stat | 149 ++++++++++++++++++++++++++++++++++++++---------------
1 file changed, 108 insertions(+), 41 deletions(-)
New commits:
commit dd15b51ddaf4a143d494076a6dd554a059d91489
Author: Petr Mladek <pmladek at suse.cz>
Date: Fri May 18 18:02:37 2012 +0200
lo-commit-stat: problem with wide character in bug title
+ do not check for "-" in the bug title; it might be also wide character
in some cases
+ show result when looking for bug titles
+ sort bugs when loolking for bug titles and printing bug numbers
Change-Id: I39496f7d0cf5f7a116e7d3c506b76b4a3de1dee1
diff --git a/bin/lo-commit-stat b/bin/lo-commit-stat
index a14eb3e..a61b326 100755
--- a/bin/lo-commit-stat
+++ b/bin/lo-commit-stat
@@ -283,7 +283,7 @@ sub print_stat($$)
sub get_bug_name($$)
{
my ($bug, $summary) = @_;
- print "$bug\n";
+ print "$bug: ";
$bug =~ m/(?:(\w*)\#+(\d+))/; # fdo#12345
my $bugzilla = $1; # fdo
@@ -296,9 +296,12 @@ sub get_bug_name($$)
$ua->env_proxy;
my $response = $ua->get($url);
if ($response->is_success) {
- my $title = $response->title();
- if ( $title =~ s/^Bug \d+ – // ) {
+ my $title = $response->title;
+ if ( $title =~ s/^Bug \d+ . // ) {
+ print "$title\n";
return $title;
+ } else {
+ print "warning: not found; using commit message\n";
}
}
}
@@ -324,7 +327,8 @@ sub print_bugs($$)
}
# try to replace summaries with bug names from bugzilla
- foreach my $bug ( keys %bugs) {
+ print "Getting bug titles:\n";
+ foreach my $bug ( sort { $a cmp $b } keys %bugs) {
$bugs{$bug}{'summary'} = get_bug_name($bug, $bugs{$bug}{'summary'});
}
@@ -355,7 +359,7 @@ sub print_bugnumbers($$)
}
}
- printf $log join ("\n", keys %bugs) . "\n";
+ printf $log join ("\n", sort { $a cmp $b } keys %bugs) . "\n";
}
########################################################################
commit b47213604b69df85837b504917caf550c008459f
Author: Ivan Timofeev <timofeev.i.s at gmail.com>
Date: Thu May 17 18:42:46 2012 +0400
lo-commit-stat: remove flags and print_filters
Change-Id: I3d5ecb3cc52aeba780087f4ecb6b3bf86353276c
diff --git a/bin/lo-commit-stat b/bin/lo-commit-stat
index 1f067e2..a14eb3e 100755
--- a/bin/lo-commit-stat
+++ b/bin/lo-commit-stat
@@ -49,7 +49,6 @@ sub search_bugs($$$$)
# save the bug number
%{$pdata->{$piece}{$commit_id}{'bugs'}} = () if (! defined %{$pdata->{$piece}{$commit_id}{'bugs'}});
$pdata->{$piece}{$commit_id}{'bugs'}{$bug} = 1;
- $pdata->{$piece}{$commit_id}{'flags'}{'bug'} = 1;
}
return $line;
@@ -99,7 +98,6 @@ sub load_git_log($$$$$)
$commit_id = "$1";
$summary=undef;
%{$pdata->{$piece}{"$commit_id"}} = ();
- %{$pdata->{$piece}{"$commit_id"}{'flags'}} = ();
next;
}
@@ -222,23 +220,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, $ppiece_title, $pbugs, $pauthors, $prefix, $log) = @_;
return if ( $summary eq "" );
- # do we want to print this summary at all?
- my $print;
- if (%{$pprint_filters}) {
- foreach my $flag (keys %{$pprint_filters}) {
- $print = 1 if (defined $pflags->{$flag});
- }
- } else {
- $print = 1;
- }
- return unless (defined $print);
-
# print piece title if not done yet
if ( defined ${$ppiece_title} ) {
printf $log "${$ppiece_title}\n";
@@ -259,9 +246,9 @@ sub print_summary_in_stat($$$$$$$$)
printf $log $prefix . $summary . $bugs . $authors . "\n";
}
-sub print_stat($$$)
+sub print_stat($$)
{
- my ($pdata, $pprint_filters, $log) = @_;
+ my ($pdata, $log) = @_;
foreach my $piece ( sort { $a cmp $b } keys %{$pdata}) {
# check if this piece has any entries at all
@@ -270,15 +257,13 @@ sub print_stat($$$)
my $old_summary="";
my %authors = ();
my %bugs = ();
- my %flags = ();
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, \$piece_title, \%bugs, \%authors, " + ", $log);
$old_summary = $summary;
%authors = ();
%bugs = ();
- %flags = ();
}
# collect bug numbers
if (defined $pdata->{$piece}{$id}{'bugs'}) {
@@ -289,12 +274,8 @@ sub print_stat($$$)
# collect author names
my $author = $pdata->{$piece}{$id}{'author'}{'name'};
$authors{$author} = 1;
- # collect flags
- foreach my $flag ( keys %{$pdata->{$piece}{$id}{'flags'}} ) {
- $flags{$flag} = 1;
- }
}
- print_summary_in_stat($old_summary, $pprint_filters, \$piece_title, \%flags, \%bugs, \%authors, " + ", $log);
+ print_summary_in_stat($old_summary, \$piece_title, \%bugs, \%authors, " + ", $log);
}
}
}
@@ -426,7 +407,6 @@ my $git_command = "git log";
my $branch_name;
my @git_args;
my %data;
-my %print_filters = ();
my $print_mode = "normal";
foreach my $arg (@ARGV) {
@@ -442,11 +422,9 @@ foreach my $arg (@ARGV) {
} elsif ($arg =~ m/--log-dir=(.*)/) {
$log_dir = "$1";
} elsif ($arg eq '--bugs') {
- $print_filters{'bug'} = 1;
$log_prefix = "bugfixes";
$print_mode = "bugs";
} elsif ($arg eq '--bug-numbers') {
- $print_filters{'bug'} = 1;
$log_prefix = "bugnumbers";
$print_mode = "bugnumbers";
} elsif ($arg eq '--rev-list') {
@@ -480,6 +458,6 @@ if ( $print_mode eq "bugs" ) {
} elsif ( $print_mode eq "bugnumbers" ) {
print_bugnumbers(\%data, $log);
} else {
- print_stat(\%data, \%print_filters, $log);
+ print_stat(\%data, $log);
}
close $log;
commit a8b77a529047d2d26b1633df3c0f6511fc379305
Author: Ivan Timofeev <timofeev.i.s at gmail.com>
Date: Thu May 17 18:38:09 2012 +0400
lo-commit-stat: use bug titles instead of commit messages if possible
Change-Id: I0d5bb5f593c94b039c45bde638337932fa380b55
diff --git a/bin/lo-commit-stat b/bin/lo-commit-stat
index 626d601..1f067e2 100755
--- a/bin/lo-commit-stat
+++ b/bin/lo-commit-stat
@@ -4,10 +4,18 @@
#!/usr/bin/perl
use strict;
+use LWP::UserAgent;
my $main_repo="core";
my @pieces=("binfilter", "dictionaries", "help", "translations");
+my %bugzillas = (
+ fdo => "https://bugs.freedesktop.org/",
+ bnc => "https://bugzilla.novell.com/",
+ rhbz => "https://bugzilla.redhat.com/",
+ i => "https://issues.apache.org/ooo/",
+);
+
sub search_bugs($$$$)
{
my ($pdata, $piece, $commit_id, $line) = @_;
@@ -214,9 +222,9 @@ sub open_log_file($$$$$)
return $log;
}
-sub print_summary_in_stat($$$$$$$$$)
+sub print_summary_in_stat($$$$$$$$)
{
- my ($summary, $pprint_filters, $print_mode, $ppiece_title, $pflags, $pbugs, $pauthors, $prefix, $log) = @_;
+ my ($summary, $pprint_filters, $ppiece_title, $pflags, $pbugs, $pauthors, $prefix, $log) = @_;
return if ( $summary eq "" );
@@ -232,7 +240,7 @@ sub print_summary_in_stat($$$$$$$$$)
return unless (defined $print);
# print piece title if not done yet
- if ( defined ${$ppiece_title} && $print_mode ne "bugnumbers" ) {
+ if ( defined ${$ppiece_title} ) {
printf $log "${$ppiece_title}\n";
${$ppiece_title} = undef;
}
@@ -240,11 +248,7 @@ sub print_summary_in_stat($$$$$$$$$)
# finally print the summary line
my $bugs = "";
if ( %{$pbugs} ) {
- if ( $print_mode eq "bugnumbers" ) {
- $bugs = join ("\n", keys %{$pbugs}) . "\n";
- } else {
- $bugs = " (" . join (", ", keys %{$pbugs}) . ")";
- }
+ $bugs = " (" . join (", ", keys %{$pbugs}) . ")";
}
my $authors = "";
@@ -252,16 +256,12 @@ sub print_summary_in_stat($$$$$$$$$)
$authors = " [" . join (", ", keys %{$pauthors}) . "]";
}
- if ( $print_mode eq "bugnumbers" ) {
- printf $log $bugs;
- } else {
- printf $log $prefix . $summary . $bugs . $authors . "\n";
- }
+ printf $log $prefix . $summary . $bugs . $authors . "\n";
}
-sub print_stat($$$$)
+sub print_stat($$$)
{
- my ($pdata, $pprint_filters, $print_mode, $log) = @_;
+ my ($pdata, $pprint_filters, $log) = @_;
foreach my $piece ( sort { $a cmp $b } keys %{$pdata}) {
# check if this piece has any entries at all
@@ -274,7 +274,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, $print_mode, \$piece_title, \%flags, \%bugs, \%authors, " + ", $log);
+ print_summary_in_stat($old_summary, $pprint_filters, \$piece_title, \%flags, \%bugs, \%authors, " + ", $log);
$old_summary = $summary;
%authors = ();
%bugs = ();
@@ -294,9 +294,87 @@ sub print_stat($$$$)
$flags{$flag} = 1;
}
}
- print_summary_in_stat($old_summary, $pprint_filters, $print_mode, \$piece_title, \%flags, \%bugs, \%authors, " + ", $log);
+ print_summary_in_stat($old_summary, $pprint_filters, \$piece_title, \%flags, \%bugs, \%authors, " + ", $log);
+ }
+ }
+}
+
+sub get_bug_name($$)
+{
+ my ($bug, $summary) = @_;
+ print "$bug\n";
+
+ $bug =~ m/(?:(\w*)\#+(\d+))/; # fdo#12345
+ my $bugzilla = $1; # fdo
+ my $bug_number = $2; # 12345
+
+ if ( $bugzillas{$bugzilla} ) {
+ my $url = $bugzillas{$bugzilla} . "show_bug.cgi?id=" . $bug_number;
+ my $ua = LWP::UserAgent->new;
+ $ua->timeout(10);
+ $ua->env_proxy;
+ my $response = $ua->get($url);
+ if ($response->is_success) {
+ my $title = $response->title();
+ if ( $title =~ s/^Bug \d+ – // ) {
+ return $title;
+ }
+ }
+ }
+
+ return $summary;
+}
+
+sub print_bugs($$)
+{
+ my ($pdata, $log) = @_;
+
+ # 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;
+ }
+ }
+ }
+
+ # try to replace summaries with bug names from bugzilla
+ foreach my $bug ( 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'};
+
+ my $authors = "";
+ if ( %{$bugs{$bug}{'author'}} ) {
+ $authors = " [" . join (", ", keys %{$bugs{$bug}{'author'}}) . "]";
+ }
+
+ printf $log $bug . " " . $summary . $authors . "\n";
+ }
+}
+
+sub print_bugnumbers($$)
+{
+ my ($pdata, $log) = @_;
+
+ # 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;
+ }
}
}
+
+ printf $log join ("\n", keys %bugs) . "\n";
}
########################################################################
@@ -365,7 +443,8 @@ foreach my $arg (@ARGV) {
$log_dir = "$1";
} elsif ($arg eq '--bugs') {
$print_filters{'bug'} = 1;
- $log_prefix = "bugfixes"
+ $log_prefix = "bugfixes";
+ $print_mode = "bugs";
} elsif ($arg eq '--bug-numbers') {
$print_filters{'bug'} = 1;
$log_prefix = "bugnumbers";
@@ -396,5 +475,11 @@ $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);
-print_stat(\%data, \%print_filters, $print_mode, $log);
+if ( $print_mode eq "bugs" ) {
+ print_bugs(\%data, $log);
+} elsif ( $print_mode eq "bugnumbers" ) {
+ print_bugnumbers(\%data, $log);
+} else {
+ print_stat(\%data, \%print_filters, $log);
+}
close $log;
More information about the Libreoffice-commits
mailing list