Restructured in functions
This commit is contained in:
104
gitistics.sh
104
gitistics.sh
@@ -10,59 +10,73 @@ REPOUSER="\(structix\|Janek\)"
|
|||||||
STARTDATE="01 Jan 2018"
|
STARTDATE="01 Jan 2018"
|
||||||
|
|
||||||
# --------------------
|
# --------------------
|
||||||
|
# --- functions
|
||||||
|
|
||||||
# Switch into the REPODIR
|
# returns the amount of commits for one repository
|
||||||
pushd $REPODIR
|
function getCommits() {
|
||||||
|
# show amount of commits of all users
|
||||||
|
committemp=$(git rev-list --count --all --author=$REPOUSER --since="$STARTDATE")
|
||||||
|
echo $committemp
|
||||||
|
}
|
||||||
|
|
||||||
# total commits
|
# get the amount of files, insertions, deletions by specifying parameters
|
||||||
commitcounter=0
|
function getDiffChanges() {
|
||||||
|
local __files=$1
|
||||||
|
local __insert=$2
|
||||||
|
local __delete=$3
|
||||||
|
|
||||||
# total diff stats
|
# calculate total changes between given date and HEAD
|
||||||
totalfiles=0
|
local extractdiff=$(git diff @{"$STARTDATE"} HEAD --shortstat) 2>/dev/null
|
||||||
totalinsertions=0
|
|
||||||
totaldeletions=0
|
|
||||||
|
|
||||||
# Iterate over all subdirectories
|
# set the separator to ,
|
||||||
for dir in $REPODIR/*/
|
local IFS=','
|
||||||
do
|
local array=( $extractdiff )
|
||||||
dir=${dir%*/}
|
local f=$(( ${array[0]//[!0-9]} + __files))
|
||||||
echo ${dir##*/}
|
local i=$(( ${array[1]//[!0-9]} + __insert))
|
||||||
|
local d=$(( ${array[2]//[!0-9]} + __delete))
|
||||||
|
|
||||||
# enter directory
|
eval $__files="'$f'"
|
||||||
cd ${dir##*/}
|
eval $__insert="'$i'"
|
||||||
|
eval $__delete="'$d'"
|
||||||
|
|
||||||
# --- RUN COMMANDS
|
}
|
||||||
|
|
||||||
# show amount of commits of all users
|
function main() {
|
||||||
committemp=$(git rev-list --count --all --author=$REPOUSER --since="$STARTDATE")
|
# Switch into the REPODIR
|
||||||
|
pushd $REPODIR
|
||||||
|
|
||||||
# Add to the total commit counter
|
# Iterate over all subdirectories
|
||||||
commitcounter=$((commitcounter + committemp))
|
for dir in $REPODIR/*/
|
||||||
|
do
|
||||||
|
dir=${dir%*/}
|
||||||
|
echo ${dir##*/}
|
||||||
|
|
||||||
|
# enter directory
|
||||||
|
cd ${dir##*/}
|
||||||
|
|
||||||
|
# --- RUN COMMANDS
|
||||||
|
|
||||||
|
commtemp=$(getCommits)
|
||||||
|
# Add to the total commit counter
|
||||||
|
commitcounter=$((commitcounter + commtemp))
|
||||||
|
# Output the commit counter of the current iteration
|
||||||
|
echo $commtemp
|
||||||
|
|
||||||
|
getDiffChanges totalfiles totalinsertions totaldeletions
|
||||||
|
|
||||||
|
# go back
|
||||||
|
cd ..
|
||||||
|
done
|
||||||
|
|
||||||
|
# Switch back to the original directory state
|
||||||
|
popd
|
||||||
|
|
||||||
|
|
||||||
# calculate total changes between given date and HEAD
|
echo "-------------------------"
|
||||||
extractdiff=$(git diff @{"$STARTDATE"} HEAD --shortstat) 2>/dev/null
|
echo "Total commits since $STARTDATE: $commitcounter"
|
||||||
|
echo "Total files changed: $totalfiles"
|
||||||
|
echo "Total insertions: $totalinsertions"
|
||||||
|
echo "Total deletions: $totaldeletions"
|
||||||
|
}
|
||||||
|
|
||||||
# set the separator to ,
|
main
|
||||||
IFS=','
|
|
||||||
array=( $extractdiff )
|
|
||||||
totalfiles=$(( ${array[0]//[!0-9]} + totalfiles))
|
|
||||||
totalinsertions=$(( ${array[1]//[!0-9]} + totalinsertions))
|
|
||||||
totaldeletions=$(( ${array[2]//[!0-9]} + totaldeletions))
|
|
||||||
|
|
||||||
|
|
||||||
# ------------------
|
|
||||||
# Output the commit counter of the current iteration
|
|
||||||
echo $committemp
|
|
||||||
|
|
||||||
# go back
|
|
||||||
cd ..
|
|
||||||
done
|
|
||||||
|
|
||||||
echo "Total commits since $STARTDATE: $commitcounter"
|
|
||||||
echo "Total files changed: $totalfiles"
|
|
||||||
echo "Total insertions: $totalinsertions"
|
|
||||||
echo "Total deletions: $totaldeletions"
|
|
||||||
|
|
||||||
# Switch back to the original directory state
|
|
||||||
popd
|
|
||||||
|
Reference in New Issue
Block a user