summaryrefslogtreecommitdiff
path: root/localsvnlog2cl
blob: bf4ff4479aed277d46b174226d8021f73474b8a1 (plain)
  1. #!/usr/bin/perl -w
  2. # Origin: /usr/share/doc/subversion/examples/gnuify-changelog.pl.gz
  3. # a script to munge the output of 'svn log' into something approaching the
  4. # style of a GNU ChangeLog.
  5. #
  6. # to use this, just fill in the 'hackers' hash with the usernames and
  7. # name/emails of the people who work on your project, go to the top level
  8. # of your working copy, and run:
  9. #
  10. # $ svn log | /path/to/gnuify-changelog.pl > ChangeLog
  11. require 5.0;
  12. use strict;
  13. my %hackers = (
  14. # "jonas" => 'Jonas Smedegaard <dr@jones.dk>',
  15. );
  16. my $parse_next_line = 0;
  17. my $last_line_empty = 0;
  18. my $last_rev = "";
  19. while (my $entry = <>) {
  20. # Axe windows style line endings, since we should try to be consistent, and
  21. # the repos has both styles in its log entries
  22. $entry =~ s/\r\n$/\n/;
  23. # Remove trailing whitespace
  24. $entry =~ s/\s+$/\n/;
  25. my $this_line_empty = $entry eq "\n";
  26. # Avoid duplicate empty lines
  27. next if $this_line_empty and $last_line_empty;
  28. # Don't fail on valid dash-only lines
  29. if ($entry =~ /^-+$/ and length($entry) >= 72) {
  30. # We're at the start of a log entry, so we need to parse the next line
  31. $parse_next_line = 1;
  32. # Check to see if the final line of the commit message was blank,
  33. # if not insert one
  34. print "\n" if $last_rev ne "" and !$last_line_empty;
  35. } elsif ($parse_next_line) {
  36. # Transform from svn style to GNU style
  37. $parse_next_line = 0;
  38. my @parts = split (/ /, $entry);
  39. $last_rev = $parts[0];
  40. my $hacker = $parts[2];
  41. my $tstamp = $parts[4];
  42. # Use alias if we can't resolve to name, email
  43. $hacker = $hackers{$hacker} if defined $hackers{$hacker};
  44. printf "%s %s\n", $tstamp, $hacker;
  45. } elsif ($this_line_empty) {
  46. print "\n";
  47. } else {
  48. print "\t$entry";
  49. }
  50. $last_line_empty = $this_line_empty;
  51. }
  52. # As a HERE doc so it also sets the final changelog's coding
  53. print <<LOCAL;
  54. ;; Local Variables:
  55. ;; coding: utf-8
  56. ;; End:
  57. LOCAL
  58. 1;