Skip to content

Commit

Permalink
Ensure we know about the SPDX short-form license names.
Browse files Browse the repository at this point in the history
  • Loading branch information
tzarc committed Sep 19, 2023
1 parent c2570cd commit 1664e00
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/python/qmk/cli/license_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,20 @@ def _detect_license_from_file_contents(filename, absolute=False):
if 'SPDX-License-Identifier:' in data:
res = data.split('SPDX-License-Identifier:')
license = re.split(r'\s|//|\*', res[1].strip())[0].strip()
found = False
for short_license, _ in LICENSE_TEXTS:
if license.lower() == short_license.lower():
license = short_license
found = True
break

if not found:
if cli.args.short:
print(f'{filename_out} UNKNOWN')
else:
cli.log.error(f'{{fg_cyan}}{filename_out}{{fg_reset}} -- unknown license, or no license detected!')
return False

if cli.args.short:
print(f'{filename_out} {license}')
else:
Expand Down

0 comments on commit 1664e00

Please sign in to comment.