Skip to content

Instantly share code, notes, and snippets.

@NeoBlack
Created April 15, 2020 09:54
Show Gist options
  • Save NeoBlack/32f69c85e2cb3c0e5e189e81a38070c7 to your computer and use it in GitHub Desktop.
Save NeoBlack/32f69c85e2cb3c0e5e189e81a38070c7 to your computer and use it in GitHub Desktop.
TYPO3 release statistics
#!/bin/bash
###############################
# TYPO3 release statistics
# Generator script to get some stats from the git repository
# Set the variable "tag" below to the first LTS version tag and start the script from the local master checkout
#
# Created by Frank Nägler (@NeoBlack)
###############################
# last LTS Version tag
tag=v9.5.0
# Calculations
contributor=`git shortlog -sne $tag..master | wc -l | sed -e 's/^[[:space:]]*//'`
commits=`git log --oneline $tag..master | wc -l | sed -e 's/^[[:space:]]*//'`
tasks=`git log --oneline $tag..master| egrep ' \[TASK' | wc -l | sed -e 's/^[[:space:]]*//'`
bugfixes=`git log --oneline $tag..master| egrep ' \[BUGFIX' | wc -l | sed -e 's/^[[:space:]]*//'`
features=`git log --oneline $tag..master| egrep ' \[FEATURE' | wc -l | sed -e 's/^[[:space:]]*//'`
breaking=`git log --oneline $tag..master| egrep ' \[!!!' | wc -l | sed -e 's/^[[:space:]]*//'`
loc_stats=`git diff --shortstat $tag..master`
# $loc_stats example: " 9765 files changed, 273410 insertions(+), 210069 deletions(-)"
files_changed=`echo "$loc_stats" | cut -d"," -f1 | cut -d" " -f2`
loc_added=`echo "$loc_stats" | cut -d"," -f2 | cut -d" " -f2`
loc_removed=`echo "$loc_stats" | cut -d"," -f3 | cut -d" " -f2`
loc_diff=$(( $loc_added - $loc_removed ))
if [ "$loc_diff" -gt "0" ]; then
more_less="more"
else
more_less="less"
fi
tagDateString=`git log -1 --format="%ci" $tag | cut -d" " -f1 | sed 's/-/\//g'`
if type "gdate" > /dev/null; then
tagDate=$(gdate +%s --date "$tagDateString")
today=`gdate "+%s"`
else
tagDate=$(date +%s --date "$tagDateString")
today=`date "+%s"`
fi
dateDiff=$(( $today - $tagDate ))
days=$(( $dateDiff / (60*60*24) ))
commits_per_day=$(($commits/$days))
# Start output
##############################
# Version
echo "Since the last LTS version $tag"
# Contributor
echo "... $contributor different contributors ..."
# Commits
echo "... made $commits Git commits ..."
# Days
echo "... in $days days ..."
# Commits / Day
echo "... this means $commits_per_day commits / day ..."
# Tasks
echo "... $tasks task commits ..."
# Bugfixes
echo "... $bugfixes bugfix commits ..."
# Features
echo "... $features feature commits ..."
# Breaking
echo "... $breaking breaking commits ..."
# Files changed
echo "... $files_changed files were changed ..."
# Lines of code added
echo "... $loc_added lines of code were added ..."
# Lines of code removed
echo "... $loc_removed lines of code were removed ..."
# Lines of code removed
echo "... this means that there are now $loc_diff $more_less lines of code ..."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment