diff options
author | Zettat123 <zettat123@gmail.com> | 2024-09-24 09:00:09 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-24 01:00:09 +0000 |
commit | fcedf634d5864a9e4ec3f866b99076872aafd07d (patch) | |
tree | 7b8b0a1f1959021d34ed478fcceb3da79ca14f4d /routers/api/v1 | |
parent | 6afb22448b7845fb8f570d64ce2ad6c4c81b9d2f (diff) | |
download | gitea-fcedf634d5864a9e4ec3f866b99076872aafd07d.tar.gz gitea-fcedf634d5864a9e4ec3f866b99076872aafd07d.zip |
Fix bug in getting merged pull request by commit (#32079)
Diffstat (limited to 'routers/api/v1')
-rw-r--r-- | routers/api/v1/api.go | 2 | ||||
-rw-r--r-- | routers/api/v1/repo/commits.go | 6 |
2 files changed, 5 insertions, 3 deletions
diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go index be67ec1695..1244676508 100644 --- a/routers/api/v1/api.go +++ b/routers/api/v1/api.go @@ -1286,6 +1286,8 @@ func Routes() *web.Router { m.Group("/{ref}", func() { m.Get("/status", repo.GetCombinedCommitStatusByRef) m.Get("/statuses", repo.GetCommitStatusesByRef) + }, context.ReferencesGitRepo()) + m.Group("/{sha}", func() { m.Get("/pull", repo.GetCommitPullRequest) }, context.ReferencesGitRepo()) }, reqRepoReader(unit.TypeCode)) diff --git a/routers/api/v1/repo/commits.go b/routers/api/v1/repo/commits.go index cec7c3d534..788c75fab2 100644 --- a/routers/api/v1/repo/commits.go +++ b/routers/api/v1/repo/commits.go @@ -325,11 +325,11 @@ func DownloadCommitDiffOrPatch(ctx *context.APIContext) { } } -// GetCommitPullRequest returns the pull request of the commit +// GetCommitPullRequest returns the merged pull request of the commit func GetCommitPullRequest(ctx *context.APIContext) { // swagger:operation GET /repos/{owner}/{repo}/commits/{sha}/pull repository repoGetCommitPullRequest // --- - // summary: Get the pull request of the commit + // summary: Get the merged pull request of the commit // produces: // - application/json // parameters: @@ -354,7 +354,7 @@ func GetCommitPullRequest(ctx *context.APIContext) { // "404": // "$ref": "#/responses/notFound" - pr, err := issues_model.GetPullRequestByMergedCommit(ctx, ctx.Repo.Repository.ID, ctx.PathParam(":sha")) + pr, err := issues_model.GetPullRequestByMergedCommit(ctx, ctx.Repo.Repository.ID, ctx.PathParam("sha")) if err != nil { if issues_model.IsErrPullRequestNotExist(err) { ctx.Error(http.StatusNotFound, "GetPullRequestByMergedCommit", err) |