check_license misses some newly added files
This patch fixes the check_license script to detect new files
in previous commits and also include cached files in local
changes.
The script wasn't properly detecting new files due to a
reversal in the commit hashes in git diff-tree.
@@ -12,12 +12,11 @@ function filterExcludedFiles {
| grep -v .md$ | grep -v ^vendor/ | grep -v ^build/ | grep -v .pb.go$ | sort -u`
}
-CHECK=$(git diff --name-only HEAD --diff-filter=ACMRTUXB *)
+CHECK=$(git diff --name-only HEAD --diff-filter=ACMRTUXB --cached)
filterExcludedFiles
-
if [[ -z "$CHECK" ]]; then
- CHECK=$(git diff-tree --no-commit-id --name-only --diff-filter=ACMRTUXB -r $(git log -2 \
- --pretty=format:"%h"))
+ LAST_COMMITS=($(git log -2 --pretty=format:"%h"))
+ CHECK=$(git diff-tree --no-commit-id --name-only --diff-filter=ACMRTUXB -r ${LAST_COMMITS[1]} ${LAST_COMMITS[0]})
filterExcludedFiles
fi
