log2changes.pl 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. #!/usr/bin/env perl
  2. #***************************************************************************
  3. # _ _ ____ _
  4. # Project ___| | | | _ \| |
  5. # / __| | | | |_) | |
  6. # | (__| |_| | _ <| |___
  7. # \___|\___/|_| \_\_____|
  8. #
  9. # Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
  10. #
  11. # This software is licensed as described in the file COPYING, which
  12. # you should have received as part of this distribution. The terms
  13. # are also available at https://curl.haxx.se/docs/copyright.html.
  14. #
  15. # You may opt to use, copy, modify, merge, publish, distribute and/or sell
  16. # copies of the Software, and permit persons to whom the Software is
  17. # furnished to do so, under the terms of the COPYING file.
  18. #
  19. # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  20. # KIND, either express or implied.
  21. #
  22. ###########################################################################
  23. # git log --pretty=fuller --no-color --date=short --decorate=full
  24. my @mname = ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
  25. 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' );
  26. sub nicedate {
  27. my ($date)=$_;
  28. if($date =~ /(\d\d\d\d)-(\d\d)-(\d\d)/) {
  29. return sprintf("%d %s %4d", $3, $mname[$2-1], $1);
  30. }
  31. return $date;
  32. }
  33. print
  34. ' _ _ ____ _
  35. ___| | | | _ \| |
  36. / __| | | | |_) | |
  37. | (__| |_| | _ <| |___
  38. \___|\___/|_| \_\_____|
  39. Changelog
  40. ';
  41. my $line;
  42. my $tag;
  43. while(<STDIN>) {
  44. my $l = $_;
  45. if($l =~/^commit ([[:xdigit:]]*) ?(.*)/) {
  46. $co = $1;
  47. my $ref = $2;
  48. if ($ref =~ /refs\/tags\/curl-([0-9_]*)/) {
  49. $tag = $1;
  50. $tag =~ tr/_/./;
  51. }
  52. }
  53. elsif($l =~ /^Author: *(.*) +</) {
  54. $a = $1;
  55. }
  56. elsif($l =~ /^Commit: *(.*) +</) {
  57. $c = $1;
  58. }
  59. elsif($l =~ /^CommitDate: (.*)/) {
  60. $date = nicedate($1);
  61. }
  62. elsif($l =~ /^( )(.*)/) {
  63. my $extra;
  64. if ($tag) {
  65. # Version entries have a special format
  66. print "\nVersion " . $tag." ($date)\n";
  67. $oldc = "";
  68. $tag = "";
  69. }
  70. if($a ne $c) {
  71. $extra=sprintf("\n- [%s brought this change]\n\n ", $a);
  72. }
  73. else {
  74. $extra="\n- ";
  75. }
  76. if($co ne $oldco) {
  77. if($c ne $oldc) {
  78. print "\n$c ($date)$extra";
  79. }
  80. else {
  81. print "$extra";
  82. }
  83. $line =0;
  84. }
  85. $oldco = $co;
  86. $oldc = $c;
  87. $olddate = $date;
  88. if($line++) {
  89. print " ";
  90. }
  91. print $2."\n";
  92. }
  93. }