Skip to content

Commit ca75900

Browse files
committed
Change has_spdx() → has_spdx_or_is_empty()
1 parent 193fee1 commit ca75900

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

toolshed/check_spdx.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ def load_spdx_ignore():
2424
return pathspec.PathSpec.from_lines("gitwildmatch", lines)
2525

2626

27-
def has_spdx(filepath):
27+
def has_spdx_or_is_empty(filepath):
2828
with open(filepath, "rb") as f:
2929
blob = f.read()
30-
return EXPECTED_SPDX_BYTES in blob
30+
return len(blob.strip()) == 0 or EXPECTED_SPDX_BYTES in blob
3131

3232

3333
def main(args):
@@ -37,7 +37,7 @@ def main(args):
3737

3838
returncode = 0
3939
for filepath in args:
40-
if not ignore_spec.match_file(filepath) and not has_spdx(filepath):
40+
if not ignore_spec.match_file(filepath) and not has_spdx_or_is_empty(filepath):
4141
print(f"MISSING {EXPECTED_SPDX_STR} {filepath!r}")
4242
returncode = 1
4343
return returncode

0 commit comments

Comments
 (0)