Merge pull request '[v7.0/forgejo] [BUG] Use correct SHA in `GetCommitPullRequest`' (#4379) from bp-v7.0/forgejo-a8460bb into v7.0/forgejo
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4379 Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
This commit is contained in:
commit
09054cb191
|
@ -354,7 +354,7 @@ func GetCommitPullRequest(ctx *context.APIContext) {
|
||||||
// "404":
|
// "404":
|
||||||
// "$ref": "#/responses/notFound"
|
// "$ref": "#/responses/notFound"
|
||||||
|
|
||||||
pr, err := issues_model.GetPullRequestByMergedCommit(ctx, ctx.Repo.Repository.ID, ctx.Params(":sha"))
|
pr, err := issues_model.GetPullRequestByMergedCommit(ctx, ctx.Repo.Repository.ID, ctx.Params("ref"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if issues_model.IsErrPullRequestNotExist(err) {
|
if issues_model.IsErrPullRequestNotExist(err) {
|
||||||
ctx.Error(http.StatusNotFound, "GetPullRequestByMergedCommit", err)
|
ctx.Error(http.StatusNotFound, "GetPullRequestByMergedCommit", err)
|
||||||
|
|
|
@ -749,3 +749,17 @@ func TestAPIViewRepoObjectFormat(t *testing.T) {
|
||||||
DecodeJSON(t, resp, &repo)
|
DecodeJSON(t, resp, &repo)
|
||||||
assert.EqualValues(t, "sha1", repo.ObjectFormatName)
|
assert.EqualValues(t, "sha1", repo.ObjectFormatName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestAPIRepoCommitPull(t *testing.T) {
|
||||||
|
defer tests.PrepareTestEnv(t)()
|
||||||
|
|
||||||
|
var pr api.PullRequest
|
||||||
|
req := NewRequest(t, "GET", "/api/v1/repos/user2/repo1/commits/1a8823cd1a9549fde083f992f6b9b87a7ab74fb3/pull")
|
||||||
|
resp := MakeRequest(t, req, http.StatusOK)
|
||||||
|
|
||||||
|
DecodeJSON(t, resp, &pr)
|
||||||
|
assert.EqualValues(t, 1, pr.ID)
|
||||||
|
|
||||||
|
req = NewRequest(t, "GET", "/api/v1/repos/user2/repo1/commits/not-a-commit/pull")
|
||||||
|
MakeRequest(t, req, http.StatusNotFound)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue