Add check Ada unit for status (style or semantic changes)
authorPascal Obry <[email protected]>
Sat, 11 May 2013 17:48:09 +0000 (11 19:48 +0200)
committerPascal Obry <[email protected]>
Sat, 11 May 2013 17:48:09 +0000 (11 19:48 +0200)
pre-commit

index bdb65b6..cc0c19e 100755 (executable)
@@ -49,6 +49,7 @@ esac
 # Process each file
 
 function check() {
+   oid=$3
    id=$4
    mode=$(echo $5 | cut -c1)
 
@@ -96,6 +97,25 @@ function check() {
        echo $nfile >> $REP/.files.added
    fi
 
+   #  For Ada file, check change status, we normalize the old and new version
+   #  of the unit and check the diff. No diff means that the changes are only
+   #  reformatting and/or style fixes.
+
+   if [[ ! -z $(which normalize) ]]; then
+       file_ext=${bfile##*.}
+       if [[ "$file_ext" == "adb" || "$file_ext" == "ads" ]]; then
+           git show $oid > $REP/ofile
+           normalize $REP/ofile > $REP/n_ofile
+           normalize $REP/$bfile > $REP/n_nfile
+           diff -q $REP/n_ofile $REP/n_nfile > /dev/null
+           if [ $? = 0 ]; then
+               echo "$nfile: has no semantic changes (style changes only)"
+           fi
+       fi
+   fi
+
+   # style checker
+
    ( cd $REP; style_checker $SC_OPTS -n "$nfile" "$bfile"; )
    res=$(($res + $?))
    rm -f $REP/$bfile