Browse Source

Add script to create ChangeLog for Emacs

Carsten Dominik 14 years ago
parent
commit
a11ee296f5
1 changed files with 50 additions and 0 deletions
  1. 50 0
      UTILITIES/make_emacs_changelog

+ 50 - 0
UTILITIES/make_emacs_changelog

@@ -0,0 +1,50 @@
+#!/usr/bin/perl
+
+$commitrange = shift @ARGV;
+if (!$commitrange) {
+  print STDERR "Enter commitrange: ";
+  $commitrange = <>;
+  $commitrange =~ s/\s*(.*?)\s+/$1/;
+}
+
+$syncdate = shift @ARGV;
+if (!$syncdate) {
+  print STDERR "Enter syncdate YYYY-MM-DD: ";
+  $syncdate = <>;
+  $syncdate =~ s/\s*(.*?)\s+/$1/;
+}
+
+# Run git log to get the commits the messages
+open IN,"git log $commitrange|";
+undef $/;
+$log = <IN>;
+@commits = split(/^(?=commit)/m,$log);
+
+for $i (0..$#commits) {
+  $entry = 0; $tiny = 0;
+  $commit = $commits[$i];
+  $author = $1 if $commit=~/^Author: ([^\n]+)/m;
+  $date   = $1 if $commit=~/^Date: ([^\n]+)/m;
+  $entry  = $1 if $commit=~/^([ \t]*\* [^\f]*?)(\n[ \t]*\n|\Z)/m;
+  $tiny   = "  (tiny change)" if $commit =~ /TINYCHANGE/;
+
+  # split author into name and address
+  if ($author =~ /(.*?)\s+(<.*?>)/) {
+    $name = $1;
+    $address = $2;
+  } else {
+    warn "No name/address";
+    next;
+  }
+
+  if ($entry) {
+    # indent each line by 1 TAB
+    $entry =~ s/^[ \t]*/\t/gm;
+    # Add empty lines if there are several files in there
+    $entry =~ s/(\n[ \t]+\* )/\n$1/g;
+    # remove the lisp part of the path
+    $entry =~ s/^([ \t]+\* )lisp\//$1/mg;
+    print "$syncdate  $name  $address\n\n$entry\n\n";
+  }
+}
+