summaryrefslogtreecommitdiff
path: root/scripts/mkgitlog
diff options
context:
space:
mode:
authorDidier Raboud <odyx@debian.org>2016-09-20 11:56:08 +0200
committerDidier Raboud <odyx@debian.org>2016-09-20 11:56:08 +0200
commit7f5731038556e5b03d2a886163ca2c873c77333d (patch)
tree8f4194af3949a73accf44b2b0bd8ebfa990ac577 /scripts/mkgitlog
parenta313257bdec71bc92a56598e74d9097c16cb6e48 (diff)
New upstream version 5.2.12~pre2
Diffstat (limited to 'scripts/mkgitlog')
-rwxr-xr-xscripts/mkgitlog121
1 files changed, 121 insertions, 0 deletions
diff --git a/scripts/mkgitlog b/scripts/mkgitlog
new file mode 100755
index 0000000..9ad22e5
--- /dev/null
+++ b/scripts/mkgitlog
@@ -0,0 +1,121 @@
+#!/usr/bin/perl
+
+use Getopt::Long;
+
+use strict;
+
+my ($base_file);
+my ($base_revision);
+
+GetOptions("i=s" => \$base_file,
+ "r=s" => \$base_revision);
+
+my ($autline) = "";
+my ($curmsg) = "";
+my ($curtag) = "";
+my (%addlines);
+my (%removelines);
+my (%filechanges);
+my (%files);
+
+my ($state) = 0;
+my ($ostate) = 0;
+my ($firsttime) = 1;
+
+sub print_it {
+ if ($curtag ne "") {
+ print "===============================================================================\n";
+ print "Name: $curtag\n\n"
+ }
+ print "$autline\n";
+ my (@files) = sort keys %files;
+ if ($#files >= 0) {
+ my ($add) = 0;
+ my ($remove) = 0;
+ map { $add += $addlines{$_} } @files;
+ map { $remove += $removelines{$_} } @files;
+ print " Lines: +$add, -$remove\n";
+ print " Files:\n";
+ foreach my $fn (@files) {
+ print " $fn (";
+ if ($filechanges{$fn} eq 'D') {
+ print "removed -$removelines{$fn}";
+ } elsif ($filechanges{$fn} eq 'C') {
+ print "added +$addlines{$fn}";
+ } else {
+ print "+$addlines{$fn}, -$removelines{$fn}";
+ }
+ print ")\n";
+ }
+ print "\n";
+ }
+ print "$curmsg\n";
+ $autline = "";
+ $curmsg = "";
+ $curtag = "";
+ %addlines = ();
+ %removelines = ();
+ %filechanges = ();
+ %files = ();
+}
+
+if ($base_revision) {
+ $base_revision = "'$base_revision..HEAD'";
+}
+
+open(GITLOG, "git log --diff-algorithm=default --summary --numstat --date=short --pretty=format:'>>>GIT1%n%cd <%an> %H%n>>>GIT2%n%B>>>GIT3%n%D%n>>>GIT4' $base_revision|") or die "Can't run git log: $!\n";
+
+while (<GITLOG>) {
+ if (/>>>GIT([0-9]+)$/) {
+ $state = $1;
+ if ($state == 1) {
+ if (! $firsttime) {
+ print_it();
+ }
+ $firsttime = 0;
+ }
+ } elsif ($state == 1) {
+ $autline = $_;
+ } elsif ($state == 2) {
+ if ($_ ne "\n") {
+ $curmsg .= " ";
+ }
+ $curmsg .= $_;
+ } elsif ($state == 3) {
+ if (/^tag: ((guten|gimp-)?print-[0-9]+_.*)/) {
+ $curtag = $1;
+ }
+ } elsif ($state == 4) {
+ if ($_ ne "\n") {
+ chomp;
+ $_ =~ s/^[ ]+//;
+ if (/^delete/) {
+ my ($junk, $junk, $junk, $fn) = split(/ /, $_, 4);
+ $filechanges{$fn} = 'D';
+ } elsif (/^create/) {
+ my ($junk, $junk, $junk, $fn) = split(/ /, $_, 4);
+ $filechanges{$fn} = 'C';
+ } elsif (/^[-0-9]/) {
+ my ($add, $remove, $fn) = split(/ /, $_, 3);
+ $add = 0 if ($add eq '-');
+ $remove = 0 if ($remove eq '-');
+ $files{$fn} = 1;
+ $addlines{$fn} = $add;
+ $removelines{$fn} = $remove;
+ }
+ }
+ } else {
+ die "Unknown state $state\n";
+ }
+}
+
+print_it();
+
+if ($base_file) {
+ open IN, $base_file or die "Can't open baseline file $base_file: $!";
+ while (<IN>) {
+ print;
+ }
+}
+
+exit 0;