From fdb53851228da17d7536fc6c036c3a0e7535fd84 Mon Sep 17 00:00:00 2001 From: Joseph Jon Booker Date: Mon, 17 Jan 2011 13:57:23 -0600 Subject: [PATCH] Allow forks to use the same upgrade script, adds upstream repo if needed --- tools/upgrade.sh | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/tools/upgrade.sh b/tools/upgrade.sh index 6bdd02e38..7e6e4ca8d 100644 --- a/tools/upgrade.sh +++ b/tools/upgrade.sh @@ -1,6 +1,19 @@ current_path=`pwd` echo "Upgrading Oh My Zsh" -( cd $ZSH && git pull origin master ) + +git_branches=`git remote -v` +default_origin=`echo $git_branches | egrep 'origin\s+https://github.com/robbyrussell/oh-my-zsh\.git'` +upgrade_cmd="git pull origin master" +if [ "N$default_origin" = "N" ]; then + upstream_branch=`echo $git_branches | egrep 'upstream\s+https://github.com/robbyrussell/oh-my-zsh\.git'` + if [ "N$upstream_branch" = "N" ]; then + upgrade_cmd="git remote add upstream https://github.com/robbyrussell/oh-my-zsh/; git fetch upstream; git merge upstream/master" + else + upgrade_cmd="git fetch upstream; git merge upstream/master" + fi +fi + +( cd $ZSH && eval "$upgrade_cmd" ) echo ' __ __ ' echo ' ____ / /_ ____ ___ __ __ ____ _____/ /_ ' echo ' / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \ ' @@ -9,4 +22,4 @@ echo '\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ ' echo ' /____/' echo "Hooray! Oh My Zsh has been updated and/or is at the current version. \nAny new updates will be reflected when you start your next terminal session." echo "To keep up on the latest, be sure to follow Oh My Zsh on twitter: http://twitter.com/ohmyzsh" -cd $current_path \ No newline at end of file +cd $current_path