diff --git a/gitistics.sh b/gitistics.sh index 01628cc..ec6ba64 100755 --- a/gitistics.sh +++ b/gitistics.sh @@ -9,13 +9,16 @@ REPOUSER="\(structix\|Janek\)" # Specify the start date, where the statistics should be gathered STARTDATE="01 Jan 2018" +# Verbose flag +VERBOSE=false + # -------------------- # --- functions # returns the amount of commits for one repository function getCommits() { # show amount of commits of all users - committemp=$(git rev-list --count --all --author=$REPOUSER --since="$STARTDATE") + committemp=$(git rev-list --count --all --author=$REPOUSER --since="$STARTDATE" 2> /dev/null) echo $committemp } @@ -37,7 +40,9 @@ function getDiffChanges() { local exti=${array[1]//[!0-9]} local extd=${array[2]//[!0-9]} - echo "Files: $extf, Insertions: $exti, Deletions: $extd" + if [ "$VERBOSE" = true ]; then + echo "Files: $extf, Insertions: $exti, Deletions: $extd" + fi local f=$(( extf + __files)) local i=$(( exti + __insert)) @@ -50,14 +55,17 @@ function getDiffChanges() { } function main() { - # Switch into the REPODIR - pushd $REPODIR + # Switch into the REPODIR (silently) + pushd $REPODIR 1> /dev/null # Iterate over all subdirectories for dir in $REPODIR/*/ do dir=${dir%*/} - echo ${dir##*/} + + if [ "$VERBOSE" = true ]; then + echo ${dir##*/} + fi # enter directory cd ${dir##*/} @@ -68,7 +76,10 @@ function main() { # Add to the total commit counter commitcounter=$((commitcounter + commtemp)) # Output the commit counter of the current iteration - echo $commtemp + + if [ "$VERBOSE" = true ]; then + echo $commtemp + fi getDiffChanges totalfiles totalinsertions totaldeletions @@ -76,8 +87,8 @@ function main() { cd .. done - # Switch back to the original directory state - popd + # Switch back to the original directory state (silently) + popd 1> /dev/null echo "-------------------------"