Skip to content

Instantly share code, notes, and snippets.

@eculver
Created August 2, 2012 19:52
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eculver/3240084 to your computer and use it in GitHub Desktop.
Save eculver/3240084 to your computer and use it in GitHub Desktop.
Simple shell script to determine if a branch has been fully merged back in to master and develop(ment)
#!/usr/local/bin/zsh
autoload colors
if [[ "$terminfo[colors]" -gt 8 ]]; then
colors
fi
for COLOR in RED GREEN YELLOW BLUE MAGENTA CYAN BLACK WHITE; do
eval $COLOR='$fg_no_bold[${(L)COLOR}]'
eval BOLD_$COLOR='$fg_bold[${(L)COLOR}]'
done
eval RESET='$reset_color'
PROGNAME=$(basename $0)
if [ $# != "1" ]; then
echo "${PROGNAME}: you must specify a branch name to check to see if it's fully merged."
exit 1
fi
git fetch origin > /dev/null 2>&1
git checkout $1 > /dev/null 2>&1
git pull > /dev/null 2>&1
git checkout development > /dev/null 2>&1
git pull > /dev/null 2>&1
git branch --merged | grep "$1" > /dev/null 2>&1
if [ "$?" -eq "0" ]; then
git checkout master > /dev/null 2>&1
git pull > /dev/null 2>&1
git branch --merged | grep "$1" > /dev/null 2>&1
if [ "$?" -eq "0" ]; then
echo "${GREEN}✔ YAY! ${RESET}$1 is completely merged to both master and development"
else
echo "${RED}✗ WHOOPS: ${RESET}$1 was not completely merged back in to master."
fi
else
echo "${RED}✗ WHOOPS: ${RESET}$1 was not completely merged back in to development."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment