File: release-stats.sh

package info (click to toggle)
gimp 3.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 222,880 kB
  • sloc: ansic: 870,914; python: 10,965; lisp: 10,857; cpp: 7,355; perl: 4,536; sh: 1,753; xml: 972; yacc: 609; lex: 348; javascript: 150; makefile: 42
file content (366 lines) | stat: -rwxr-xr-x 13,733 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
#!/bin/sh
# release-stats.sh
# Copyright (C) 2018-2025 Jehan
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.

############################################
# Script gathering statistics on a release #
############################################

#### Usage ####
printf "GIMP version to release: "; read ver

if [ -z "$ver" ]; then
  TAG="HEAD"
  PREV_TAG=$(git ls-remote --tags --exit-code --refs  "https://gitlab.gnome.org/GNOME/gimp.git" |grep -o "GIMP_[0-9]*_[0-9]*_[0-9]*" | sort --version-sort | tail -1)
  INTERMEDIATE_TAG=$PREV_TAG

  is_dev_release=1
else
  major=$(echo "$ver" | cut -d'.' -f1)
  minor=$(echo "$ver" | cut -d'.' -f2)
  micro_rc=$(echo "$ver" | cut -d'.' -f3)
  echo $micro_rc | grep -- '-'  > /dev/null 2>&1
  if [ $? -eq 0 ]; then
    micro=$(echo "$micro_rc" | cut -d'-' -f1)
    rc=$(echo "$micro_rc" | cut -d'-' -f2)
    TAG=GIMP_${major}_${minor}_${micro}_$rc
    rel_version="${major}.${minor}.${micro} ${rc}"
  else
    micro=$micro_rc
    TAG=GIMP_${major}_${minor}_${micro}
    rel_version="${major}.${minor}.${micro}"
  fi

  git --no-pager show $TAG >/dev/null 2>&1
  if [ $? -ne 0 ]; then
    echo "Tag is unknown: $TAG"
    exit 1
  fi

  is_dev_release=$((minor % 2))

  if [ $((micro % 2)) -ne 0 ]; then
    echo "Releases must have an even micro version."
    exit 1
  fi

  # The previous tag will be in the same branch. For instance 3.0.4 is
  # previous to 3.0.6 even if we may have released 3.1 versions
  # in-between.
  PREV_TAG=$(git ls-remote --tags --exit-code --refs  "https://gitlab.gnome.org/GNOME/gimp.git" |grep -o "GIMP_[0-9]*_[0-9]*_[0-9]*\(_RC[0-9]*\)\?" | sort --version-sort | grep -B1 $TAG | head -1)
  # The intermediate tag is the actual version we released before.
  INTERMEDIATE_TAG=$(git ls-remote --tags --sort=taggerdate --exit-code --refs  "https://gitlab.gnome.org/GNOME/gimp.git" |grep -o "GIMP_[0-9]*_[0-9]*_[0-9]*\(_RC[0-9]*\)\?" | grep -B1 $TAG | head -1)
fi

#if [ $is_dev_release -eq 0 ]; then
  #read -p "Previous stable GIMP version:" ver
#elif [ $micro -eq 0 ];
#else
  #read -p "Previous GIMP version:" ver
#fi

prevmajor=$(echo "$PREV_TAG" | cut -d'_' -f2)
prevminor=$(echo "$PREV_TAG" | cut -d'_' -f3)
prevmicro=$(echo "$PREV_TAG" | cut -d'_' -f4)
prevrc=$(echo "$PREV_TAG" | cut -d'_' -f5)
if [ -z $prevrc ]; then
  prev_version="$prevmajor.$prevminor.$prevmicro"
  prev_uri="$prevmajor.$prevminor.$prevmicro"
else
  prev_version="$prevmajor.$prevminor.$prevmicro $prevrc"
  prev_uri="$prevmajor.$prevminor.$prevmicro-$prevrc"
fi

intmajor=$(echo "$INTERMEDIATE_TAG" | cut -d'_' -f2)
intminor=$(echo "$INTERMEDIATE_TAG" | cut -d'_' -f3)
intmicro=$(echo "$INTERMEDIATE_TAG" | cut -d'_' -f4)
intrc=$(echo "$INTERMEDIATE_TAG" | cut -d'_' -f5)
if [ -z $intrc ]; then
  int_version="$intmajor.$intminor.$intmicro"
else
  int_version="$intmajor.$intminor.$intmicro $intrc"
fi

echo "Previous Release: $prev_version"
if [ "$PREV_TAG" != "$INTERMEDIATE_TAG" ]; then
  echo "Intermediate Release: $int_version"
fi

#if [ $((prevmicro % 2)) -ne 0 ]; then
  #echo "Releases must have an even micro version."
  #exit 1
#fi

#if [ $is_dev_release -eq 0 ]; then
  #if [ $((prevminor % 2)) -ne 0 ]; then
    #echo "$ver is not a stable version."
    #exit 1
  #fi
#fi

prev_date=`git log -1 --format=%ci $PREV_TAG`
int_date=`git log -1 --format=%ci $INTERMEDIATE_TAG`
cur_date=`git log -1 --format=%ci $TAG`

get_issues_mrs()
{
  base_url=$1
  if [ $micro -eq 0 ]; then
    if [ -z $rc ]; then
      version="$major.$minor"
    else
      version="$major.$minor+$rc"
    fi
  else
    version="$major.$minor.$micro"
  fi

  closed_issues=
  merged_mrs=
  milestone=$(curl "$base_url-/milestones?search_title=$version&state=all" 2>/dev/null| grep "/-/milestones/[0-9]" | head -1 | sed 's$^.*/-/milestones/\([0-9]*\)".*$\1$')
  if [ -n "$milestone" ] && [ "$milestone" -eq "$milestone" ] 2>/dev/null; then
    # Milestone exists and is a valid integer.
    closed_issues=$(curl "$base_url-/milestones/$milestone" 2>/dev/null|grep 'issues.*Closed:' -A1 |tail -1)
    merged_mrs=$(curl "$base_url-/milestones/$milestone" 2>/dev/null|grep 'merge_requests.*Merged:' -A1 |tail -1)
  fi

  echo $closed_issues $merged_mrs
}

set -- $(get_issues_mrs "https://gitlab.gnome.org/GNOME/gimp/")
closed_issues=$1
merged_mrs=$2

set -- $(get_issues_mrs "https://gitlab.gnome.org/Teams/GIMP/Design/gimp-ux/")
ux_closed_issues=$1
ux_merged_mrs=$2

if [ -n "$ux_closed_issues" ] || [ "$ux_closed_issues" -eq "$ux_closed_issues" ] 2>/dev/null; then
  : # All good.
else
  echo "Failed to read Gitlab webpages."
  echo "It may be the anti-bot Anubis blocking us."
  echo "Try loading manually: https://gitlab.gnome.org/GNOME/gimp/-/milestones/"
  exit 1
fi

get_latest_from_meson()
{
  dep=$1
  tag=$2
  ver=`git blame $tag -- meson.build | grep "${dep}_minver *=" | sed "s/.*${dep}_minver *= *'\([0-9.]*\)' *$/\1/"`
  echo $ver
}

get_tag_from_version()
{
  prefix=$1
  ver=$2
  tag=`echo $ver | tr . _`
  tag=${prefix}_${tag}
  echo $tag
}

count_contributors()
{
  folders=$1
  text=$2

  contributors=`git --no-pager shortlog -sn $PREV_TAG..$TAG -- $folders`
  if [ -n "$contributors" ]; then
    contributors=`echo "$contributors" | cut -f2`
    n_contributors=`echo "$contributors" | wc -l`
    contributors_list=`echo "$contributors" | paste -s -d, | sed 's/,/, /g'`

    printf "* $text" "$n_contributors" "$contributors_list."
    echo
  fi
}

count_data_contributors()
{
  folders=$1
  text=$2

  cd gimp-data
  contributors=`git --no-pager shortlog -sn --since="$prev_date" --until="$cur_date" -- $folders`
  if [ -n "$contributors" ]; then
    contributors=`echo "$contributors" | cut -f2`
    n_contributors=`echo "$contributors" | wc -l`
    contributors_list=`echo "$contributors" | paste -s -d, | sed 's/,/, /g'`

    printf "  - $text" "$n_contributors" "$contributors_list."
    echo
  fi
  cd ..
}

count_repo_contributors()
{
  repo=$1
  branch=$2
  text=$3
  prev_tag=$4
  cur_tag=$5
  since_date=$6

  cd $repo
  git fetch origin > /dev/null 2>&1
  if [ -z "$cur_tag" ]; then
    if [ -z "$since_date" ]; then
      contributors=`git --no-pager shortlog -sn --since="$prev_date" --until="$cur_date" origin/$branch`
    else
      contributors=`git --no-pager shortlog -sn --since="$since_date" --until="$cur_date" origin/$branch`
    fi
  else
    contributors=`git --no-pager shortlog -sn $prev_tag..$cur_tag`
  fi

  if [ -n "$contributors" ]; then
    contributors=`echo "$contributors" | cut -f2`
    n_contributors=`echo "$contributors" | wc -l`
    contributors_list=`echo "$contributors" | paste -s -d, | sed 's/,/, /g'`

    if [ -z "$cur_tag" ]; then
      n_commits=`git --no-pager log --oneline --since="$prev_date" --until="$cur_date" origin/$branch | wc -l`
    else
      n_commits=`git --no-pager log --oneline $prev_tag..$cur_tag | wc -l`
    fi
    printf "* $text" "$n_commits" "$n_contributors" "$contributors_list."
    echo
  fi
  cd - > /dev/null
}

echo "Copy the below text into your release news:"
echo
echo "-------------------------------------------"
echo

echo "Since [GIMP $prev_version](/release/$prev_uri/), in the main GIMP repository:"
echo
echo "* $closed_issues reports were closed as FIXED."
echo "* $merged_mrs merge requests were merged."

# Main stats:
contribs=`git --no-pager shortlog -s -n $PREV_TAG..$TAG`
contribs_n=`printf "$contribs" | wc -l`
commits_n=`git log --oneline $PREV_TAG..$TAG | wc -l`

echo "* $commits_n commits were pushed."

# I think this is not very portable, and may be a bash-specific syntax
# for arithmetic operations. XXX
#days_n=$(( (`date -d  "$cur_date" +%s` - `date -d "$prev_date" +%s`)/(60*60*24) ))
#commits_rate=$(( $commits_n / $days_n ))

#echo "Start date: $prev_date - End date: $cur_date"
#echo "Between $PREV_TAG and $TAG, $contribs_n people contributed $commits_n commits to GIMP."
#echo "This is an average of $commits_rate commits a day."
#echo
#echo "Statistics on all files:" `git diff --shortstat $PREV_TAG..$TAG 2>/dev/null`
#echo
#echo "Total contributor list:"
#printf "$contribs"

# Translation stats:
i18n=`git --no-pager log --stat $PREV_TAG..$TAG -- po* | grep "Updated\? .* \(translation\|language\)"`
i18n=`printf "$i18n" | sed "s/ *Updated\? \(.*\) \(translation\|language\).*/\\1/" | sort | uniq`
i18n_n=`printf "$i18n" | wc -l`
# It seems that if the last line has no newline, wc does not count it.
# Add one line manually.
i18n_n=$(( $i18n_n + 1 ))
i18n_comma=`printf "$i18n" | paste -s -d, | sed 's/,/, /g'`

echo "* $i18n_n translations were updated: $i18n_comma."

#echo "Statistics on C files:" `git diff --shortstat $PREV_TAG..$TAG  -- "*.[ch]" 2>/dev/null`

echo
echo "$contribs_n people contributed changes or fixes to GIMP $rel_version codebase (order
is determined by number of commits; some people are in several groups):"
echo
count_contributors 'app/ "libgimp*" pdb tools/pdbgen/' "%d developers to core code: %s"
count_contributors 'plug-ins/ modules/' "%d developers to plug-ins or modules: %s"
count_contributors 'po*/*.po' "%d translators: %s"
count_contributors 'themes/*/*.css themes/*/*png' "%d theme designers: %s"
# XXX For some reason using '*/meson.build' doesn't work out through the
# function. So I list all files explicitly.
meson_builds=`find . -name meson.build -not -path gimp-data`
count_contributors "meson_options.txt $meson_builds .gitlab-ci.yml build" "%d build, packaging or CI contributors: %s"
count_contributors 'data/ etc/ desktop/ menus/ docs/ devel-docs/ NEWS INSTALL.in' "%d contributors on other types of resources: %s"
count_repo_contributors "gimp-data" main "The gimp-data submodule had %d commits by %d contributors: %s" "" "" $int_date
count_data_contributors 'images' "%d image creators: %s"
count_data_contributors 'icons/*.svg icons/*.png' "%d icon designers: %s"
count_data_contributors 'cursors' "%d cursor designers: %s"
count_data_contributors 'brushes' "%d brush designers: %s"
count_data_contributors 'patterns' "%d pattern designers: %s"
if [ "$prevmajor" -ne "$major" ] || [ "$prevminor" -ne "$minor" ] || [ $((minor%2)) -eq 1 ]; then
  # Micro releases don't have a splash update (expect optionally
  # development releases).
  if [ $((minor%2)) -eq 0 ]; then
    echo "  - The splash image for the $major.$minor series was authored by TODO under license TODO."
  else
    echo "  - [OPTIONAL] This new development splash image was authored by TODO under license TODO."
  fi
fi

echo
echo "Contributions on other repositories in the GIMPverse (order is determined by"
echo "number of commits):"
echo
echo "* Our UX tracker had $ux_closed_issues reports closed as FIXED."

babl_ver=`get_latest_from_meson babl $TAG`
prev_babl_ver=`get_latest_from_meson babl $PREV_TAG`
if [ "$babl_ver" != "$prev_babl_ver" ]; then
  prev_tag=`get_tag_from_version BABL $prev_babl_ver`
  cur_tag=`get_tag_from_version BABL $babl_ver`
  count_repo_contributors "../babl" master "babl $babl_ver is made of %d commits by %d contributors: %s" $prev_tag $cur_tag
fi

gegl_ver=`get_latest_from_meson gegl $TAG`
prev_gegl_ver=`get_latest_from_meson gegl $PREV_TAG`
if [ "$gegl_ver" != "$prev_gegl_ver" ]; then
  prev_tag=`get_tag_from_version GEGL $prev_gegl_ver`
  cur_tag=`get_tag_from_version GEGL $gegl_ver`
  count_repo_contributors "../gegl" master "GEGL $gegl_ver is made of %d commits by %d contributors: %s" $prev_tag $cur_tag
fi

count_repo_contributors "../ctx.graphics" dev "[ctx](https://ctx.graphics/) had %d commits since $int_version release by %d contributors: %s"
count_repo_contributors "../gimp-test-images" main "The \`gimp-test-images\` (unit testing repository) repository had %d commits by %d contributors: %s"
count_repo_contributors "../gimp-macos-build" master "The \`gimp-macos-build\` (macOS packaging scripts) release had %d commits by %d contributors: %s"
# TODO:
# * flatpak often has bot commits. These should be filtered out.
# * detect a beta vs. stable release and tweak branch accordingly.
count_repo_contributors "../org.gimp.GIMP" master "The flatpak release had %d commits by %d contributors: %s"
count_repo_contributors "../gimp-web" testing "Our main website (what you are reading right now) had %d commits by %d contributors: %s"
count_repo_contributors "../gimp-web-devel" testing "Our [developer website](https://developer.gimp.org/) had %d commits by %d contributors: %s"
count_repo_contributors "../gimp-help" master "Our [3.0 documentation](https://docs.gimp.org/) had %d commits by %d contributors: %s"

echo
echo "Let's not forget to thank all the people who help us triaging in Gitlab, report"
echo "bugs and discuss possible improvements with us."
echo "Our community is deeply thankful as well to the internet warriors who manage our"
echo "various [discussion channels](https://www.gimp.org/discuss.html) or social"
echo "network accounts such as Ville Pätsi, Liam Quin, Michael Schumacher and Sevenix!"
echo
echo "*Note: considering the number of parts in GIMP and around, and how we"
echo "get statistics through \`git\` scripting, errors may slip inside these"
echo "stats. Feel free to tell us if we missed or mis-categorized some"
echo "contributors or contributions.*"

exit 0