summaryrefslogtreecommitdiff
path: root/pkg/scripts/stats.sh
blob: 2b7a8b189cb8b11addf8ea6dbde648797154e2c4 (plain)
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
#!/bin/bash

REPOSITORIES="bitmask_client leap_pycommon soledad keymanager leap_mail"

CHANGED=0
INSERTIONS=0
DELETIONS=0
MERGES_TOTAL=0

echo "Changes summary between closest annotated tag to HEAD"
echo "====================================================="
echo

for repo in $REPOSITORIES; do
    cd $repo
    echo "Stats for: $repo"
    # the 'describe' command gives the closest annotated tag
    STATS=$(git diff --shortstat `git describe --abbrev=0`..HEAD)
    MERGES=$(git log --merges `git describe --abbrev=0`..HEAD | wc -l)
    echo "Stats:$STATS"
    echo "Merges: $MERGES"
    VALUES=(`echo $STATS | awk '{ print $1, $4, $6 }'`)  # use array to store values
    CHANGED=$(echo $CHANGED + ${VALUES[0]} | bc)
    INSERTIONS=$(echo $INSERTIONS + ${VALUES[1]} | bc)
    DELETIONS=$(echo $DELETIONS + ${VALUES[2]} | bc)
    MERGES_TOTAL=$(echo $MERGES_TOTAL + $MERGES | bc)
    echo "----------------------------------------------------------------------"
    cd ..
done

echo
echo "TOTAL"
echo "Stats: $CHANGED files changed, $INSERTIONS insertions(+), $DELETIONS deletions(-)"
echo "Merges: $MERGES_TOTAL"