From 2357b29571f7b46859a6841d82a4b88b366c037f Mon Sep 17 00:00:00 2001 From: Eduardo Ramos Testillano Date: Tue, 25 Jun 2013 03:21:36 +0200 Subject: [PATCH] pre-commit with auto fixing --- pre-commit.sh | 15 ++++++++++----- source/core/util/Environment.cpp | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/pre-commit.sh b/pre-commit.sh index 2771db8..e9ded58 100755 --- a/pre-commit.sh +++ b/pre-commit.sh @@ -93,13 +93,18 @@ test_style () { $ASTYLE -a -f -p -o -O -c -s2 -U -x --mode=c < $file > $newfile 2>>/dev/null diff "${file}" "${newfile}" r=$? - rm "${newfile}" if [ $r != 0 ] ; then echo "Code style error in '$file', please fix before commiting." - echo "To autofix, create a hidden file named './.fix_style' on suite root." -pwd -echo xxxx - exit 1 + if [ -f "./.fix_style" ]; then + echo "Auto-fixing code style..." + mv $newfile $file + else + echo "To autofix, create a hidden file named './.fix_style' on suite root." + rm $newfile + exit 1 + fi + else + rm $newfile fi } diff --git a/source/core/util/Environment.cpp b/source/core/util/Environment.cpp index c00d9a5..83ed2f8 100644 --- a/source/core/util/Environment.cpp +++ b/source/core/util/Environment.cpp @@ -112,7 +112,7 @@ std::string Environment::getValue(const char* variableName, bool exceptionIfMiss std::map::const_iterator it = a_managedVars.find(variableName); - if (it == a_managedVars.end()) { + if(it == a_managedVars.end()) { std::string msg = "The variable '"; msg += variableName; msg += "' is not defined in the environment."; -- 2.20.1