55REPO_ROOT=" $( git rev-parse --show-toplevel) "
66cd " $REPO_ROOT " || exit 1
77
8- # Define the license header pattern to look for
9- LICENSE_PATTERN=" Copyright .* The Hyperlight Authors..*Licensed under the Apache License, Version 2.0"
8+ # Define the license patterns to look for
9+ SPDX_PATTERN=" ^// SPDX-License-Identifier: Apache-2\.0$"
10+ COPYRIGHT_PATTERN=" ^// Copyright .* The Hyperlight Authors\.$"
1011
1112# Define the full license header for files that need it
12- LICENSE_HEADER=' /*
13- Copyright 2025 The Hyperlight Authors.
14-
15- Licensed under the Apache License, Version 2.0 (the "License");
16- you may not use this file except in compliance with the License.
17- You may obtain a copy of the License at
18-
19- http://www.apache.org/licenses/LICENSE-2.0
20-
21- Unless required by applicable law or agreed to in writing, software
22- distributed under the License is distributed on an "AS IS" BASIS,
23- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24- See the License for the specific language governing permissions and
25- limitations under the License.
26- */
27-
28- '
13+ YEAR=" $( date +" %Y" ) "
14+ LICENSE_HEADER=" // SPDX-License-Identifier: Apache-2.0
15+ // Copyright $YEAR The Hyperlight Authors.
16+ "
2917
3018# Initialize a variable to track missing headers
3119MISSING_HEADERS=0
@@ -43,8 +31,8 @@ while IFS= read -r -d $'\0' file; do
4331 continue
4432 fi
4533
46- # Check if the file has the license header (allowing for multi-line matching)
47- if ! grep -q -z " $LICENSE_PATTERN " " $file " ; then
34+ header= " $( head -2 " $file " ) "
35+ if ! grep -q " $SPDX_PATTERN " <<< " $header " || ! grep -q " $COPYRIGHT_PATTERN " <<< " $header " ; then
4836 echo " Missing or invalid license header in $file "
4937 MISSING_FILES=" $MISSING_FILES \n $file "
5038 MISSING_HEADERS=$(( MISSING_HEADERS + 1 ))
0 commit comments