forgejo/services/convert
Gusted 389b32f51a feat: make upload URL compatible with GitHub API (#9285)
Adds new a function, `AcceptsGithubResponse`, to the API router context struct to check if the requests accepts a Github response. Although Forgejo API will never be compatible with the Github API, historically Forgejo's API has been designed to follow that of Github closely and we know that a lot of tooling that uses the Github API can be used against the Forgejo API with little to no problem.

As a meet in the middle solution, this function can be used to respond with a more appropriate response that follows the Github API. This allows Forgejo to avoid breaking compatibility with existing users of the API and allows the API to be oh so slightly more compatible with that of Github for API clients that expect a Github response.

Because the `upload_url` field was added purely to match the Github API (forgejo/forgejo#580), it is fair to actually make it compatible with how the Github API intended it to be and that is by adding `{?name,label}` which is used by Github's Oktokit.

Only add `{?name,label}` when Forgejo knows the request accepts a Github response. This avoids breaking the API compatibility with non-Github API  clients.

Resolves Codeberg/Community#2132

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/9285
Reviewed-by: 0ko <0ko@noreply.codeberg.org>
Reviewed-by: oliverpool <oliverpool@noreply.codeberg.org>
Co-authored-by: Gusted <postmaster@gusted.xyz>
Co-committed-by: Gusted <postmaster@gusted.xyz>
2025-09-15 15:53:35 +02:00
..
action.go bug: unify RepoActionRun and ActionRun structs (#8250) 2025-06-23 07:54:32 +02:00
activity.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
activitypub_person.go Add ActivityPub Person follow from distant (#8720) 2025-08-03 11:55:01 +02:00
activitypub_user_action.go Sent user activities to distant federated server (#8792) 2025-08-06 16:16:13 +02:00
attachment.go fix(ui): Add pasted images to dropzone 2025-06-30 12:42:22 +02:00
attachment_test.go fix(ui): Add pasted images to dropzone 2025-06-30 12:42:22 +02:00
convert.go bug: unify RepoActionRun and ActionRun structs (#8250) 2025-06-23 07:54:32 +02:00
git_commit.go fix: correctly get stats for API commits (#8756) 2025-08-02 13:06:04 +02:00
git_commit_test.go Update module github.com/golangci/golangci-lint/cmd/golangci-lint to v2 (forgejo) (#7367) 2025-03-28 22:22:21 +00:00
issue.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
issue_comment.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
issue_test.go test: prevent XSS for label rendering 2025-06-27 13:27:06 +02:00
main_test.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
mirror.go feat: add configuration to only push mirror selected branches (#7823) 2025-07-12 00:39:35 +02:00
notification.go Update module github.com/golangci/golangci-lint/cmd/golangci-lint to v2 (forgejo) (#7367) 2025-03-28 22:22:21 +00:00
package.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
pull.go fix(migrations): transfer PR flow information (#7421) 2025-04-03 06:47:37 +00:00
pull_review.go Update module github.com/golangci/golangci-lint/cmd/golangci-lint to v2 (forgejo) (#7367) 2025-03-28 22:22:21 +00:00
pull_test.go Update module github.com/golangci/golangci-lint/cmd/golangci-lint to v2 (forgejo) (#7367) 2025-03-28 22:22:21 +00:00
quota.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00: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 chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
status.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
user.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
user_test.go Update module github.com/golangci/golangci-lint/cmd/golangci-lint to v2 (forgejo) (#7367) 2025-03-28 22:22:21 +00:00
utils.go Add support for migrating from Pagure (#8513) 2025-08-11 16:56:26 +02:00
utils_test.go Update module github.com/golangci/golangci-lint/cmd/golangci-lint to v2 (forgejo) (#7367) 2025-03-28 22:22:21 +00:00
wiki.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00