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/05/20 14:45:09 UTC

(tooling-trusted-releases) branch sbp updated: Document that lightweight excludes can be archive scoped

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 22ed6971 Document that lightweight excludes can be archive scoped
22ed6971 is described below

commit 22ed6971f8f22ce8e2eb8ed0a40355d220b8af6b
Author: Sean B. Palmer <se...@miscoranda.com>
AuthorDate: Wed May 20 15:43:53 2026 +0100

    Document that lightweight excludes can be archive scoped
---
 atr/docs/license-checks.md        | 13 ++++++++++++-
 atr/shared/projects.py            |  3 ++-
 tests/unit/test_checks_license.py | 33 +++++++++++++++++++++++++--------
 3 files changed, 39 insertions(+), 10 deletions(-)

diff --git a/atr/docs/license-checks.md b/atr/docs/license-checks.md
index b0a3c40d..adc6984e 100644
--- a/atr/docs/license-checks.md
+++ b/atr/docs/license-checks.md
@@ -83,4 +83,15 @@ When editing a project, look for the **License Check Exclusions** fields:
 * **RAT Exclusions**: newline-separated patterns to exclude from RAT checks.
 * **Lightweight Exclusions**: newline-separated patterns to exclude from lightweight checks.
 
-These settings follow the project, not the artifact.
+These settings are stored on the project, but individual patterns may be scoped to one archive.
+
+### Scoping lightweight excludes to one archive
+
+Lightweight source excludes use `.gitignore` syntax and match `/<archive-filename>/<path inside the archive>`. Use an unrooted pattern (no leading `/`) to apply to all source archives, or prefix with `/` and an archive filename glob to target one archive:
+
+```text
+**/vendor/**
+/maven-mvnd-*-src*/**/build/publish-on-homebrew.sh
+```
+
+RAT excludes and check-result ignores are configured separately.
diff --git a/atr/shared/projects.py b/atr/shared/projects.py
index 66878bd4..b9b67593 100644
--- a/atr/shared/projects.py
+++ b/atr/shared/projects.py
@@ -120,7 +120,8 @@ class ComposePolicyForm(form.Form):
     source_excludes_lightweight: str = form.label(
         "Lightweight source excludes",
         "Patterns using .gitignore syntax for files to exclude"
-        " from lightweight license header checks on source artifacts.",
+        " from lightweight license header checks on source artifacts."
+        " Prefix with /archive-pattern/ to scope a pattern to one archive (globs allowed).",
         widget=form.Widget.TEXTAREA,
         rows=3,
     )
diff --git a/tests/unit/test_checks_license.py b/tests/unit/test_checks_license.py
index 57a0f533..fb9a67b8 100644
--- a/tests/unit/test_checks_license.py
+++ b/tests/unit/test_checks_license.py
@@ -203,6 +203,22 @@ def test_files_valid_license_and_notice(tmp_path):
     assert all(r.status == sql.CheckResultStatus.NOTE for r in artifact_results)
 
 
+def test_headers_check_archive_qualified_pattern_matches_only_matching_archive(tmp_path):
+    cache_dir = _extract_test_archive(tmp_path)
+    matching = f"/{TEST_ARCHIVE_BASENAME}/**/*.py"
+    nonmatching = "/some-other-archive.tar.gz/**/*.py"
+    baseline = _files_checked(list(license._headers_check_core_logic(cache_dir, TEST_ARCHIVE_BASENAME, [], "none")))
+    with_match = _files_checked(
+        list(license._headers_check_core_logic(cache_dir, TEST_ARCHIVE_BASENAME, [matching], "policy"))
+    )
+    with_nonmatch = _files_checked(
+        list(license._headers_check_core_logic(cache_dir, TEST_ARCHIVE_BASENAME, [nonmatching], "policy"))
+    )
+    assert baseline > 0
+    assert with_match < baseline
+    assert with_nonmatch == baseline
+
+
 def test_headers_check_data_fields_match_model(tmp_path):
     cache_dir = _extract_test_archive(tmp_path)
     results = list(license._headers_check_core_logic(cache_dir, TEST_ARCHIVE_BASENAME, [], "none"))
@@ -220,14 +236,8 @@ def test_headers_check_excludes_matching_files(tmp_path):
         license._headers_check_core_logic(cache_dir, TEST_ARCHIVE_BASENAME, ["*.py"], "policy")
     )
 
-    def get_files_checked(results: list) -> int:
-        for r in results:
-            if isinstance(r, license.ArtifactResult) and r.data and ("files_checked" in r.data):
-                return r.data["files_checked"]
-        return 0
-
-    without_excludes = get_files_checked(results_without_excludes)
-    with_excludes = get_files_checked(results_with_excludes)
+    without_excludes = _files_checked(results_without_excludes)
+    with_excludes = _files_checked(results_with_excludes)
     assert with_excludes < without_excludes
 
 
@@ -264,3 +274,10 @@ def _extract_test_archive(tmp_path: pathlib.Path) -> safe.StatePath:
     with tarfile.open(TEST_ARCHIVE) as tf:
         tf.extractall(cache_dir, filter="data")
     return cache_dir
+
+
+def _files_checked(results: list[object]) -> int:
+    for r in results:
+        if isinstance(r, license.ArtifactResult) and (r.data is not None) and ("files_checked" in r.data):
+            return r.data["files_checked"]
+    return 0


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@tooling.apache.org
For additional commands, e-mail: commits-help@tooling.apache.org