blob: 9d2fb9bb288a47b71dcad954d3a43083dd0492bc [file] [log] [blame]
a13460545458e6b2021-08-21 10:57:11 +00001#!/usr/bin/env perl
Daniel Stenberg70d8ac62018-12-11 15:06:21 +01002#***************************************************************************
3# _ _ ____ _
4# Project ___| | | | _ \| |
5# / __| | | | |_) | |
6# | (__| |_| | _ <| |___
7# \___|\___/|_| \_\_____|
8#
Daniel Stenberg2bc1d772023-01-02 13:51:48 +01009# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
Daniel Stenberg70d8ac62018-12-11 15:06:21 +010010#
11# This software is licensed as described in the file COPYING, which
12# you should have received as part of this distribution. The terms
Daniel Stenberg4d2f8002020-11-04 14:02:01 +010013# are also available at https://curl.se/docs/copyright.html.
Daniel Stenberg70d8ac62018-12-11 15:06:21 +010014#
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#
max.mehlad9bc592022-05-17 11:16:50 +020022# SPDX-License-Identifier: curl
23#
Daniel Stenberg70d8ac62018-12-11 15:06:21 +010024###########################################################################
25
Daniel Gustafssona92e9f52019-03-31 22:39:29 +020026# Display changes done in the repository from [tag] until now.
Daniel Stenberg70d8ac62018-12-11 15:06:21 +010027#
28# Uses git for repo data.
29# Uses docs/THANKS and RELEASE-NOTES for current status.
30#
31# In the git clone root, invoke 'scripts/delta [release tag]'
32
33$start = $ARGV[0];
34
Daniel Stenberg5296abe2020-02-05 07:48:18 +010035if($start eq "-h") {
Daniel Stenberg70d8ac62018-12-11 15:06:21 +010036 print "Usage: summary [tag]\n";
37 exit;
38}
Daniel Stenberg5296abe2020-02-05 07:48:18 +010039elsif($start eq "") {
Daniel Stenberg4608fa42020-08-27 14:25:24 +020040 $start = `git tag --sort=taggerdate | grep "^curl-" | tail -1`;
Daniel Stenberg5296abe2020-02-05 07:48:18 +010041 chomp $start;
42}
Daniel Stenberg70d8ac62018-12-11 15:06:21 +010043
44$commits = `git log --oneline $start.. | wc -l`;
45$committers = `git shortlog -s $start.. | wc -l`;
46$bcommitters = `git shortlog -s $start | wc -l`;
47
48$acommits = `git log --oneline | wc -l`;
49$acommitters = `git shortlog -s | wc -l`;
50
51# delta from now compared to before
52$ncommitters = $acommitters - $bcommitters;
53
Daniel Stenberg5296abe2020-02-05 07:48:18 +010054# number of contributors right now
55$acontribs = `./scripts/contrithanks.sh | grep -c '^[^ ]'`;
Daniel Stenberg70d8ac62018-12-11 15:06:21 +010056# number when the tag tag was set
57$bcontribs = `git show $start:docs/THANKS | grep -c '^[^ ]'`;
58# delta
59$contribs = $acontribs - $bcontribs;
60
61# number of setops:
Daniel Stenberg709aefc2022-11-17 14:41:04 +010062sub setopts {
63 my ($f)=@_;
64 open(H, "$f");
65 my $opts;
66 while(<H>) {
67 if(/^ CURLOPT(|DEPRECATED)\(/ && ($_ !~ /OBSOLETE/)) {
68 $opts++;
69 }
70 }
71 close(H);
72 return $opts;
73}
74$asetopts = setopts("<include/curl/curl.h");
75$bsetopts = setopts("git show $start:include/curl/curl.h|");
Daniel Stenberg70d8ac62018-12-11 15:06:21 +010076$nsetopts = $asetopts - $bsetopts;
77
78# Number of command line options:
Daniel Stenberg8bb5f4d2021-10-01 08:49:12 +020079$aoptions=`grep -c '{"....--' src/tool_listhelp.c`;
Daniel Stenberg343644f2021-10-02 23:36:00 +020080$boptions=`git show $start:src/tool_listhelp.c 2>/dev/null | grep -c '{"....--'`;
Daniel Stenberg70d8ac62018-12-11 15:06:21 +010081$noptions=$aoptions - $boptions;
82
Daniel Stenberg5ad50072022-02-03 23:42:02 +010083# current local branch
84$branch=`git rev-parse --abbrev-ref HEAD 2>/dev/null`;
85chomp $branch;
Daniel Stenberg70d8ac62018-12-11 15:06:21 +010086# Number of files in git
87$afiles=`git ls-files | wc -l`;
Daniel Stenberg5ad50072022-02-03 23:42:02 +010088$deletes=`git diff-tree --diff-filter=A -r --summary origin/$branch $start | wc -l`;
89$creates=`git diff-tree --diff-filter=D -r --summary origin/$branch $start | wc -l`;
Daniel Stenberg70d8ac62018-12-11 15:06:21 +010090
91# Time since that tag
92$tagged=`git for-each-ref --format="%(refname:short) | %(taggerdate:unix)" refs/tags/* | grep ^$start | cut "-d|" -f2`; # unix timestamp
93$taggednice=`git for-each-ref --format="%(refname:short) | %(creatordate)" refs/tags/* | grep ^$start | cut '-d|' -f2`; # human readable time
94chomp $taggednice;
95$now=`date +%s`;
96$elapsed=$now - $tagged; # number of seconds since tag
Daniel Stenbergf4dc08a2021-05-06 10:00:36 +020097$total=$now - `date -d 19980320 +%s`;
Daniel Stenberg70d8ac62018-12-11 15:06:21 +010098
99# Number of public functions in libcurl
100$apublic=`git grep ^CURL_EXTERN -- include/curl | wc -l`;
101$bpublic=`git grep ^CURL_EXTERN $start -- include/curl | wc -l`;
102$public = $apublic - $bpublic;
103
Daniel Stenbergb4d86d32020-09-03 08:18:32 +0200104# diffstat
105$diffstat=`git diff --stat $start.. | tail -1`;
Daniel Stenberg5ad50072022-02-03 23:42:02 +0100106if($diffstat =~ /^ *(\d+) files changed, (\d+) insertions\(\+\), (\d+)/) {
107 ($fileschanged, $insertions, $deletions)=($1, $2, $3);
108}
Daniel Stenbergb4d86d32020-09-03 08:18:32 +0200109
Daniel Gustafssona92e9f52019-03-31 22:39:29 +0200110# Changes/bug-fixes currently logged
Daniel Stenberg70d8ac62018-12-11 15:06:21 +0100111open(F, "<RELEASE-NOTES");
112while(<F>) {
113 if($_ =~ /following changes:/) {
114 $mode=1;
115 }
116 elsif($_ =~ /following bugfixes:/) {
117 $mode=2;
118 }
119 elsif($_ =~ /known bugs:/) {
120 $mode=3;
121 }
122 elsif($_ =~ /like these:/) {
123 $mode=4;
124 }
125 if($_ =~ /^ o /) {
126 if($mode == 1) {
127 $numchanges++;
128 }
129 elsif($mode == 2) {
130 $numbugfixes++;
131 }
132 }
133 if(($mode == 4) && ($_ =~ /^ \((\d+) contributors/)) {
134 $numcontributors = $1;
135 }
136}
137close(F);
138
139########################################################################
140# Produce the summary
141
Daniel Stenbergb4d86d32020-09-03 08:18:32 +0200142print "== Since $start $taggednice ==\n";
Daniel Stenbergf4dc08a2021-05-06 10:00:36 +0200143printf "Elapsed time: %.1f days (total %d)\n",
144 $elapsed / 3600 / 24,
145 $total / 3600 / 24;
146printf "Commits: %d (total %d)\n",
Daniel Stenberg70d8ac62018-12-11 15:06:21 +0100147 $commits, $acommits;
Daniel Stenbergb4d86d32020-09-03 08:18:32 +0200148printf "Commit authors: %d, %d new (total %d)\n",
Daniel Stenberg70d8ac62018-12-11 15:06:21 +0100149 $committers, $ncommitters, $acommitters;
Daniel Stenbergb4d86d32020-09-03 08:18:32 +0200150printf "Contributors: %d, %d new (total %d)\n",
151 $numcontributors, $contribs, $acontribs;
152printf "New public functions: %d (total %d)\n",
153 $public, $apublic;
154printf "New curl_easy_setopt() options: %d (total %d)\n",
Daniel Stenberg70d8ac62018-12-11 15:06:21 +0100155 $nsetopts, $asetopts;
Daniel Stenbergb4d86d32020-09-03 08:18:32 +0200156printf "New command line options: %d (total %d)\n",
Daniel Stenberg70d8ac62018-12-11 15:06:21 +0100157 $noptions, $aoptions;
Daniel Stenbergb4d86d32020-09-03 08:18:32 +0200158printf "Changes logged: %d\n", $numchanges;
159printf "Bugfixes logged: %d\n", $numbugfixes;
Daniel Stenberg5ad50072022-02-03 23:42:02 +0100160printf "Added files: %d (total %d)\n",
161 $creates, $afiles;
162printf "Deleted files: %d (delta: %d)\n", $deletes,
163 $creates - $deletes;
164print "Diffstat:$diffstat" if(!$fileschanged);
165printf "Files changed: %d\n", $fileschanged;
166printf "Lines inserted: %d\n", $insertions;
167printf "Lines deleted: %d (delta: %d)\n", $deletions,
168 $insertions - $deletions;