Skip to content

Instantly share code, notes, and snippets.

@mossheim
Last active February 3, 2018 23:28
Show Gist options
  • Save mossheim/6839fae8214d0379f6caf81ecfce5ced to your computer and use it in GitHub Desktop.
Save mossheim/6839fae8214d0379f6caf81ecfce5ced to your computer and use it in GitHub Desktop.
#!/bin/bash
# Checks whether PRs with a chosen milestone have been merged into a chosen release branch
# Used to detect patch fixes that might not have been cherry-picked onto the release branch
#
# Original author: Brian Heim
# 2018-02-03
if [[ -z "$1" || -z "$2" ]]; then
echo "Usage: cmd <milestone> <release-branch>"
echo "\tExample: cmd 3.9.1 3.9"
fi
milestone=$1
release_br=$2
echo "Updating branches..."
git checkout -q develop
git pull -q upstream
git checkout -q $release_br
git pull -q upstream
echo "Gathering issues..."
pulls_file=pulls-$milestone
clean_pulls_file=$pulls_file-clean
hub issue --include-pulls -f "%U %Mt (%Mn)%n" -s all | grep "pull.*$milestone" >$pulls_file
awk '{print $1}' <$pulls_file | grep -o "[[:digit:]]*$" >$clean_pulls_file
echo "Testing PRs..."
for pr in `cat $clean_pulls_file`; do
localbr=test-$pr
git fetch -q upstream pull/$pr/head:$localbr
diffs=`git rev-list --right-only --count $release_br...$localbr`
diffs_chpk=`git rev-list --cherry-pick --right-only --count $release_br...$localbr`
diffs_dev=`git rev-list --right-only --count develop...$localbr`
# debug:
# echo "$pr | $diffs | $diffs_chpk | $diffs_dev"
if [[ $diffs_chpk > 0 ]]; then
if [[ $diffs_dev > 0 ]]; then
# debug
# echo "PR #$pr was not merged into $release_br or develop"
else
echo "PR #$pr was not cherry-picked onto $release_br"
if [[ $diffs_chpk != $diffs ]]; then
echo " But, it may have been included in a later PR"
fi
fi
fi
git branch -q -D $localbr
done
rm $pulls_file
rm $clean_pulls_file
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment