2
0

delta 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. #!/usr/bin/env perl
  2. #***************************************************************************
  3. # _ _ ____ _
  4. # Project ___| | | | _ \| |
  5. # / __| | | | |_) | |
  6. # | (__| |_| | _ <| |___
  7. # \___|\___/|_| \_\_____|
  8. #
  9. # Copyright (C) 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 was set
  50. $bcontribs = `git show $start:docs/THANKS | grep -c '^[^ ]'`;
  51. # delta
  52. $contribs = $acontribs - $bcontribs;
  53. # number of setops:
  54. sub setopts {
  55. my ($f)=@_;
  56. open(H, "$f");
  57. my $opts;
  58. while(<H>) {
  59. if(/^ CURLOPT(|DEPRECATED)\(/ && ($_ !~ /OBSOLETE/)) {
  60. $opts++;
  61. }
  62. }
  63. close(H);
  64. return $opts;
  65. }
  66. $asetopts = setopts("<include/curl/curl.h");
  67. $bsetopts = setopts("git show $start:include/curl/curl.h|");
  68. $nsetopts = $asetopts - $bsetopts;
  69. # Number of command line options:
  70. $aoptions=`grep -c '{"....--' src/tool_listhelp.c`;
  71. $boptions=`git show $start:src/tool_listhelp.c 2>/dev/null | grep -c '{"....--'`;
  72. $noptions=$aoptions - $boptions;
  73. # current local branch
  74. $branch=`git rev-parse --abbrev-ref HEAD 2>/dev/null`;
  75. chomp $branch;
  76. # Number of files in git
  77. $afiles=`git ls-files | wc -l`;
  78. $deletes=`git diff-tree --diff-filter=A -r --summary origin/$branch $start 2>/dev/null | wc -l`;
  79. $creates=`git diff-tree --diff-filter=D -r --summary origin/$branch $start 2>/dev/null| wc -l`;
  80. # Time since that tag
  81. $tagged=`git for-each-ref --format="%(refname:short) | %(taggerdate:unix)" refs/tags/* | grep ^$start | cut "-d|" -f2`; # unix timestamp
  82. $taggednice=`git for-each-ref --format="%(refname:short) | %(creatordate)" refs/tags/* | grep ^$start | cut '-d|' -f2`; # human readable time
  83. chomp $taggednice;
  84. $now=`date +%s`;
  85. $elapsed=$now - $tagged; # number of seconds since tag
  86. $total=$now - `date -d 19980320 +%s`;
  87. # Number of public functions in libcurl
  88. $apublic=`git grep ^CURL_EXTERN -- include/curl | wc -l`;
  89. $bpublic=`git grep ^CURL_EXTERN $start -- include/curl | wc -l`;
  90. $public = $apublic - $bpublic;
  91. # diffstat
  92. $diffstat=`git diff --stat $start.. | tail -1`;
  93. if($diffstat =~ /^ *(\d+) files changed, (\d+) insertions\(\+\), (\d+)/) {
  94. ($fileschanged, $insertions, $deletions)=($1, $2, $3);
  95. }
  96. # Changes/bug-fixes currently logged
  97. open(F, "<RELEASE-NOTES");
  98. while(<F>) {
  99. if($_ =~ /following changes:/) {
  100. $mode=1;
  101. }
  102. elsif($_ =~ /following bugfixes:/) {
  103. $mode=2;
  104. }
  105. elsif($_ =~ /known bugs:/) {
  106. $mode=3;
  107. }
  108. elsif($_ =~ /like these:/) {
  109. $mode=4;
  110. }
  111. if($_ =~ /^ o /) {
  112. if($mode == 1) {
  113. $numchanges++;
  114. }
  115. elsif($mode == 2) {
  116. $numbugfixes++;
  117. }
  118. }
  119. if(($mode == 4) && ($_ =~ /^ \((\d+) contributors/)) {
  120. $numcontributors = $1;
  121. }
  122. }
  123. close(F);
  124. ########################################################################
  125. # Produce the summary
  126. print "== Since $start $taggednice ==\n";
  127. printf "Elapsed time: %.1f days (total %d)\n",
  128. $elapsed / 3600 / 24,
  129. $total / 3600 / 24;
  130. printf "Commits: %d (total %d)\n",
  131. $commits, $acommits;
  132. printf "Commit authors: %d, %d new (total %d)\n",
  133. $committers, $ncommitters, $acommitters;
  134. printf "Contributors: %d, %d new (total %d)\n",
  135. $numcontributors, $contribs, $acontribs;
  136. printf "New public functions: %d (total %d)\n",
  137. $public, $apublic;
  138. printf "New curl_easy_setopt() options: %d (total %d)\n",
  139. $nsetopts, $asetopts;
  140. printf "New command line options: %d (total %d)\n",
  141. $noptions, $aoptions;
  142. printf "Changes logged: %d\n", $numchanges;
  143. printf "Bugfixes logged: %d\n", $numbugfixes;
  144. printf "Added files: %d (total %d)\n",
  145. $creates, $afiles;
  146. printf "Deleted files: %d (delta: %d)\n", $deletes,
  147. $creates - $deletes;
  148. print "Diffstat:$diffstat" if(!$fileschanged);
  149. printf "Files changed: %d (%.2f%%)\n", $fileschanged, $fileschanged*100/$afiles;
  150. printf "Lines inserted: %d\n", $insertions;
  151. printf "Lines deleted: %d (delta: %d)\n", $deletions,
  152. $insertions - $deletions;