gitforge/services/convert
steven.guiheux 7e205c5718 fix: get tag must return the tag signature instead of commit signature (#12351)
## Fix: `GET /api/v1/repos/{owner}/{repo}/git/tags/{sha}` returns empty verification for signed tags

### Problem

When an annotated tag is signed (GPG or SSH) but the underlying commit is **not** signed, the API endpoint `GET /repos/{owner}/{repo}/git/tags/{sha}` returns an empty `verification.signature` field.

This is because `ToAnnotatedTag` was calling `ToVerification(ctx, c)` with the **commit** object, which checks the commit's signature — not the tag's own signature. Since the commit is unsigned, the API returns `signature: ""` and `verified: false`.

This causes issues for tools that rely on the tag signature from the API to validate that a tag push event is from a trusted source.

### Fix

`ToAnnotatedTag` now checks if the tag has its own signature (`t.Signature != nil`). If so, it uses `ParseTagWithSignature` to verify the tag's signature and populates the `verification` field from the tag. Otherwise, it falls back to the commit signature (existing behavior for unsigned/lightweight tags).

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/12351
Reviewed-by: limiting-factor <limiting-factor@noreply.codeberg.org>
Reviewed-by: Mathieu Fenniak <mfenniak@noreply.codeberg.org>
2026-05-03 04:41:12 +02:00
..
action.go feat(api): add REST API endpoints for Actions artifacts (#12140) 2026-04-20 05:10:54 +02:00
activity.go
activitypub_person.go chore: update github.com/go-ap/activitypub to 902f6cf (#11301) 2026-04-02 23:57:13 +02:00
activitypub_user_action.go chore: add modernizer linter (#11936) 2026-04-02 03:29:37 +02:00
attachment.go
attachment_test.go
convert.go fix: get tag must return the tag signature instead of commit signature (#12351) 2026-05-03 04:41:12 +02:00
convert_test.go fix: get tag must return the tag signature instead of commit signature (#12351) 2026-05-03 04:41:12 +02:00
git_commit.go chore: ensure consistent import aliasing for services and models (#10253) 2025-11-30 17:00:57 +01:00
git_commit_test.go
issue.go
issue_comment.go perf: bulk load resolvers & reactions on pull request comments (#11988) 2026-04-05 14:37:09 +02:00
issue_test.go
main_test.go chore: move all test blank imports in a single package (#10662) 2026-01-02 05:32:32 +01:00
mirror.go
notification.go feat: rework notification table (#9926) 2025-11-29 23:03:56 +01:00
package.go
pull.go feat: improve getting shortstat (#9587) 2025-10-10 14:15:38 +02:00
pull_review.go
pull_test.go
quota.go chore: ensure consistent import aliasing for services and models (#10253) 2025-11-30 17:00:57 +01:00
release.go feat: make upload URL compatible with GitHub API (#9285) 2025-09-15 15:53:35 +02:00
release_test.go feat: make upload URL compatible with GitHub API (#9285) 2025-09-15 15:53:35 +02:00
repository.go feat: add wiki git info to API (#11589) 2026-03-19 01:21:50 +01:00
status.go
user.go
user_test.go
utils.go
utils_test.go
wiki.go