Skip to content

Commit 3c8de5c

Browse files
committed
refactor: copyright_check script with better if else handling
1 parent 082be4d commit 3c8de5c

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

script/check_copyright_year.sh

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,27 @@ SPDX_LINE="SPDX-License-Identifier: MIT"
1515

1616
check_file() {
1717
local file=$1
18+
local basename="${file##*/}"
1819
local ext="${file##*.}"
1920
local comment_char
2021

21-
# Determine comment character based on file extension
22-
case "$ext" in
23-
cpp|hpp|inc)
24-
comment_char="//"
25-
;;
26-
py|sh|cmake)
27-
comment_char="#"
28-
;;
29-
*)
30-
# If the filename is *.cmake or CMakeLists.txt, use #
31-
if [[ "$file" == *CMakeLists.txt ]] || [[ "$file" == *.cmake ]]; then
22+
# Determine comment character based on filename or extension
23+
if [[ "$basename" == "CMakeLists.txt" ]]; then
24+
comment_char="#"
25+
else
26+
case "$ext" in
27+
cpp|hpp|inc)
28+
comment_char="//"
29+
;;
30+
py|sh|cmake)
3231
comment_char="#"
33-
else
32+
;;
33+
*)
3434
# Skip files with unsupported extensions
3535
return 0
36-
fi
37-
;;
38-
esac
36+
;;
37+
esac
38+
fi
3939

4040
# Build expected header patterns
4141
expected_copyright="$comment_char $COPYRIGHT_LINE"

0 commit comments

Comments
 (0)