Commit 8c5ec3a5 authored by Stefan Doehla's avatar Stefan Doehla
Browse files

[fix] check-format.sh script to also work with git

parent edc72906
Loading
Loading
Loading
Loading
Loading
+17 −4
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@

if [ ! -d "lib_com" ]; then
    echo "not in root directory! - please run in IVAS root"
    exit 1
    exit 255
fi

CLANG_FORMAT=clang-format
@@ -161,7 +161,7 @@ fi
if [ -z "$FILES" ]; then
    if [ $ALL ]; then
        FILES=$(ls lib*/*.[c,h] apps/*.[c,h])
    else
    elif [ -d ".svn" ]; then
        if [ ! -x "$(command -v svn)" ]; then
            echo "Subversion doesn't seem to be installed. Please ensure svn is in your PATH"
            exit 3
@@ -171,6 +171,19 @@ if [ -z "$FILES" ]; then
        else
            FILES=$(svn st | grep '^M' | cut -b 9- | grep '\.c$\|\.h$')
        fi
    elif [ -d ".git" ]; then
        if [ ! -x "$(command -v git)" ]; then
            echo "GIT doesn't seem to be installed. Please ensure git is in your PATH"
            exit 3
        fi
        if [[ "$OSTYPE" == "darwin"* ]]; then
            FILES=$(git status | grep 'modified: ' | cut -b 14- | grep -E "\.c|\.h")
        else
            FILES=$(git status | grep 'modified: ' | cut -b 14- | grep '\.c$\|\.h$')
        fi
    else
        echo "Warning: no files checked (either no cmdl params or no modified files)"
        exit 0
    fi
    for i in ${EXCLUDE_FILES}; do
        FILES=$(echo ${FILES} | xargs -n 1 | grep -v ${i} | tr '\n' ' ')
@@ -189,7 +202,7 @@ if [[ $NUMPROCS -lt 2 ]]; then
    done
    if [[ $NUMFAILS -gt 0 ]]; then
        echo "Total fails:  $NUMFAILS"
        exit 1
        exit $NUMFAILS
    fi
else
    # parallel processing. Note that return code is always 0 then and fails are not counted