2017-10-02 17:47:10 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
echo "Starting API Diff"
|
|
|
|
|
2017-10-03 11:51:55 +00:00
|
|
|
APIHOME=$(dirname $0)
|
|
|
|
|
|
|
|
apiCurrent=$APIHOME/api-current.txt
|
2017-10-02 17:47:10 +00:00
|
|
|
if [ ! -f $apiCurrent ]; then
|
2017-10-03 11:51:55 +00:00
|
|
|
echo "Missing $apiCurrent file - cannot check API diff. Please rebase or add it to this release"
|
2017-10-02 17:47:10 +00:00
|
|
|
exit -1
|
|
|
|
fi
|
|
|
|
|
2017-10-03 11:51:55 +00:00
|
|
|
diffContents=`diff -u $apiCurrent $APIHOME/../build/api/api-corda-*.txt`
|
2017-10-09 16:38:45 +00:00
|
|
|
echo "Diff contents:"
|
2017-10-02 17:47:10 +00:00
|
|
|
echo "$diffContents"
|
2017-10-09 16:38:45 +00:00
|
|
|
echo
|
|
|
|
|
|
|
|
# A removed line means that an API was either deleted or modified.
|
|
|
|
removals=$(echo "$diffContents" | grep "^-\s")
|
|
|
|
removalCount=`grep -v "^$" <<EOF | wc -l
|
|
|
|
$removals
|
|
|
|
EOF
|
|
|
|
`
|
|
|
|
|
|
|
|
echo "Number of API removals/changes: "$removalCount
|
|
|
|
if [ $removalCount -gt 0 ]; then
|
|
|
|
echo "$removals"
|
|
|
|
echo
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Adding new abstract methods could also break the API.
|
|
|
|
newAbstracts=$(echo "$diffContents" | grep "^+\s" | grep "\(public\|protected\) abstract")
|
|
|
|
abstractCount=`grep -v "^$" <<EOF | wc -l
|
|
|
|
$newAbstracts
|
|
|
|
EOF
|
|
|
|
`
|
|
|
|
|
|
|
|
echo "Number of new abstract APIs: "$abstractCount
|
|
|
|
if [ $abstractCount -gt 0 ]; then
|
|
|
|
echo "$newAbstracts"
|
|
|
|
echo
|
|
|
|
fi
|
|
|
|
|
|
|
|
badChanges=$(($removalCount + $abstractCount))
|
|
|
|
|
|
|
|
echo "Exiting with exit code" $badChanges
|
|
|
|
exit $badChanges
|