From bf26f76d5efd3b8c2c9bc5a3fcb5faaab0fcea0c Mon Sep 17 00:00:00 2001 From: Ali Zulfiqar Date: Sat, 5 Sep 2026 22:21:47 +0500 Subject: [PATCH 1/2] Handle GitHub tags whose targets have no commit date Signed-off-by: Ali Zulfiqar --- src/fetchcode/utils.py | 2 +- tests/test_github_tag_targets.py | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 tests/test_github_tag_targets.py diff --git a/src/fetchcode/utils.py b/src/fetchcode/utils.py index 13f1421..bc2ca23 100644 --- a/src/fetchcode/utils.py +++ b/src/fetchcode/utils.py @@ -34,7 +34,7 @@ def fetch_github_tags_gql(purl): # in case the tag is a signed tag, then the commit info is in target['target'] if "committedDate" not in target: - target = target["target"] + target = target.get("target") or {} committed_date = target.get("committedDate") release_date = None diff --git a/tests/test_github_tag_targets.py b/tests/test_github_tag_targets.py new file mode 100644 index 0000000..cf8e4d8 --- /dev/null +++ b/tests/test_github_tag_targets.py @@ -0,0 +1,11 @@ +import pytest + +from fetchcode import utils + + +@pytest.mark.parametrize("target", [{}, {"target": {}}, {"target": None}]) +def test_tags_without_commit_targets(monkeypatch, target): + monkeypatch.setattr( + utils, "fetch_github_tag_nodes", lambda purl: [{"name": "v1", "target": target}] + ) + assert list(utils.fetch_github_tags_gql(None)) == [("v1", None)] From 2b71d5d7e23e12dd9a79ef2b68fbc18f92076631 Mon Sep 17 00:00:00 2001 From: Ali Zulfiqar Date: Sat, 5 Sep 2026 22:31:37 +0500 Subject: [PATCH 2/2] Address review feedback and strengthen regression coverage Signed-off-by: Ali Zulfiqar --- tests/test_github_tag_targets.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/test_github_tag_targets.py b/tests/test_github_tag_targets.py index cf8e4d8..2368e82 100644 --- a/tests/test_github_tag_targets.py +++ b/tests/test_github_tag_targets.py @@ -1,3 +1,19 @@ +# fetchcode is a free software tool from nexB Inc. and others. +# Visit https://github.com/aboutcode-org/fetchcode for support and download. + +# Copyright (c) nexB Inc. and others. All rights reserved. +# http://nexb.com and http://aboutcode.org + +# This software is licensed under the Apache License version 2.0. + +# You may not use this software except in compliance with the License. +# You may obtain a copy of the License at: +# http://apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software distributed +# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +# CONDITIONS OF ANY KIND, either express or implied. See the License for the +# specific language governing permissions and limitations under the License. + import pytest from fetchcode import utils