Skip to content

Instantly share code, notes, and snippets.

@astleychen
Last active Oct 3, 2017
Embed
What would you like to do?
A script to dump contributors standings in a period of time in a mercurial repo.
#!/bin/bash
# == Arguments ==
# $1 : date range, exp: "2016-07-01 to 2016-09-30"
# $2 ~ $n : bug mail list, exp: aschen@mozilla.com
#
# == Output ==
# Individual standings and sum of standings.
dateRange="$1"
shift
bugMails=($@)
totalBugsNum=0
totalHGCommitsNum=0
totalServoPRNum=0
for i in "${bugMails[@]}"
do
rawCommits=$(hg log --date "$dateRange" -u $i --template '{desc|strip|firstline}\n')
uniqHGCommits=$(echo "$rawCommits" | sort | uniq | grep -v -i 'servo: ')
hgCommitsNum=$(echo "$uniqHGCommits" | wc -l)
uniqServoPRs=$(echo "$rawCommits" | sort | uniq | grep -i 'servo: ')
servoPRNum=$(echo "$uniqServoPRs" | wc -l)
bugsNum=$(echo "$uniqHGCommits" | cut -d' ' -f 2 | sort | uniq | wc -l)
totalBugsNum=$(($totalBugsNum + $bugsNum))
totalHGCommitsNum=$(($totalHGCommitsNum + $hgCommitsNum))
totalServoPRNum=$(($totalServoPRNum + $servoPRNum))
printf "$i : Fixed $bugsNum bugs with $hgCommitsNum HG commits and $servoPRNum Servo PRs\n"
# printf "Mercurial Commits History :\n"
# echo -e "$uniqHGCommits\n\n"
done
printf "Team : $totalBugsNum bugs, $totalHGCommitsNum commits, $totalServoPRNum PRs\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment