Created
February 13, 2018 06:51
-
-
Save aj-adl/5fb70d6d65f581c04cacaacc940a026f to your computer and use it in GitHub Desktop.
Command to automate branch switching and merging when using deployment braches
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
#!/usr/bin/env bash | |
function gdpl (){ | |
set -e | |
local RED=`tput setaf 1` | |
local GREEN=`tput setaf 2` | |
local BLUE=`tput setaf 6` | |
local YELLOW=`tput setaf 3` | |
local PURPLE=`tput setaf 5` | |
local NC=`tput sgr0` # No Color | |
local TAG="${BLUE}FRAME TOOLSET ${NC}:::: " | |
local NL=`tput il 1` | |
if [ $# -eq 0 ]; then | |
echo "${RED}Please supply a valid branch"; | |
exit 1; | |
fi; | |
echo ""; | |
echo ""; | |
echo "${TAG}${YELLOW}Checking out branch \"${1}\""; | |
echo "${NC}................................"; | |
echo ""; | |
echo ""; | |
git checkout $1; | |
git pull origin $1; | |
if [ $# -eq 2 ]; then | |
echo ""; | |
echo ""; | |
echo "${TAG}${YELLOW}Merging branch \"${2}\" into branch \"${1}\""; | |
echo "${NC}................................"; | |
echo ""; | |
echo ""; | |
git merge $2; | |
else | |
echo ""; | |
echo ""; | |
echo "${TAG}${YELLOW}Merging branch \"master\" into branch \"${1}\" "; | |
echo "${NC}................................"; | |
echo ""; | |
echo ""; | |
git merge master; | |
fi; | |
echo ""; | |
echo ""; | |
echo "${TAG}${YELLOW}Merge complete! pushing to origin / ${1} "; | |
echo "${NC}................................"; | |
echo ""; | |
echo ""; | |
git push origin $1; | |
echo ""; | |
echo ""; | |
echo "${TAG}${GREEN}Push complete, returing you to branch \"master\" "; | |
echo "${NC}................................"; | |
echo ""; | |
echo ""; | |
git checkout master; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Why not just use tags?
We'd fricken love to but our deploy tool doesn't support triggering deployments automatically via regex tag matching
How do I use it?
Examples