#!/usr/bin/perl -w
-open GNUPLOT, "|gnuplot -persist";
+use Getopt::Std;
+
+my ($opt_l);
+&getopts("l");
+
+open GNUPLOT, "|gnuplot";
+$data = "/tmp/commit-graph-$$.dat";
+print "Using file $data\n";
+open DATA, ">$data";
+use FileHandle;
+GNUPLOT->autoflush(1);
print GNUPLOT <<EOF;
set xdata time
set timefmt "%s"
set format x "%m/%y"
set xlabel "Date"
-set ylabel "Commit number"
set grid
set key left top
EOF
%authors = ('Michal' => 'sojka',
- 'Martin' => '\(zidek\|mzi\)',
+ 'Martin' => '\(zidek\|mzi\|martin-eee\|martin-nb2\)',
'Filip' => 'jares',
'Jarda' => 'jarin',
'Jirka' => '\(jirka\|kubia\)',
- 'Marek' => 'marek',
+ 'Marek' => '\(marek\|duch\)',
'Petr' => 'benes',
"Celkem" => '.');
-@plots = ();
-foreach $author(sort keys %authors) {
- push @plots, qq/'-' using 1:2 with linespoints title "$author"/;
-}
-print GNUPLOT "plot ", join(", ", @plots), ";\n";
+
foreach $author(sort keys %authors) {
- @commits = `git log ace04654c8f2e11077c12ccf48d09fbb3bec28f3..HEAD --pretty=format:"%ct" --author='$authors{$author}'|sort -n`;
- $i = 1;
- foreach (@commits) {
- chop;
- print GNUPLOT "$_ $i\n";
- $i++;
+ $cmd = qq/git log --pretty=format:"commit %ct %s" --author='$authors{$author}' --no-merges --reverse --numstat @ARGV/;
+ print "$cmd\n";
+ @log = `$cmd`;
+ $num_commits = 0;
+ $added_lines = 0;
+ foreach (@log) {
+ chomp;
+ if (/^commit (\d+)/) { $time=$1; $num_commits++; }
+ elsif (/(\d+)\s+(\d+)/) {
+ $added_lines += $1;
+ } elsif (!$_) {
+ print DATA "$time $num_commits $added_lines\n";
+ }
}
- print GNUPLOT "e\n";
+ print DATA "\n\n";
+}
+
+if (!$opt_l) {
+ @plots = ();
+ $i=0;
+ foreach $author(sort keys %authors) {
+ push @plots, qq/"$data" index $i using 1:2 with linespoints title "$author"/;
+ $i++;
+ }
+ print GNUPLOT "set ylabel \"Number of commits\"\n";
+ print GNUPLOT "plot ", join(", ", @plots), ";\n";
+} else {
+ @plots = ();
+ $i=0;
+ foreach $author(sort keys %authors) {
+ push @plots, qq/"$data" index $i using 1:3 with linespoints title "$author"/;
+ $i++;
+ }
+ print GNUPLOT "set ylabel \"Added lines\"\n";
+ # print GNUPLOT "set logscale y\n";
+ print GNUPLOT "plot ", join(", ", @plots), ";\n";
}
-# set xdata time
-# set timefmt "%m/%d/%y"
-# set xrange ["03/21/95":"03/22/95"]
-# set format x "%m/%d"
-# set timefmt "%m/%d/%y %H:%M"
-# plot "data" using 1:3