Skip to content

Commit bf26f76

Browse files
Handle GitHub tags whose targets have no commit date
Signed-off-by: Ali Zulfiqar <codewithfourtix@gmail.com>
1 parent 27c4fc9 commit bf26f76

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

src/fetchcode/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def fetch_github_tags_gql(purl):
3434

3535
# in case the tag is a signed tag, then the commit info is in target['target']
3636
if "committedDate" not in target:
37-
target = target["target"]
37+
target = target.get("target") or {}
3838

3939
committed_date = target.get("committedDate")
4040
release_date = None

tests/test_github_tag_targets.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import pytest
2+
3+
from fetchcode import utils
4+
5+
6+
@pytest.mark.parametrize("target", [{}, {"target": {}}, {"target": None}])
7+
def test_tags_without_commit_targets(monkeypatch, target):
8+
monkeypatch.setattr(
9+
utils, "fetch_github_tag_nodes", lambda purl: [{"name": "v1", "target": target}]
10+
)
11+
assert list(utils.fetch_github_tags_gql(None)) == [("v1", None)]

0 commit comments

Comments
 (0)