You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tooling.apache.org by sb...@apache.org on 2026/07/09 15:43:54 UTC
(tooling-trusted-releases) branch sbp updated: Skip empty files in lightweight license checks
This is an automated email from the ASF dual-hosted git repository.
sbp pushed a commit to branch sbp
in repository https://gitbox.apache.org/repos/asf/tooling-trusted-releases.git
The following commit(s) were added to refs/heads/sbp by this push:
new 58079ab1 Skip empty files in lightweight license checks
58079ab1 is described below
commit 58079ab1b2f2cd557e6bb8b5fbd8cde98564d967
Author: Sean B. Palmer <se...@miscoranda.com>
AuthorDate: Thu Jul 9 16:43:26 2026 +0100
Skip empty files in lightweight license checks
---
atr/tasks/checks/license.py | 7 ++++++-
tests/unit/test_checks_license.py | 16 ++++++++++++++++
2 files changed, 22 insertions(+), 1 deletion(-)
diff --git a/atr/tasks/checks/license.py b/atr/tasks/checks/license.py
index 664332dd..87313ba0 100644
--- a/atr/tasks/checks/license.py
+++ b/atr/tasks/checks/license.py
@@ -83,7 +83,7 @@ INCLUDED_PATTERNS: Final[list[str]] = [
INPUT_POLICY_KEYS: Final[list[str]] = ["license_check_mode", "source_excludes_lightweight"]
INPUT_EXTRA_ARGS: Final[list[str]] = ["is_podling"]
CHECK_VERSION_FILES: Final[str] = "6"
-CHECK_VERSION_HEADERS: Final[str] = "4"
+CHECK_VERSION_HEADERS: Final[str] = "5"
_BINARY_LICENSE_FILENAMES: Final[frozenset[str]] = frozenset({"LICENSE", "LICENSE.txt"})
_BINARY_NOTICE_FILENAMES: Final[frozenset[str]] = frozenset({"NOTICE", "NOTICE.txt"})
@@ -543,6 +543,11 @@ def _headers_check_core_logic_process_file(
# That may be shebangs, encoding declarations, etc.
with open(file_path, "rb") as f:
content = f.read(4096)
+ if (len(content) < 4096) and (not content.strip()):
+ return MemberSkippedResult(
+ path=rel_path,
+ reason="Empty file",
+ )
is_valid, error = headers_validate(content, rel_path)
if is_valid:
return MemberResult(
diff --git a/tests/unit/test_checks_license.py b/tests/unit/test_checks_license.py
index fb9a67b8..332c6fd2 100644
--- a/tests/unit/test_checks_license.py
+++ b/tests/unit/test_checks_license.py
@@ -229,6 +229,22 @@ def test_headers_check_data_fields_match_model(tmp_path):
assert actual_fields == expected_fields
+def test_headers_check_empty_source_files_skipped(tmp_path):
+ temp_dir = safe.StatePath(tmp_path)
+ cache_dir = temp_dir / "empty_cache"
+ cache_dir.path.mkdir()
+ root = cache_dir / "apache-test-0.2"
+ root.path.mkdir()
+ (root / "__init__.py").path.write_bytes(b"")
+ (root / "blank.py").path.write_bytes(b"\n")
+ results = list(license._headers_check_core_logic(cache_dir, TEST_ARCHIVE_BASENAME, [], "none"))
+ member_results = [r for r in results if isinstance(r, license.MemberResult)]
+ assert member_results == []
+ final_result = [r for r in results if isinstance(r, license.ArtifactResult)][-1]
+ assert final_result.data["files_checked"] == 0
+ assert final_result.data["files_skipped"] == 2
+
+
def test_headers_check_excludes_matching_files(tmp_path):
cache_dir = _extract_test_archive(tmp_path)
results_without_excludes = list(license._headers_check_core_logic(cache_dir, TEST_ARCHIVE_BASENAME, [], "none"))
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@tooling.apache.org
For additional commands, e-mail: commits-help@tooling.apache.org