X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=tools%2Flicense_scan.sh;h=a79463608d09fdbf43a65ef716445700d1ab7e2d;hb=02467edd88623ef5345402566319867f5fbef84a;hp=b20bb0afb9002c8c8e5706a70ebf520f742de5f4;hpb=da8ffbc7b1821ad32db2c79c586efc755ca5782b;p=osm%2Fdevops.git diff --git a/tools/license_scan.sh b/tools/license_scan.sh index b20bb0af..a7946360 100755 --- a/tools/license_scan.sh +++ b/tools/license_scan.sh @@ -22,15 +22,31 @@ exception_list="':(exclude)*.pdf' ':(exclude)*.png' ':(exclude)*.jpeg' ':(exclud git fetch for file in $(echo ${exception_list} | xargs git diff --name-only origin/$GERRIT_BRANCH -- . ); do - license="No Apache license found" - if [ -f $file ]; then - if [ -s $file ]; then - if [ $(grep -c "http://www.apache.org/licenses/LICENSE-2.0" $file) -ge 1 ] ; then - license="Apache-2.0" + + file_type=$(file -b --mime-type $file | sed 's|/.*||') + echo $file is $file_type + case "$file_type" in + text) + binary=false + ;; + *) + binary=true + ;; + esac + + if $binary ; then + license=Binary + else + license="No Apache license found" + if [ -f $file ]; then + if [ -s $file ]; then + if [ $(grep -c "http://www.apache.org/licenses/LICENSE-2.0" $file) -ge 1 ] ; then + license="Apache-2.0" + fi fi + else + license="DELETED" fi - else - license="DELETED" fi echo "$file $license" case "$license" in @@ -42,6 +58,8 @@ for file in $(echo ${exception_list} | xargs git diff --name-only origin/$GERRIT ;; "DELETED") ;; + "Binary") + ;; *) echo "BAD LICENSE ON FILE $file" other=$((other + 1))