From ec5392e95850d2f58e9ed092d4f4eb20706f7cbb Mon Sep 17 00:00:00 2001
From: Florian Uhlig <f.uhlig@gsi.de>
Date: Fri, 24 Sep 2021 11:24:46 +0200
Subject: [PATCH] Improve license header test script

Add the external directories to the list of directories which shouln't be
tested.
Only test a file that exists. This solves a problem when files are removed
from the repository.
---
 scripts/check-licence-header.sh | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/scripts/check-licence-header.sh b/scripts/check-licence-header.sh
index 480e370f19..a9b2502c26 100755
--- a/scripts/check-licence-header.sh
+++ b/scripts/check-licence-header.sh
@@ -9,6 +9,10 @@
 # For all the directories/files listed in the array an explanation should be given.
 
 excludes=(
+# The directory external is excluded from the check since this directory
+# contains code which isn't part of CbmRoot but external dependencies so
+# we don't have to test for our license header
+external
 # The directory is excluded since the files have a license header
 # inherited from the ALICE experiment. The code was copied by the
 # original author when he started working for CBM.
@@ -83,7 +87,7 @@ for FILE in $CHANGED_FILES; do
   for EXCLUDE in "${excludes[@]}"; do
     FILE=$(echo $FILE | egrep -v "$EXCLUDE")
   done
-  if [[ -n $FILE ]]; then
+  if [[ -n $FILE && -f $FILE ]]; then
     licenceHeaderCheck $FILE
   fi
 done
-- 
GitLab