}
check_cpp_files() {
- DIRECTORIES_TO_BE_TESTED=$1
- DIRECTORIES_NOT_TO_BE_TESTED=$2
+ DIRECTORIES_NOT_TO_BE_TESTED=$1
# Check c++ files
- for TEST_DIR in ${DIRECTORIES_TO_BE_TESTED[@]}; do
- pushd $TEST_DIR
- CPP_FILES_TO_CHECK=$(git ls-files '*.h' '*.cpp' '*.cc' ':!:NeuralNetworks.h')
- ARR=($CPP_FILES_TO_CHECK)
- for s in ${DIRECTORIES_NOT_TO_BE_TESTED[@]}; do
- if [[ $s = $TEST_DIR* ]]; then
- skip=${s#$TEST_DIR/}/
- ARR=(${ARR[*]//$skip*})
- fi
- done
- CPP_FILES_TO_CHECK=${ARR[*]}
- if [[ ${#CPP_FILES_TO_CHECK} -ne 0 ]]; then
- clang-format-3.9 -i $CPP_FILES_TO_CHECK
- EXIT_CODE=$?
- if [[ $EXIT_CODE -ne 0 ]]; then
- INVALID_EXIT=$EXIT_CODE
- fi
- fi
- popd
+ CPP_FILES_TO_CHECK=$(git ls-files '*.h' '*.cpp' '*.cc' ':!:include/NeuralNetworks.h')
+ ARR=($CPP_FILES_TO_CHECK)
+ for s in ${DIRECTORIES_NOT_TO_BE_TESTED[@]}; do
+ skip=${s#'.'/}/
+ ARR=(${ARR[*]//$skip*/})
done
+ CPP_FILES_TO_CHECK=${ARR[*]}
+ if [[ ${#CPP_FILES_TO_CHECK} -ne 0 ]]; then
+ clang-format-3.9 -i $CPP_FILES_TO_CHECK
+ EXIT_CODE=$?
+ if [[ $EXIT_CODE -ne 0 ]]; then
+ INVALID_EXIT=$EXIT_CODE
+ fi
+ fi
}
check_python_files() {
- DIRECTORIES_TO_BE_TESTED=$1
- DIRECTORIES_NOT_TO_BE_TESTED=$2
+ DIRECTORIES_NOT_TO_BE_TESTED=$1
# Check python files
- for TEST_DIR in ${DIRECTORIES_TO_BE_TESTED[@]}; do
- pushd $TEST_DIR
- PYTHON_FILES_TO_CHECK=$(git ls-files '*.py')
- ARR=($PYTHON_FILES_TO_CHECK)
- for s in ${DIRECTORIES_NOT_TO_BE_TESTED[@]}; do
- if [[ $s = $TEST_DIR* ]]; then
- skip=${s#$TEST_DIR/}/
- ARR=(${ARR[*]//$skip*})
- fi
- done
- PYTHON_FILES_TO_CHECK=${ARR[*]}
- if [[ ${#PYTHON_FILES_TO_CHECK} -ne 0 ]]; then
- yapf -i --style='{based_on_style: pep8, column_limit: 90}' $PYTHON_FILES_TO_CHECK
- EXIT_CODE=$?
- if [[ $EXIT_CODE -ne 0 ]]; then
- INVALID_EXIT=$EXIT_CODE
- fi
- fi
- popd
+ PYTHON_FILES_TO_CHECK=$(git ls-files '*.py')
+ ARR=($PYTHON_FILES_TO_CHECK)
+ for s in ${DIRECTORIES_NOT_TO_BE_TESTED[@]}; do
+ skip=${s#'.'/}/
+ ARR=(${ARR[*]//$skip*/})
done
+ PYTHON_FILES_TO_CHECK=${ARR[*]}
+ if [[ ${#PYTHON_FILES_TO_CHECK} -ne 0 ]]; then
+ yapf -i --style='{based_on_style: pep8, column_limit: 90}' $PYTHON_FILES_TO_CHECK
+ EXIT_CODE=$?
+ if [[ $EXIT_CODE -ne 0 ]]; then
+ INVALID_EXIT=$EXIT_CODE
+ fi
+ fi
}
echo "Make sure commit all changes before running this checker."
__Check_CPP=${CHECK_CPP:-"1"}
__Check_PYTHON=${CHECK_PYTHON:-"1"}
-DIRECTORIES_TO_BE_TESTED=()
DIRECTORIES_NOT_TO_BE_TESTED=()
-for DIR_TO_BE_TESTED in $(find -name '.FORMATCHECKED' -exec dirname {} \;); do
- DIRECTORIES_TO_BE_TESTED+=("$DIR_TO_BE_TESTED")
-done
-
for DIR_NOT_TO_BE_TESTED in $(find -name '.FORMATDENY' -exec dirname {} \;); do
DIRECTORIES_NOT_TO_BE_TESTED+=("$DIR_NOT_TO_BE_TESTED")
done
-if [[ ${#DIRECTORIES_TO_BE_TESTED[@]} -eq 0 ]]; then
- echo "No directories to be checked"
- return
-fi
-
check_newline
check_permission
if [[ $__Check_CPP -ne 0 ]]; then
check_cpp_tool
- check_cpp_files $DIRECTORIES_TO_BE_TESTED $DIRECTORIES_NOT_TO_BE_TESTED
+ check_cpp_files $DIRECTORIES_NOT_TO_BE_TESTED
fi
if [[ $__Check_PYTHON -ne 0 ]]; then
check_python_tool
- check_python_files $DIRECTORIES_TO_BE_TESTED $DIRECTORIES_NOT_TO_BE_TESTED
+ check_python_files $DIRECTORIES_NOT_TO_BE_TESTED
fi
git diff --ignore-submodules > format.patch