Skip to content

Instantly share code, notes, and snippets.

@michal-lipski
Last active September 15, 2017 12:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michal-lipski/03f94703ad94871fbe47d98bb55a9782 to your computer and use it in GitHub Desktop.
Save michal-lipski/03f94703ad94871fbe47d98bb55a9782 to your computer and use it in GitHub Desktop.
# avg number of commits per month in date range
input_start=2017-3-1
input_end=2017-9-1
startdate=$(date -I -d "$input_start") || exit -1
enddate=$(date -I -d "$input_end") || exit -1
d="$startdate"
sum=0
count=0
while [ "$d" != "$enddate" ]; do
part=0
echo $d
part=`git rev-list master --count --before={$(date -I -d "$d + 1 month")} --after={$d}`
echo $part
d=$(date -I -d "$d + 1 month")
sum=$(($sum + $part))
count=$(($count + 1))
done
echo $(($sum / $count))
# number of days beetwen first and last comit of a user
mapfile -t authors < <( git log --pretty=format:%an | sort | uniq )
echo "Number of authors:" ${#authors[@]}
for author in "${authors[@]}"
do
lastCommitDate=`git log --pretty=format:%at --author="$author" | sed -n 1p`
firstCommitDate=`git log --pretty=format:%at --author="$author" | tail -1`
if [ ! -z "$lastCommitDate" ];
then
daysInProject=$((($lastCommitDate - $firstCommitDate)/60/60/24))
echo $author" "$daysInProject
fi
done
# avg number of commiters per month in date range
input_start=2017-3-1
input_end=2017-9-1
startdate=$(date -I -d "$input_start") || exit -1
enddate=$(date -I -d "$input_end") || exit -1
d="$startdate"
sum=0
count=0
while [ "$d" != "$enddate" ]; do
part=0
echo $d
part=`git shortlog -s -n --before={$(date -I -d "$d + 1 month")} --after={$d} | wc -l`
echo $part
d=$(date -I -d "$d + 1 month")
sum=$(($sum + $part))
count=$(($count + 1))
done
echo $(($sum / $count))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment