Created
June 30, 2020 20:09
-
-
Save greg0ire/743bff6dab6498ab2ddddd7931c115c8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -e | |
function usage () { | |
echo "$1" duration oldest-branch … newest-branch | |
exit 1 | |
} | |
function count_commits() { | |
log_args[0]="origin/$2" | |
if [ $# -eq 3 ] | |
then | |
log_args[1]="^origin/$3" | |
fi | |
git log --pretty=oneline --since="$1" --merges ${log_args[*]}\ | |
|grep --count 'Merge pull request' # exclude merges up | |
} | |
if [ $# -lt 3 ] | |
then | |
usage "$0" | |
fi | |
readonly duration=$1 | |
shift; | |
readonly oldest_branch=$1 | |
lower_branch=$1 | |
printf "%s:\t%s PR merge commits\n" "$oldest_branch" "$(count_commits "$duration" "$oldest_branch")" | |
while [ -n "$2" ] | |
do | |
printf "$2:\t%s PR merge commits\n" "$(count_commits "$duration" "$2" "$lower_branch")" | |
lower_branch=$2 | |
shift; | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment