Fix copyright checker (#4954)
author오형석/On-Device Lab(SR)/Staff Engineer/삼성전자 <hseok82.oh@samsung.com>
Tue, 9 Apr 2019 11:13:01 +0000 (20:13 +0900)
committer이성재/On-Device Lab(SR)/Principal Engineer/삼성전자 <sj925.lee@samsung.com>
Tue, 9 Apr 2019 11:13:01 +0000 (20:13 +0900)
Rename copyright check script
Change mode: remove execution and allow only source (by nnfw command)
Exit with exit code when invalid result

Signed-off-by: Hyeongseok Oh <hseok82.oh@samsung.com>
scripts/command/copyright-check [moved from scripts/command/copyright-checker.sh with 91% similarity, mode: 0644]

old mode 100755 (executable)
new mode 100644 (file)
similarity index 91%
rename from scripts/command/copyright-checker.sh
rename to scripts/command/copyright-check
index 9f2201f..9401e69
@@ -1,5 +1,7 @@
 #!/bin/bash
 
+INVALID_EXIT=0
+
 check_copyright_year() {
     DIRECTORIES_NOT_TO_BE_TESTED=$2
     YEAR=`date +"%Y"`
@@ -30,8 +32,10 @@ check_copyright_year() {
             if [[ $COPYRIGHT_YEAR != $YEAR ]]; then
                 [[ -z "$COPYRIGHT_YEAR" ]] && COPYRIGHT_YEAR="None"
                 echo "Copyright year of $f is incorrect: expected $YEAR, found $COPYRIGHT_YEAR"
+                INVALID_EXIT=1
             elif ! grep -q "$CORRECT_COPYRIGHT" $f; then
                 echo "Copyright format of $f is incorrect: expected $CORRECT_COPYRIGHT"
+                INVALID_EXIT=1
             fi
         done
     fi
@@ -44,3 +48,8 @@ for DIR_NOT_TO_BE_TESTED in $(find -name '.FORMATDENY' -exec dirname {} \;); do
 done
 
 check_copyright_year $DIRECTORIES_NOT_TO_BE_TESTED
+
+if [[ $INVALID_EXIT -ne 0 ]]; then
+    echo "[FAILED] Invalid copyright check exit."
+    exit 1
+fi