]> rtime.felk.cvut.cz Git - eurobot/public.git/blob - build/_infrastructure/commit-graph.pl
Merge branch 'maint-demo'
[eurobot/public.git] / build / _infrastructure / commit-graph.pl
1 #!/usr/bin/perl -w
2
3 use Getopt::Std;
4
5 my ($opt_l);
6 &getopts("l");
7
8 open GNUPLOT, "|gnuplot -persist";
9 $data = "/tmp/commit-graph-$$.dat";
10 print "Using file $data\n";
11 open DATA, ">$data";
12 use FileHandle;
13 GNUPLOT->autoflush(1);
14 print GNUPLOT <<EOF;
15 set xdata time
16 set timefmt "%s"
17 set format x "%y/%m/%d" 
18 set xlabel "Date"
19 set grid
20 set key left top
21 EOF
22 %authors = ('Michal S.' => 'sojka',
23             #'Martin' => '\(zidek\|mzi\|martin-eee\|martin-nb2\)',
24             #'Filip'  => 'jares',
25             #'Jarda'  => 'jarin',
26             #'Jirka'  => '\(jirka\|kubia\)',
27             #'Marek'  => '\(marek\|duch\)',
28             #'Petr'   => 'benes',
29             'Matous'  => '\(ehiker\|pokor\)',
30             'Michal V.'  => '\(zandar\|vokac\)',
31             "Celkem" => '.');
32
33 foreach $author(sort keys %authors) {
34         $cmd = qq/git log --pretty=format:"commit %ct %s" --author='$authors{$author}' --no-merges --reverse --numstat @ARGV/;
35         print "$cmd\n";
36         @log = `$cmd`;
37         $num_commits = 0;
38         $added_lines = 0;
39         foreach (@log) {
40             chomp;
41             if (/^commit (\d+)/) { $time=$1; $num_commits++; $printed=0; }
42             elsif (/(\d+)\s+(\d+)/) {
43                 $added_lines += $1;
44             } elsif (!$_) {
45                 print DATA "$time $num_commits $added_lines\n";
46                 $printed=1;
47             }
48         }
49         if ($num_commits > 0) {
50             if (!$printed) {
51                 print DATA "$time $num_commits $added_lines\n";
52             }
53             print DATA "\n\n";
54         } else {
55             delete $authors{$author};
56         }
57 }
58
59 if (!$opt_l) {
60     @plots = ();
61     $i=0;
62     foreach $author(sort keys %authors) {
63         push @plots, qq/"$data" index $i using 1:2 with linespoints title "$author"/;
64         $i++;
65     }
66     print GNUPLOT "set ylabel \"Number of commits\"\n";
67     print GNUPLOT "plot ", join(", ", @plots), ";\n";
68 } else {
69     @plots = ();
70     $i=0;
71     foreach $author(sort keys %authors) {
72         push @plots, qq/"$data" index $i using 1:3 with linespoints title "$author"/;
73         $i++;
74     }
75     print GNUPLOT "set ylabel \"Added lines\"\n";
76     # print GNUPLOT "set logscale y\n";
77     print GNUPLOT "plot ", join(", ", @plots), ";\n";
78 }