Skip to content

Instantly share code, notes, and snippets.

@greg0ire
Created June 30, 2020 20:09
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 greg0ire/743bff6dab6498ab2ddddd7931c115c8 to your computer and use it in GitHub Desktop.
Save greg0ire/743bff6dab6498ab2ddddd7931c115c8 to your computer and use it in GitHub Desktop.
#!/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