Created
December 17, 2014 16:08
-
-
Save InAnimaTe/dfc9371ef2ef5fecc023 to your computer and use it in GitHub Desktop.
Update function for dotfiles/env
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
| function update () { | |
| function submod_push () { | |
| CHANGE_LIST=("${(@f)$(git status --porcelain)}") | |
| if [ $? -eq 0 ]; then | |
| # command ran fine..continue | |
| if [ ${CHANGE_LIST[1]} ]; then | |
| echo -en " ${txtyellow}*${reset} ${txtlitepurple}The following changes exist:${reset}\n" | |
| for change in ${CHANGE_LIST[@]}; do | |
| echo -en " ${txtyellow}*${reset} ${txtlitegray}${change}${reset}\n" | |
| done | |
| git commit -am '[auto] Update function submodule check' && \ | |
| git push origin master && \ | |
| echo -en " ${txtyellow}*${reset} ${bldgreen}Changes successfully committed!${reset}\n" && \ | |
| return 0 | |
| else | |
| echo -en " ${txtyellow}*${reset}${txtcyan} No submodule changes exist...${reset}\n" | |
| return 0 | |
| fi | |
| else | |
| echo -en "${bldred}There was a problem checking for changes...halting!${reset}\n" | |
| return 1 | |
| fi | |
| } | |
| cur="$(pwd)" && \ | |
| cd ~/env && \ | |
| echo -en "${txtcyan}Pulling in HEAD...${reset}\n" && \ | |
| git fetch origin && \ | |
| git reset --hard origin/master && \ | |
| git clean -dff && \ | |
| echo -en "${txtcyan}Checking submodules...${reset}\n" && \ | |
| git submodule update --init --recursive && \ | |
| git submodule status && \ | |
| #echo -en "${txtcyan}Cleaning...${reset}\n" && \ | |
| #git clean -dff && \ | |
| # Note we use a -x on git clean since our submodules should never have artifacts | |
| #git submodule foreach 'git clean -dffx' && \ | |
| echo -en "${txtcyan}Pulling in HEAD for each submodule...${reset}\n" && \ | |
| ### -> The following line was the 1st way I was updating submods but it doesn't work on older git versions. | |
| #git submodule update --remote && \ ## Sadly, we cant use this, seems to be Git 1.8+ only! 12.04 has 1.7.x :( | |
| ### -> The following two lines were the 2nd way I updated the submodules | |
| #git submodule foreach 'git fetch' && \ | |
| #git submodule foreach 'git merge origin/master' && \ | |
| ### -> The following three lines are the current way we update submodules, just like our main repo, negating any changes to anything since we dont care. | |
| ### --> Also, git clean is run again since a normal git clean doesn't recurse into submods. | |
| git submodule foreach 'git fetch origin' && \ | |
| git submodule foreach 'git reset --hard origin/master' && \ | |
| git submodule foreach 'git clean -dffx' && \ | |
| submod_push && \ | |
| echo -en "${txtcyan}Assessing symlinks...${reset}\n" && \ | |
| ./setup.sh mklink && \ | |
| cd "$cur" && \ | |
| cur='' && \ | |
| echo -en "${txtcyan}Ensuring permissions...${reset}\n" && \ | |
| chmod 600 $ENV_ROOT/.ssh/id_rsa* && \ | |
| echo -en "${bldgreen}Done! ${txtcyan}Sourcing rc file...${reset}\n" && \ | |
| source $HOME/.zshrc | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment