log2changes.pl 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. }
  31. }
  32. elsif($l =~ /^Author: *(.*) +</) {
  33. $a = $1;
  34. }
  35. elsif($l =~ /^Commit: *(.*) +</) {
  36. $c = $1;
  37. }
  38. elsif($l =~ /^CommitDate: (.*)/) {
  39. $date = nicedate($1);
  40. }
  41. elsif($l =~ /^( )(.*)/) {
  42. my $extra;
  43. if ($tag) {
  44. # Version entries have a special format
  45. print "\nVersion " . $tag." ($date)\n";
  46. $oldc = "";
  47. $tag = "";
  48. }
  49. if($a ne $c) {
  50. $extra=sprintf("\n- [%s brought this change]\n\n ", $a);
  51. }
  52. else {
  53. $extra="\n- ";
  54. }
  55. if($co ne $oldco) {
  56. if($c ne $oldc) {
  57. print "\n$c ($date)$extra";
  58. }
  59. else {
  60. print "$extra";
  61. }
  62. $line =0;
  63. }
  64. $oldco = $co;
  65. $oldc = $c;
  66. $olddate = $date;
  67. if($line++) {
  68. print " ";
  69. }
  70. print $2."\n";
  71. }
  72. }