Travis now checks for missing licences in files.

This commit is contained in:
Jakub Sobon 2018-07-01 16:15:52 -04:00
parent 8e43506e75
commit 4cefd0b77f
No known key found for this signature in database
GPG Key ID: F2451A77FB05D3B7
2 changed files with 15 additions and 3 deletions

View File

@ -10,5 +10,6 @@ script:
- go test -race ./...
- go vet ./...
- diff -u <(echo -n) <(gofmt -d -s .)
- diff -u <(echo -n) <(scripts/autogen_licences.sh .)
after_success:
- ./scripts/coverage.sh

View File

@ -28,7 +28,11 @@ if [ "$#" -eq 0 ]; then
fi
DIRECTORY="$1"
WRITE="$2"
WRITE=""
if [ "$#" -ge 3 ]; then
WRITE="$2"
fi
if [ ! -d "${BIN_DIR}" ]; then
echo "Directory ${BIN_DIR} doesn't exist."
@ -49,16 +53,23 @@ if [ "${WRITE}" == "WRITE" ]; then
DRY_RUN=""
else
DRY_RUN="echo "
echo "The WRITE argument not specified, dry run mode."
echo "Would have executed:"
fi
ADD_LICENCE="${DRY_RUN}${AUTOGEN} -i --no-top-level-comment"
FIND_FILES="find ${DIRECTORY} -type f -name \*.go"
LICENCE="Licensed under the Apache License"
MISSING=0
for FILE in `eval ${FIND_FILES}`; do
if ! grep -q "${LICENCE}" "${FILE}"; then
MISSING=1
eval "${ADD_LICENCE} ${FILE}"
fi
done
if [[ ! -z "$DRY_RUN" ]] && [ $MISSING -eq 1 ]; then
echo -e "\nFound files with missing licences. To fix, run the commands above."
echo "Or just execute:"
echo "$0 . WRITE"
fi