From 94de9334836175fb894e990edac72ef30d7cd47e Mon Sep 17 00:00:00 2001 From: Troy Ronda Date: Tue, 28 Nov 2017 21:20:11 -0500 Subject: [PATCH] [FAB-7183] 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. Change-Id: I79417c28f47869a0c336dbbcd226e5a78d3c5daa Signed-off-by: Troy Ronda --- test/scripts/check_license.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/test/scripts/check_license.sh b/test/scripts/check_license.sh index 367cc7c70d..8cd291691d 100755 --- a/test/scripts/check_license.sh +++ b/test/scripts/check_license.sh @@ -12,13 +12,12 @@ 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")) - filterExcludedFiles + 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 if [[ -z "$CHECK" ]]; then