diff --git a/script/clean.sh b/script/clean.sh index 708c01c6..3a3bcf91 100755 --- a/script/clean.sh +++ b/script/clean.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash SUCCESS="\033[32mSuccess:\033[00m" diff --git a/script/debug.sh b/script/debug.sh index 2f920def..1763d412 100755 --- a/script/debug.sh +++ b/script/debug.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # Determine path to script MY_PATH=`dirname "$0"` @@ -6,4 +6,4 @@ MY_PATH=`dirname "$0"` cd $MY_PATH/.. # Build and run target -make -C build/Debug "$1" && bin/Debug/"$1" +make -C build/Debug "$1" && cd bin && Debug/"$1" diff --git a/script/git-publish.sh b/script/git-publish.sh index 57db4718..1c7eeb80 100755 --- a/script/git-publish.sh +++ b/script/git-publish.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash ABORT="\033[31mAbort:\033[00m" SUCCESS="\033[32mSuccess:\033[00m" @@ -40,7 +40,7 @@ echo -e $INFO "Checking master" # check if master is up to date if [[ -n $(git diff origin/master) ]] then - echo -e $ABORT "Your master is not up-to-date. Run 'sync.sh' to update your master, then run 'git rebase master' to update branch $BRANCH_NAME." + echo -e $ABORT "Your master is not up-to-date. Run 'git-sync-master.sh' to update master and rebase $BRANCH_NAME." git checkout -q $BRANCH_NAME exit 1 fi @@ -75,6 +75,7 @@ git commit if [ $? != 0 ] then + echo -e $ABORT "Commit was aborted." git checkout -q $BRANCH_NAME git branch -q -D $PUBLISH_BRANCH_NAME exit 1 @@ -92,9 +93,9 @@ if [ $? != 0 ] then git reset --hard -q HEAD^ git checkout -q $BRANCH_NAME - echo -e $ABORT "Pushing to origin master has failed, there are new remote changes. Run 'sync.sh' to update your master, then run 'git rebase master' to update branch $BRANCH_NAME." + echo -e $ABORT "Pushing to origin master has failed, there are new remote changes. Run 'git-sync-master.sh' to update master and rebase $BRANCH_NAME." exit 1 fi -echo -e $SUCCESS "Published branch $BRANCH_NAME successfully" +echo -e $SUCCESS "Published $BRANCH_NAME successfully" exit 0 diff --git a/script/git-sync-master.sh b/script/git-sync-master.sh index 6ddf8601..e6aaaaee 100755 --- a/script/git-sync-master.sh +++ b/script/git-sync-master.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash ABORT="\033[31mAbort:\033[00m" ALERT="\033[31mAlert:\033[00m" @@ -8,62 +8,89 @@ INFO="\033[33mInfo:\033[00m" BRANCH_NAME=$(git symbolic-ref -q --short HEAD) # check if on branch +echo -e $INFO "Checking on branch" + if [ -z $BRANCH_NAME ] then echo -e $ABORT "You are not on any branch." exit 1 fi -# switch to master -echo -e $INFO "Switching to master" - -git checkout -q master - -if [ $? != 0 ] -then - echo -e $ABORT "Switching to master failed." - exit 1 -fi - # check clean index echo -e $INFO "Checking index" if [[ -n $(git diff HEAD) ]] then - echo -e $ABORT "You have uncommited changes on master." - git checkout -q "$BRANCH_NAME" + echo -e $ABORT "You have uncommited changes." exit 1 fi +# switch to master +if [ $BRANCH_NAME != 'master' ] +then + echo -e $INFO "Switching to master" + git checkout -q master + + if [ $? != 0 ] + then + echo -e $ABORT "Switching to master failed." + exit 1 + fi +fi + # fetch remote changes echo -e $INFO "Fetching changes" - -git fetch -q origin master +git fetch origin master if [ $? != 0 ] then - echo -e $ABORT "Fetching from origin master failed." + echo -e $ABORT "Fetching from origin master failed" git checkout -q "$BRANCH_NAME" exit 1 fi -if [[ -z $(git diff origin/master) ]] -then - echo -e $SUCCESS "Your master is already up-to-date." - git checkout -q "$BRANCH_NAME" - exit 0 -fi - # rebase master to origin/master -git rebase -q origin/master +if [[ -z $(git diff origin/master) ]] +then + echo -e $SUCCESS "Your master is up-to-date" +else + echo -e $INFO "Rebasing to origin/master" + git rebase origin/master + + if [ $? != 0 ] + then + echo -e $ALERT "Rebasing on master caused conflicts. This should never happen. Follow the instructions above to resolve them then use 'git push origin master' to update the remote." + exit 1 + fi + + echo -e $SUCCESS "Updated master" +fi + +if [ $BRANCH_NAME == 'master' ] +then + exit 0 +fi + +# switch to branch +echo -e $INFO "Switching back to $BRANCH_NAME" +git checkout -q "$BRANCH_NAME" if [ $? != 0 ] then - echo -e $ALERT "Rebasing on master caused conflicts. This should never happen. Follow the instructions above to resolve them then use 'git push origin master' to update the remote." + echo -e $ABORT "Switching back to $BRANCH_NAME failed." exit 1 fi -git checkout -q "$BRANCH_NAME" +# rebase branch to master +echo -e $INFO "Rebasing $BRANCH_NAME to master" +git rebase master + +if [ $? != 0 ] +then + echo -e $ALERT "Rebasing $BRANCH_NAME to master caused conflicts. Follow the instructions above to resolve them." + exit 1 +else + echo -e $SUCCESS "$BRANCH_NAME is now up-to-date." +fi -echo -e $SUCCESS "Updated master" exit 0 diff --git a/script/release.sh b/script/release.sh index 7e5fc735..89ae648c 100755 --- a/script/release.sh +++ b/script/release.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # Determine path to script MY_PATH=`dirname "$0"` @@ -6,4 +6,4 @@ MY_PATH=`dirname "$0"` cd $MY_PATH/.. # Build and run target -make -C build/Release "$1" && bin/Release/"$1" +make -C build/Release "$1" && cd bin && Release/"$1" diff --git a/script/setup.sh b/script/setup.sh index 337f05b0..ce27cd4b 100755 --- a/script/setup.sh +++ b/script/setup.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash ABORT="\033[31mAbort:\033[00m" SUCCESS="\033[32mSuccess:\033[00m" diff --git a/script/valgrind_debug.sh b/script/valgrind_debug.sh index 33789891..3e8bbc2b 100755 --- a/script/valgrind_debug.sh +++ b/script/valgrind_debug.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # Determine path to script MY_PATH=`dirname "$0"` @@ -6,4 +6,4 @@ MY_PATH=`dirname "$0"` cd $MY_PATH/.. # Build and run target -make -C build/Debug "$1" && valgrind --tool=memcheck --leak-check=yes --log-file=build/Debug/"$1".leaklog bin/Debug/"$1" +make -C build/Debug "$1" && cd bin && valgrind --tool=memcheck --leak-check=yes --log-file=../build/Debug/"$1".leaklog Debug/"$1" diff --git a/script/valgrind_release.sh b/script/valgrind_release.sh index ce81657e..db9fadef 100755 --- a/script/valgrind_release.sh +++ b/script/valgrind_release.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # Determine path to script MY_PATH=`dirname "$0"` @@ -6,4 +6,4 @@ MY_PATH=`dirname "$0"` cd $MY_PATH/.. # Build and run target -make -C build/Release "$1" && valgrind --tool=memcheck --leak-check=yes --log-file=build/Release/"$1".leaklog bin/Release/"$1" +make -C build/Release "$1" && cd bin && valgrind --tool=memcheck --leak-check=yes --log-file=../build/Release/"$1".leaklog Release/"$1"