log2changes.pl 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. #!/usr/bin/env perl
  2. #***************************************************************************
  3. # _ _ ____ _
  4. # Project ___| | | | _ \| |
  5. # / __| | | | |_) | |
  6. # | (__| |_| | _ <| |___
  7. # \___|\___/|_| \_\_____|
  8. #
  9. # Copyright (C) 1998 - 2022, 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.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. # SPDX-License-Identifier: curl
  23. #
  24. ###########################################################################
  25. # git log --pretty=fuller --no-color --date=short --decorate=full
  26. my @mname = ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
  27. 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' );
  28. sub nicedate {
  29. my ($date)=$_;
  30. if($date =~ /(\d\d\d\d)-(\d\d)-(\d\d)/) {
  31. return sprintf("%d %s %4d", $3, $mname[$2-1], $1);
  32. }
  33. return $date;
  34. }
  35. print
  36. ' _ _ ____ _
  37. ___| | | | _ \| |
  38. / __| | | | |_) | |
  39. | (__| |_| | _ <| |___
  40. \___|\___/|_| \_\_____|
  41. Changelog
  42. ';
  43. my $line;
  44. my $tag;
  45. while(<STDIN>) {
  46. my $l = $_;
  47. if($l =~/^commit ([[:xdigit:]]*) ?(.*)/) {
  48. $co = $1;
  49. my $ref = $2;
  50. if ($ref =~ /refs\/tags\/curl-([0-9_]*)/) {
  51. $tag = $1;
  52. $tag =~ tr/_/./;
  53. }
  54. }
  55. elsif($l =~ /^Author: *(.*) +</) {
  56. $a = $1;
  57. }
  58. elsif($l =~ /^Commit: *(.*) +</) {
  59. $c = $1;
  60. }
  61. elsif($l =~ /^CommitDate: (.*)/) {
  62. $date = nicedate($1);
  63. }
  64. elsif($l =~ /^( )(.*)/) {
  65. my $extra;
  66. if ($tag) {
  67. # Version entries have a special format
  68. print "\nVersion " . $tag." ($date)\n";
  69. $oldc = "";
  70. $tag = "";
  71. }
  72. if($a ne $c) {
  73. $extra=sprintf("\n- [%s brought this change]\n\n ", $a);
  74. }
  75. else {
  76. $extra="\n- ";
  77. }
  78. if($co ne $oldco) {
  79. if($c ne $oldc) {
  80. print "\n$c ($date)$extra";
  81. }
  82. else {
  83. print "$extra";
  84. }
  85. $line =0;
  86. }
  87. $oldco = $co;
  88. $oldc = $c;
  89. $olddate = $date;
  90. if($line++ && $2 ne "") {
  91. print " ";
  92. }
  93. print $2."\n";
  94. }
  95. }