Skip to content

Commit 3bcbd80

Browse files
committed
Split out static, and dynamic exclude lists
1 parent 32269f3 commit 3bcbd80

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

.github/workflows/scripts/check-license-header.sh

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,20 @@ fi
3939

4040
paths_with_missing_license=( )
4141

42+
static_exclude_list=( )
43+
static_exclude_list+=( '":(exclude).license_header_template"' )
44+
static_exclude_list+=( '":(exclude).swift-version"' ) # Swift version files do not have comments nor licenses in them
45+
dynamic_exclude_list=( )
46+
4247
if [[ -f .licenseignore ]]; then
43-
static_exclude_list='":(exclude).licenseignore" ":(exclude).license_header_template" '
44-
dynamic_exclude_list=$(tr '\n' '\0' < .licenseignore | xargs -0 -I% printf '":(exclude)%" ')
45-
exclude_list=$static_exclude_list$dynamic_exclude_list
46-
else
47-
exclude_list=":(exclude).license_header_template"
48+
static_exclude_list+=( '":(exclude).licenseignore"' )
49+
IFS=$'\n' read -d '' -r -a dynamic_exclude_list <<< $(sed -E 's/^(.*)$/":(exclude)\1"/' <.licenseignore)
4850
fi
4951

50-
exclude_list="${exclude_list}:(exclude).swift-version" # Swift version files will never have license headers in them
52+
exclude_list=( "${static_exclude_list[@]}" "${dynamic_exclude_list[@]}" )
53+
excludes=$(IFS=" " ; echo "${exclude_list[*]}")
5154

52-
file_paths=$(echo "$exclude_list" | xargs git ls-files)
55+
file_paths=$(echo "$excludes" | xargs git ls-files)
5356

5457
while IFS= read -r file_path; do
5558
file_basename=$(basename -- "${file_path}")

0 commit comments

Comments
 (0)