delta 5.4 KB

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