1
1
mirror of https://gitlab.gnome.org/GNOME/gimp.git synced 2025-10-06 01:12:40 +02:00

tools: tweak script so that it outputs statistics in release news format.

Though most of the stats we were pulling came from this, let's format it
exactly how we have done in many latest release news.
Also add automatic stats pulling too of our many side repositories.
This commit is contained in:
Jehan
2025-09-02 18:59:35 +02:00
parent 51ba945eb1
commit 81c844d2ca

View File

@@ -1,4 +1,19 @@
#!/bin/sh
#!/bin/bash
# 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 #
@@ -34,50 +49,122 @@ else
CUR='HEAD'
fi
echo "## GIMP contributions between $PREV and $CUR ##"
prev_date=`git log -1 --format=%ci $PREV`
cur_date=`git log -1 --format=%ci $CUR`
IFS=_ read -r gimp prevmajor prevminor prevmicro <<<"$1"
IFS=_ read -r gimp major minor micro <<<"$2"
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..$CUR -- $folders`
if [ -n "$contributors" ]; then
contributors=`echo "$contributors" | cut -f2`
n_contributors=`echo "$contributors" | wc -l`
contributors_list="${contributors//$'\n'/, }"
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="${contributors//$'\n'/, }"
printf " - $text" "$n_contributors" "$contributors_list."
echo
fi
cd ..
}
count_repo_contributors()
{
repo=$1
branch=$2
text=$3
prev_tag=$4
cur_tag=$5
cd $repo
git fetch origin > /dev/null 2>&1
if [ -z "$cur_tag" ]; then
contributors=`git --no-pager shortlog -sn --since="$prev_date" --until="$cur_date" origin/$branch`
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="${contributors//$'\n'/, }"
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 "Since [GIMP $prevmajor.$prevminor.$prevmicro](TODO), in the main GIMP repository:"
echo
echo "* TODO reports were closed as FIXED."
echo "* TODO merge requests were merged."
# Main stats:
contribs=`git --no-pager shortlog -s -n $PREV..$CUR`
contribs_n=`printf "$contribs" | wc -l`
commits_n=`git log --oneline $PREV..$CUR | wc -l`
prev_date=`git log -1 --format=%ci $PREV`
cur_date=`git log -1 --format=%ci $CUR`
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 ))
#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 and $CUR, $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..$CUR 2>/dev/null`
echo
echo "Total contributor list:"
printf "$contribs"
echo
echo
echo "## DEVELOPERS ##"
echo
echo "Statistics on C files:" `git diff --shortstat $PREV..$CUR -- "*.[ch]" 2>/dev/null`
echo
echo "Core developers:"
git --no-pager shortlog -s -n $PREV..$CUR -- app/ "libgimp*" pdb tools/pdbgen/
echo "Plugin and module developers:"
git --no-pager shortlog -s -n $PREV..$CUR -- plug-ins/ modules/
echo
echo "## TRANSLATIONS ##"
echo
#git --no-pager log --stat $PREV..$CUR -- po* | grep "Updated\? .* translation"|sed "s/ *Updated\? \(.*\) translation.*/\\1/" | sort | uniq | paste -s -d, | sed 's/,/, /g'
#echo "Start date: $prev_date - End date: $cur_date"
#echo "Between $PREV and $CUR, $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..$CUR 2>/dev/null`
#echo
#echo "Total contributor list:"
#printf "$contribs"
# Translation stats:
i18n=`git --no-pager log --stat $PREV..$CUR -- po* | grep "Updated\? .* \(translation\|language\)"`
i18n=`printf "$i18n" | sed "s/ *Updated\? \(.*\) \(translation\|language\).*/\\1/" | sort | uniq`
i18n_n=`printf "$i18n" | wc -l`
@@ -86,53 +173,74 @@ i18n_n=`printf "$i18n" | wc -l`
i18n_n=$(( $i18n_n + 1 ))
i18n_comma=`printf "$i18n" | paste -s -d, | sed 's/,/, /g'`
echo "$i18n_n translations were updated: $i18n_comma."
echo
echo "* $i18n_n translations were updated: $i18n_comma."
echo "Translators:"
git --no-pager shortlog -sn $PREV..$CUR -- "po*/*.po"
#echo "Statistics on C files:" `git diff --shortstat $PREV..$CUR -- "*.[ch]" 2>/dev/null`
echo
echo "## DESIGN ##"
echo "$contribs_n people contributed changes or fixes to GIMP $major.$minor.$micro 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"
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"
echo " - TODO: splash author."
new_icons=`git log --name-status $PREV..$CUR -- icons/*.svg icons/*.png 2>/dev/null|grep "^A\s"|sed 's%^.*/\([^/]*\)\..*$%\1%' | sort | uniq`
icons_n=$((`printf "$new_icons" | wc -l` + 1))
icons_comma=`printf "$new_icons" | paste -s -d, | sed 's/,/, /g'`
echo
echo "Contributions on other repositories in the GIMPverse (order is determined by"
echo "number of commits):"
echo
echo "* Our UX tracker had TODO reports closed as FIXED."
if [ "$icons_n" -lt 20 ]; then
echo "$icons_n icons were added: $icons_comma"
else
echo "$icons_n icons were added (too many to list them all)."
babl_ver=`get_latest_from_meson babl $CUR`
prev_babl_ver=`get_latest_from_meson babl $PREV`
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
echo
echo "Icon designers:"
git --no-pager shortlog -sn $PREV..$CUR -- "icons/*.svg" "icons/*.png"
echo "Theme designers:"
git --no-pager shortlog -sn $PREV..$CUR -- "themes/*/*.css" "themes/*/*png"
gegl_ver=`get_latest_from_meson gegl $CUR`
prev_gegl_ver=`get_latest_from_meson gegl $PREV`
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
echo "Cursor creators:"
git --no-pager shortlog -sn $PREV..$CUR -- cursors/
echo "Resource creators:"
git --no-pager shortlog -sn $PREV..$CUR -- data/ etc/ desktop/ menus/
count_repo_contributors "../ctx.graphics" dev "[ctx](https://ctx.graphics/) had %d commits since $prevmajor.$prevminor.$prevmicro 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 "## Documenters ##"
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.*"
git --no-pager shortlog -sn $PREV..$CUR -- docs/ devel-docs/ NEWS INSTALL.in "*README*" HACKING
echo
echo "## Build maintainers ##"
echo
echo "Meson build system:"
git --no-pager shortlog -sn $PREV..$CUR -- meson_options.txt "*/meson.build"
echo "Gitlab CI:"
git --no-pager shortlog -sn $PREV..$CUR -- .gitlab-ci.yml
echo "Binary builds:"
git --no-pager shortlog -sn $PREV..$CUR -- build/
exit 0