#!/usr/bin/env bash

source $(dirname $0)/env.sh

cd $LUNA_ROOT

source tools/sources.sh

ALL_OK=1

for f in ${SOURCES[@]}
do
    clang-format -n $f 2>&1 | grep -q ^
    RESULT=$?
    if [ "$RESULT" -eq "0" ]
    then
        echo "File $f needs formatting"
        ALL_OK=0
    fi
done

if [ $ALL_OK = "1" ]
then
    echo "All files OK"
    exit 0
fi

exit 1