delta 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. #!/usr/bin/env perl
  2. #***************************************************************************
  3. # _ _ ____ _
  4. # Project ___| | | | _ \| |
  5. # / __| | | | |_) | |
  6. # | (__| |_| | _ <| |___
  7. # \___|\___/|_| \_\_____|
  8. #
  9. # Copyright (C) 2018-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. ###########################################################################
  23. # Display changes done in the repository from [tag] until now.
  24. #
  25. # Uses git for repo data.
  26. # Uses docs/THANKS and RELEASE-NOTES for current status.
  27. #
  28. # In the git clone root, invoke 'scripts/delta [release tag]'
  29. $start = $ARGV[0];
  30. if($start eq "-h") {
  31. print "Usage: summary [tag]\n";
  32. exit;
  33. }
  34. elsif($start eq "") {
  35. $start = `git tag --sort=taggerdate | grep "^curl-" | tail -1`;
  36. chomp $start;
  37. }
  38. $commits = `git log --oneline $start.. | wc -l`;
  39. $committers = `git shortlog -s $start.. | wc -l`;
  40. $bcommitters = `git shortlog -s $start | wc -l`;
  41. $acommits = `git log --oneline | wc -l`;
  42. $acommitters = `git shortlog -s | wc -l`;
  43. # delta from now compared to before
  44. $ncommitters = $acommitters - $bcommitters;
  45. # number of contributors right now
  46. $acontribs = `./scripts/contrithanks.sh | grep -c '^[^ ]'`;
  47. # number when the tag tag was set
  48. $bcontribs = `git show $start:docs/THANKS | grep -c '^[^ ]'`;
  49. # delta
  50. $contribs = $acontribs - $bcontribs;
  51. # number of setops:
  52. $asetopts=`grep '^ CURLOPT(' include/curl/curl.h | grep -cv OBSOLETE`;
  53. $bsetopts=`git show $start:include/curl/curl.h | grep '^ CURLOPT(' | grep -cv OBSOLETE`;
  54. $nsetopts = $asetopts - $bsetopts;
  55. # Number of command line options:
  56. $aoptions=`grep -c '{"....--' src/tool_listhelp.c`;
  57. $boptions=`git show $start:src/tool_listhelp.c 2>/dev/null | grep -c '{"....--'`;
  58. $noptions=$aoptions - $boptions;
  59. # current local branch
  60. $branch=`git rev-parse --abbrev-ref HEAD 2>/dev/null`;
  61. chomp $branch;
  62. # Number of files in git
  63. $afiles=`git ls-files | wc -l`;
  64. $deletes=`git diff-tree --diff-filter=A -r --summary origin/$branch $start | wc -l`;
  65. $creates=`git diff-tree --diff-filter=D -r --summary origin/$branch $start | wc -l`;
  66. # Time since that tag
  67. $tagged=`git for-each-ref --format="%(refname:short) | %(taggerdate:unix)" refs/tags/* | grep ^$start | cut "-d|" -f2`; # unix timestamp
  68. $taggednice=`git for-each-ref --format="%(refname:short) | %(creatordate)" refs/tags/* | grep ^$start | cut '-d|' -f2`; # human readable time
  69. chomp $taggednice;
  70. $now=`date +%s`;
  71. $elapsed=$now - $tagged; # number of seconds since tag
  72. $total=$now - `date -d 19980320 +%s`;
  73. # Number of public functions in libcurl
  74. $apublic=`git grep ^CURL_EXTERN -- include/curl | wc -l`;
  75. $bpublic=`git grep ^CURL_EXTERN $start -- include/curl | wc -l`;
  76. $public = $apublic - $bpublic;
  77. # diffstat
  78. $diffstat=`git diff --stat $start.. | tail -1`;
  79. if($diffstat =~ /^ *(\d+) files changed, (\d+) insertions\(\+\), (\d+)/) {
  80. ($fileschanged, $insertions, $deletions)=($1, $2, $3);
  81. }
  82. # Changes/bug-fixes currently logged
  83. open(F, "<RELEASE-NOTES");
  84. while(<F>) {
  85. if($_ =~ /following changes:/) {
  86. $mode=1;
  87. }
  88. elsif($_ =~ /following bugfixes:/) {
  89. $mode=2;
  90. }
  91. elsif($_ =~ /known bugs:/) {
  92. $mode=3;
  93. }
  94. elsif($_ =~ /like these:/) {
  95. $mode=4;
  96. }
  97. if($_ =~ /^ o /) {
  98. if($mode == 1) {
  99. $numchanges++;
  100. }
  101. elsif($mode == 2) {
  102. $numbugfixes++;
  103. }
  104. }
  105. if(($mode == 4) && ($_ =~ /^ \((\d+) contributors/)) {
  106. $numcontributors = $1;
  107. }
  108. }
  109. close(F);
  110. ########################################################################
  111. # Produce the summary
  112. print "== Since $start $taggednice ==\n";
  113. printf "Elapsed time: %.1f days (total %d)\n",
  114. $elapsed / 3600 / 24,
  115. $total / 3600 / 24;
  116. printf "Commits: %d (total %d)\n",
  117. $commits, $acommits;
  118. printf "Commit authors: %d, %d new (total %d)\n",
  119. $committers, $ncommitters, $acommitters;
  120. printf "Contributors: %d, %d new (total %d)\n",
  121. $numcontributors, $contribs, $acontribs;
  122. printf "New public functions: %d (total %d)\n",
  123. $public, $apublic;
  124. printf "New curl_easy_setopt() options: %d (total %d)\n",
  125. $nsetopts, $asetopts;
  126. printf "New command line options: %d (total %d)\n",
  127. $noptions, $aoptions;
  128. printf "Changes logged: %d\n", $numchanges;
  129. printf "Bugfixes logged: %d\n", $numbugfixes;
  130. printf "Added files: %d (total %d)\n",
  131. $creates, $afiles;
  132. printf "Deleted files: %d (delta: %d)\n", $deletes,
  133. $creates - $deletes;
  134. print "Diffstat:$diffstat" if(!$fileschanged);
  135. printf "Files changed: %d\n", $fileschanged;
  136. printf "Lines inserted: %d\n", $insertions;
  137. printf "Lines deleted: %d (delta: %d)\n", $deletions,
  138. $insertions - $deletions;