scripts: replaced echo with echo -e for color in linux (maybe windows)

This commit is contained in:
Andreas Stallinger
2014-03-31 20:42:53 +02:00
parent 055b3d0029
commit f61425b4e8
4 changed files with 32 additions and 32 deletions
+1 -1
View File
@@ -12,4 +12,4 @@ rm -rf lib
rm -rf bin/Debug rm -rf bin/Debug
rm -rf bin/Release rm -rf bin/Release
echo $SUCCESS "clean complete" echo -e $SUCCESS "clean complete"
+14 -14
View File
@@ -4,43 +4,43 @@ ABORT="\033[31mAbort:\033[00m"
SUCCESS="\033[32mSuccess:\033[00m" SUCCESS="\033[32mSuccess:\033[00m"
INFO="\033[33mInfo:\033[00m" INFO="\033[33mInfo:\033[00m"
echo $INFO "Checking index" echo -e $INFO "Checking index"
# check clean index # check clean index
if [[ -n $(git diff HEAD) ]] if [[ -n $(git diff HEAD) ]]
then then
echo $ABORT "You have uncommited changes." echo -e $ABORT "You have uncommited changes."
exit 1 exit 1
fi fi
BRANCH_NAME=$(git symbolic-ref -q --short HEAD) BRANCH_NAME=$(git symbolic-ref -q --short HEAD)
PUBLISH_BRANCH_NAME=_publish_"$BRANCH_NAME"_ PUBLISH_BRANCH_NAME=_publish_"$BRANCH_NAME"_
echo $INFO "Checking branch $BRANCH_NAME" echo -e $INFO "Checking branch $BRANCH_NAME"
# check if on branch # check if on branch
if [ -z $BRANCH_NAME ] if [ -z $BRANCH_NAME ]
then then
echo $ABORT "You are not on any branch." echo -e $ABORT "You are not on any branch."
exit 1 exit 1
fi fi
# check if on master # check if on master
if [ $BRANCH_NAME == "master" ] if [ $BRANCH_NAME == "master" ]
then then
echo $ABORT "You are on master. Use this script only from a feature branch." echo -e $ABORT "You are on master. Use this script only from a feature branch."
exit 1 exit 1
fi fi
git checkout -q master git checkout -q master
git remote update &>/dev/null git remote update &>/dev/null
echo $INFO "Checking master" echo -e $INFO "Checking master"
# check if master is up to date # check if master is up to date
if [[ -n $(git diff origin/master) ]] if [[ -n $(git diff origin/master) ]]
then then
echo $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 'sync.sh' to update your master, then run 'git rebase master' to update branch $BRANCH_NAME."
git checkout -q $BRANCH_NAME git checkout -q $BRANCH_NAME
exit 1 exit 1
fi fi
@@ -55,21 +55,21 @@ BRANCH_HEAD_COMMIT=$(git rev-parse HEAD)
# check if feature has commits # check if feature has commits
if [ $BRANCH_HEAD_COMMIT == $MASTER_HEAD_COMMIT ] if [ $BRANCH_HEAD_COMMIT == $MASTER_HEAD_COMMIT ]
then then
echo $ABORT "Your feature branch has no commits." echo -e $ABORT "Your feature branch has no commits."
exit 1 exit 1
fi fi
# check if feature is not behind master # check if feature is not behind master
if [ $BASE_COMMIT != $MASTER_HEAD_COMMIT ] if [ $BASE_COMMIT != $MASTER_HEAD_COMMIT ]
then then
echo $ABORT "Your feature branch is behind master. Use 'git rebase master' to update your feature branch." echo -e $ABORT "Your feature branch is behind master. Use 'git rebase master' to update your feature branch."
exit 1 exit 1
fi fi
# switch to temporary branch for squashing # switch to temporary branch for squashing
git checkout -q -b $PUBLISH_BRANCH_NAME git checkout -q -b $PUBLISH_BRANCH_NAME
echo $INFO "Squashing commits" echo -e $INFO "Squashing commits"
git reset --soft $BASE_COMMIT git reset --soft $BASE_COMMIT
git commit git commit
@@ -80,21 +80,21 @@ then
exit 1 exit 1
fi fi
echo $INFO "Rebasing on master" echo -e $INFO "Rebasing on master"
git checkout -q master git checkout -q master
git rebase -q $PUBLISH_BRANCH_NAME git rebase -q $PUBLISH_BRANCH_NAME
git branch -q -d $PUBLISH_BRANCH_NAME git branch -q -d $PUBLISH_BRANCH_NAME
echo $INFO "Uploading to origin master" echo -e $INFO "Uploading to origin master"
git push origin master git push origin master
if [ $? != 0 ] if [ $? != 0 ]
then then
git reset --hard -q HEAD^ git reset --hard -q HEAD^
git checkout -q $BRANCH_NAME git checkout -q $BRANCH_NAME
echo $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 'sync.sh' to update your master, then run 'git rebase master' to update branch $BRANCH_NAME."
exit 1 exit 1
fi fi
echo $SUCCESS "Published branch $BRANCH_NAME successfully" echo -e $SUCCESS "Published branch $BRANCH_NAME successfully"
exit 0 exit 0
+10 -10
View File
@@ -10,46 +10,46 @@ BRANCH_NAME=$(git symbolic-ref -q --short HEAD)
# check if on branch # check if on branch
if [ -z $BRANCH_NAME ] if [ -z $BRANCH_NAME ]
then then
echo $ABORT "You are not on any branch." echo -e $ABORT "You are not on any branch."
exit 1 exit 1
fi fi
# switch to master # switch to master
echo $INFO "Switching to master" echo -e $INFO "Switching to master"
git checkout -q master git checkout -q master
if [ $? != 0 ] if [ $? != 0 ]
then then
echo $ABORT "Switching to master failed." echo -e $ABORT "Switching to master failed."
exit 1 exit 1
fi fi
# check clean index # check clean index
echo $INFO "Checking index" echo -e $INFO "Checking index"
if [[ -n $(git diff HEAD) ]] if [[ -n $(git diff HEAD) ]]
then then
echo $ABORT "You have uncommited changes on master." echo -e $ABORT "You have uncommited changes on master."
git checkout -q "$BRANCH_NAME" git checkout -q "$BRANCH_NAME"
exit 1 exit 1
fi fi
# fetch remote changes # fetch remote changes
echo $INFO "Fetching changes" echo -e $INFO "Fetching changes"
git fetch -q origin master git fetch -q origin master
if [ $? != 0 ] if [ $? != 0 ]
then then
echo $ABORT "Fetching from origin master failed." echo -e $ABORT "Fetching from origin master failed."
git checkout -q "$BRANCH_NAME" git checkout -q "$BRANCH_NAME"
exit 1 exit 1
fi fi
if [[ -z $(git diff origin/master) ]] if [[ -z $(git diff origin/master) ]]
then then
echo $SUCCESS "Your master is already up-to-date." echo -e $SUCCESS "Your master is already up-to-date."
git checkout -q "$BRANCH_NAME" git checkout -q "$BRANCH_NAME"
exit 0 exit 0
fi fi
@@ -59,11 +59,11 @@ git rebase -q origin/master
if [ $? != 0 ] if [ $? != 0 ]
then then
echo $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 $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 exit 1
fi fi
git checkout -q "$BRANCH_NAME" git checkout -q "$BRANCH_NAME"
echo $SUCCESS "Updated master" echo -e $SUCCESS "Updated master"
exit 0 exit 0
+7 -7
View File
@@ -19,7 +19,7 @@ MY_PATH=`dirname "$0"`
cd $MY_PATH/.. cd $MY_PATH/..
# git settings # git settings
echo $INFO "install git settings" echo -e $INFO "install git settings"
git config commit.template .git_commit_template.txt git config commit.template .git_commit_template.txt
git config color.ui true git config color.ui true
@@ -27,7 +27,7 @@ cp .git_pre_commit_hook.sh .git/hooks/pre-commit
# Create Debug and Release folders # Create Debug and Release folders
echo $INFO "create build folders" echo -e $INFO "create build folders"
mkdir -p build mkdir -p build
mkdir -p lib mkdir -p lib
@@ -36,11 +36,11 @@ mkdir -p bin/Release
# Copy necessary dynamic libraries to bin folder # Copy necessary dynamic libraries to bin folder
if [ $PLATFORM == "Windows" ]; then if [ $PLATFORM == "Windows" ]; then
echo $INFO "copy dynamic libraries" echo -e $INFO "copy dynamic libraries"
cp -u -r setup/dynamic_libraries/windows/Debug/* bin/Debug cp -u -r setup/dynamic_libraries/windows/Debug/* bin/Debug
cp -u -r setup/dynamic_libraries/windows/Release/* bin/Release cp -u -r setup/dynamic_libraries/windows/Release/* bin/Release
echo $INFO "copy test_main file" echo -e $INFO "copy test_main file"
cp -u setup/cxx_test/windows/test_main.cpp build cp -u setup/cxx_test/windows/test_main.cpp build
fi fi
@@ -49,11 +49,11 @@ if [ $PLATFORM == "Linux" ] || [ $PLATFORM == "MacOS" ]; then
mkdir -p build/Debug mkdir -p build/Debug
mkdir -p build/Release mkdir -p build/Release
echo $INFO "run cmake with Debug configuration" echo -e $INFO "run cmake with Debug configuration"
cd build/Debug && cmake -DCMAKE_BUILD_TYPE="Debug" ../.. cd build/Debug && cmake -DCMAKE_BUILD_TYPE="Debug" ../..
echo $INFO "run cmake with Release configuration" echo -e $INFO "run cmake with Release configuration"
cd ../Release && cmake -DCMAKE_BUILD_TYPE="Release" ../.. cd ../Release && cmake -DCMAKE_BUILD_TYPE="Release" ../..
fi fi
echo $SUCCESS "setup complete" echo -e $SUCCESS "setup complete"