[Libreoffice-commits] .: Branch 'libreoffice-3-6' - 4 commits - bin/lo-commit-stat

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu Nov 29 05:54:07 PST 2012


 bin/lo-commit-stat |  188 ++++++++++++++++++++++++++++++++++++-----------------
 1 file changed, 130 insertions(+), 58 deletions(-)

New commits:
commit 5c580e624b9dffbfcae1c7870c1f1df944006b47
Author: Petr Mladek <pmladek at suse.cz>
Date:   Thu Nov 29 11:14:13 2012 +0100

    lo-commit-stat: allow to filer cherry-picked commits
    
    Add --cherry option that filters commits using the "git cherry" command.
    
    Note that you need to pass git arguments for "git cherry". It means
    "old-branch-or-tag" "new-branch-or-tag".
    
    Change-Id: Iea67d0ead205c66112791cb0444fa183c7fa6e9b

diff --git a/bin/lo-commit-stat b/bin/lo-commit-stat
index 6da5285..7dd2211 100755
--- a/bin/lo-commit-stat
+++ b/bin/lo-commit-stat
@@ -6,6 +6,7 @@
 use strict;
 use LWP::UserAgent;
 use utf8;
+use File::Temp;
 
 my $main_repo="core";
 my @pieces=("binfilter", "dictionaries", "help", "translations");
@@ -87,11 +88,53 @@ sub standardize_summary($)
     return $line;
 }
 
-sub load_git_log($$$$$) 
+sub generate_git_cherry_ids_log($$$$$) 
 {
-    my ($pdata, $repo_dir, $piece, $branch_name, $git_command) = @_;
+    my ($pdata, $repo_dir, $piece, $branch_name, $git_args) = @_;
+
+    my $commit_ids_log;
+    my $commit_ids_log_fh;
+    $commit_ids_log_fh = File::Temp->new(TEMPLATE => 'lo-commit-stat-ids-XXXXXX',
+                                         DIR => '/tmp',
+                                         UNLINK => 0);
+    $commit_ids_log = $commit_ids_log_fh->filename;
+
+    print STDERR "Filtering cherry-picked commits in the git repo: $piece...\n";
+
+    my $cmd = "cd $repo_dir; git cherry $git_args";
+    open (GIT, "$cmd 2>&1|") || die "Can't run $cmd: $!";
+
+    while (my $line = <GIT>) {
+
+        # skip cherry-picked commits
+        next if ( $line =~ m/^\-/ );
+    
+        if ( $line =~ m/^\+ / ) {
+            $line =~ s/^\+ //;
+            print $commit_ids_log_fh $line;
+        }
+    }
+    
+    close GIT;
+    close $commit_ids_log_fh;
+    
+    return $commit_ids_log;
+}
+
+sub load_git_log($$$$$$$) 
+{
+    my ($pdata, $repo_dir, $piece, $branch_name, $git_command, $git_cherry, $git_args) = @_;
+
+    my $cmd = "cd $repo_dir;";
+    my $commit_ids_log;
+    
+    if ($git_cherry) {
+        $commit_ids_log = generate_git_cherry_ids_log($pdata, $repo_dir, $piece, $branch_name, $git_args);
+        $cmd .= " cat $commit_ids_log | xargs -n 1 $git_command -1";
+    } else {
+        $cmd .= " $git_command $git_args";
+    }
 
-    my $cmd = "cd $repo_dir; $git_command";
     my $commit_id;
     my $summary;
 
@@ -149,6 +192,7 @@ sub load_git_log($$$$$)
     }
 
     close GIT;
+    unlink $commit_ids_log if ($git_cherry);
 }
 
 sub get_repo_name($)
@@ -170,9 +214,9 @@ sub get_repo_name($)
     die "Error: can't find repo name in \"$$repo_dir/.git/config\"\n";
 }
 
-sub load_data($$$$$)
+sub load_data($$$$$$$)
 {
-    my ($pdata, $top_dir, $piece, $branch_name, $git_command) = @_;
+    my ($pdata, $top_dir, $piece, $branch_name, $git_command, $git_cherry, $git_args) = @_;
 
     if (defined $piece) {
         my $piece_dir;
@@ -181,11 +225,11 @@ sub load_data($$$$$)
         } else {
             $piece_dir = "$top_dir/clone/$piece";
         }
-        load_git_log($pdata, $piece_dir, $piece, $branch_name, $git_command);
+        load_git_log($pdata, $piece_dir, $piece, $branch_name, $git_command, $git_cherry, $git_args);
     } else {
-        load_git_log($pdata, $top_dir, $main_repo, $branch_name, $git_command);
-        foreach my $piece (@pieces) {
-            load_git_log($pdata, "$top_dir/clone/$piece", $piece, $branch_name, $git_command);
+        load_git_log($pdata, $top_dir, $main_repo, $branch_name, $git_command, $git_cherry, $git_args);
+        foreach my $piece (sort { $a cmp $b } @pieces) {
+            load_git_log($pdata, "$top_dir/clone/$piece", $piece, $branch_name, $git_command, $git_cherry, $git_args);
         }
     }
 }
@@ -420,13 +464,17 @@ sub usage()
           "     --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\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";
 }
 
 
@@ -446,8 +494,9 @@ my $log_suffix;
 my $log;
 my $branch_name;
 my $git_command = "git log";
+my $git_cherry;
+my $git_args = "";
 my $branch_name;
-my @git_args;
 my %data;
 my $print_mode = "normal";
 
@@ -482,11 +531,14 @@ foreach my $arg (@ARGV) {
         $generate_log{"bugs-numbers"} = 1;
     } elsif ($arg eq '--rev-list') {
         $git_command = "git rev-list --pretty=medium"
+    } elsif ($arg eq '--cherry') {
+        $git_command = "git log";
+        $git_cherry = 1;
     } else {
         if (! defined $top_dir) {
             $top_dir=$arg;
         } else {
-            push @git_args, $arg;
+            $git_args .= " $arg";
         }
     }
 }
@@ -496,8 +548,6 @@ 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";
 (-d "$top_dir") || die "Error: not a directory: $top_dir\n";
 (-f "$top_dir/.git/config") || die "Error: can't find $top_dir/.git/config\n";
@@ -508,7 +558,7 @@ $git_command .= " " . join ' ', @git_args if (@git_args);
 
 $branch_name = get_branch_name($top_dir);
 
-load_data(\%data, $top_dir, $piece, $branch_name, $git_command);
+load_data(\%data, $top_dir, $piece, $branch_name, $git_command, $git_cherry, $git_args);
 
 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"});
commit c0b41c84d28577581b2dcfb9ada80525919b6ce7
Author: Petr Mladek <pmladek at suse.cz>
Date:   Tue Nov 20 16:10:58 2012 +0100

    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

diff --git a/bin/lo-commit-stat b/bin/lo-commit-stat
index 4135b8b..6da5285 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"});
commit 5a0f9579eaab6489ced0cf4350d599970f2a12bb
Author: Thorsten Behrens <tbehrens at suse.com>
Date:   Thu Jul 12 01:32:55 2012 +0200

    Make commit stat script recognize opensuse fate entries, too
    
    Change-Id: Ia6b3e6459c5bda7ea24091024cf3dabd19746237
    Signed-off-by: Petr Mladek <pmladek at suse.cz>

diff --git a/bin/lo-commit-stat b/bin/lo-commit-stat
index 4fb8a10..4135b8b 100755
--- a/bin/lo-commit-stat
+++ b/bin/lo-commit-stat
@@ -11,10 +11,11 @@ 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/",
+    fdo  => "https://bugs.freedesktop.org/show_bug.cgi?id=",
+    bnc  => "https://bugzilla.novell.com/show_bug.cgi?id=",
+    rhbz => "https://bugzilla.redhat.com/show_bug.cgi?id=",
+    i    => "https://issues.apache.org/ooo/show_bug.cgi?id=",
+    fate => "https://features.opensuse.org/",
 );
 
 sub search_bugs($$$$)
@@ -305,7 +306,7 @@ sub get_bug_name($$)
     my $bug_number = $2;          # 12345
 
     if ( $bugzillas{$bugzilla} ) {
-        my $url = $bugzillas{$bugzilla} . "show_bug.cgi?id=" . $bug_number;
+        my $url = $bugzillas{$bugzilla} . $bug_number;
         my $ua = LWP::UserAgent->new;
         $ua->timeout(10);
         $ua->env_proxy;
commit 8bf69de83fb1961bc9b5ed56461bb62106b57f9e
Author: Thorsten Behrens <tbehrens at suse.com>
Date:   Sat Jun 23 16:08:10 2012 +0200

    Slightly more robust removal of bug title prefix.
    
    Change-Id: Ic37589222831d03ec48689a077b1eb16a9199385
    Signed-off-by: Petr Mladek <pmladek at suse.cz>

diff --git a/bin/lo-commit-stat b/bin/lo-commit-stat
index d2b6d85..4fb8a10 100755
--- a/bin/lo-commit-stat
+++ b/bin/lo-commit-stat
@@ -312,11 +312,11 @@ sub get_bug_name($$)
         my $response = $ua->get($url);
         if ($response->is_success) {
             my $title = $response->title;
-            if ( $title =~ s/^Bug \d+ – // ) {
+            if ( $title =~ s/^Bug \d+ \S+ // ) {
                 print "$title\n";
                 return $title;
             } else {
-                print "warning: not found; using commit message\n";
+                print "warning: not found; using commit message (only got $title)\n";
             }
         } else {
             print "\n";


More information about the Libreoffice-commits mailing list