make_emacs_changelog 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/usr/bin/perl
  2. $commitrange = shift @ARGV;
  3. if (!$commitrange) {
  4. print STDERR "Enter commitrange: ";
  5. $commitrange = <>;
  6. $commitrange =~ s/\s*(.*?)\s+/$1/;
  7. }
  8. $syncdate = shift @ARGV;
  9. if (!$syncdate) {
  10. print STDERR "Enter syncdate YYYY-MM-DD: ";
  11. $syncdate = <>;
  12. $syncdate =~ s/\s*(.*?)\s+/$1/;
  13. }
  14. # Run git log to get the commits the messages
  15. open IN,"git log $commitrange|";
  16. undef $/;
  17. $log = <IN>;
  18. @commits = split(/^(?=commit)/m,$log);
  19. for $i (0..$#commits) {
  20. $entry = ""; $tiny = "";
  21. $commit = $commits[$i];
  22. $author = $1 if $commit=~/^Author: ([^\n]+)/m;
  23. $date = $1 if $commit=~/^Date: ([^\n]+)/m;
  24. $entry = $1 if $commit=~/^([ \t]*\* [^\f]*?)(\n[ \t]*\n|\Z)/m;
  25. $tiny = " (tiny change)" if $commit =~ /TINYCHANGE/;
  26. # split author into name and address
  27. if ($author =~ /(.*?)\s+(<.*?>)/) {
  28. $name = $1;
  29. $address = $2;
  30. } else {
  31. warn "No name/address";
  32. next;
  33. }
  34. if ($entry) {
  35. # indent each line by 1 TAB
  36. $entry =~ s/^[ \t]*/\t/gm;
  37. # Add empty lines if there are several files in there
  38. $entry =~ s/(\n[ \t]+\* )/\n$1/g;
  39. # remove the lisp part of the path
  40. $entry =~ s/^([ \t]+\* )lisp\//$1/mg;
  41. print "$syncdate $name $address$tiny\n\n$entry\n\n";
  42. }
  43. }