Skip to content

Instantly share code, notes, and snippets.

@astleychen
Last active October 3, 2017 16:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save astleychen/26ee4cc59e9b77ed8b923be899141cf9 to your computer and use it in GitHub Desktop.
Save astleychen/26ee4cc59e9b77ed8b923be899141cf9 to your computer and use it in GitHub Desktop.
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