log2changes.pl 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #!/usr/bin/perl
  2. # git log --pretty=fuller --no-color --date=short --decorate=full
  3. my @mname = ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
  4. 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' );
  5. sub nicedate {
  6. my ($date)=$_;
  7. if($date =~ /(\d\d\d\d)-(\d\d)-(\d\d)/) {
  8. return sprintf("%d %s %4d", $3, $mname[$2-1], $1);
  9. }
  10. return $date;
  11. }
  12. print
  13. ' _ _ ____ _
  14. ___| | | | _ \| |
  15. / __| | | | |_) | |
  16. | (__| |_| | _ <| |___
  17. \___|\___/|_| \_\_____|
  18. Changelog
  19. ';
  20. my $line;
  21. my $tag;
  22. while(<STDIN>) {
  23. my $l = $_;
  24. if($l =~/^commit ([[:xdigit:]]*) ?(.*)/) {
  25. $co = $1;
  26. my $ref = $2;
  27. if ($ref =~ /refs\/tags\/curl-([0-9_]*)/) {
  28. $tag = $1;
  29. $tag =~ tr/_/./;
  30. } else {
  31. $tag = '';
  32. }
  33. }
  34. elsif($l =~ /^Author: *(.*) +</) {
  35. $a = $1;
  36. }
  37. elsif($l =~ /^Commit: *(.*) +</) {
  38. $c = $1;
  39. }
  40. elsif($l =~ /^CommitDate: (.*)/) {
  41. $date = nicedate($1);
  42. }
  43. elsif($l =~ /^( )(.*)/) {
  44. my $extra;
  45. if ($tag) {
  46. # Version entries have a special format
  47. print "\nVersion " . $tag." ($date)\n";
  48. $oldc = "";
  49. }
  50. if($a ne $c) {
  51. $extra=sprintf("\n- [%s brought this change]\n\n ", $a);
  52. }
  53. else {
  54. $extra="\n- ";
  55. }
  56. if($co ne $oldco) {
  57. if($c ne $oldc) {
  58. print "\n$c ($date)$extra";
  59. }
  60. else {
  61. print "$extra";
  62. }
  63. $line =0;
  64. }
  65. $oldco = $co;
  66. $oldc = $c;
  67. $olddate = $date;
  68. if($line++) {
  69. print " ";
  70. }
  71. print $2."\n";
  72. }
  73. }