Skip to content

Commit

Permalink
Update license headers to SPDX identifier
Browse files Browse the repository at this point in the history
Signed-off-by: Prabhat Kumar Sahu <[email protected]>
  • Loading branch information
thecaffeinedev authored Aug 8, 2024
1 parent 141a122 commit 7f0d5ea
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions scripts/update_license_headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ def update_license_header(file_path, dry_run=False):
with open(file_path, 'r') as file:
content = file.read()

# Pattern to match the old header
header_pattern = re.compile(r'(?s)(// Copyright.*?)\n.*?limitations under the License\.\s*')
# Pattern to match the old header or the new SPDX header
header_pattern = re.compile(r'(?s)(// Copyright.*?)\n(.*?limitations under the License\.|// SPDX-License-Identifier: Apache-2\.0)\s*')

match = header_pattern.match(content)
if match:
if "SPDX-License-Identifier: Apache-2.0" in match.group(2):
print(f"Skipping {file_path}: SPDX identifier already present")
return False

if dry_run:
print(f"Would update {file_path}")
return True
Expand Down

0 comments on commit 7f0d5ea

Please sign in to comment.