summaryrefslogtreecommitdiffstats
path: root/routers/api
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2020-01-10 15:53:53 +0800
committerGitHub <noreply@github.com>2020-01-10 15:53:53 +0800
commit384c2b342ec01fadb520572666127cb5564e1050 (patch)
tree73357abe356721749e212b90049444cf279a97e4 /routers/api
parent8878cfa4a125348d92f8163988ac9d3279f27e75 (diff)
downloadgitea-384c2b342ec01fadb520572666127cb5564e1050.tar.gz
gitea-384c2b342ec01fadb520572666127cb5564e1050.zip
Move pull request api convert to convert package (#9664)
* Move pull request api convert to convert package * Rename ToPullRequest to ToAPIPullRequest
Diffstat (limited to 'routers/api')
-rw-r--r--routers/api/v1/repo/pull.go9
1 files changed, 5 insertions, 4 deletions
diff --git a/routers/api/v1/repo/pull.go b/routers/api/v1/repo/pull.go
index 85ef419780..8e6677116d 100644
--- a/routers/api/v1/repo/pull.go
+++ b/routers/api/v1/repo/pull.go
@@ -13,6 +13,7 @@ import (
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/auth"
"code.gitea.io/gitea/modules/context"
+ "code.gitea.io/gitea/modules/convert"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/notification"
@@ -102,7 +103,7 @@ func ListPullRequests(ctx *context.APIContext, form api.ListPullRequestsOptions)
ctx.Error(http.StatusInternalServerError, "GetHeadRepo", err)
return
}
- apiPrs[i] = prs[i].APIFormat()
+ apiPrs[i] = convert.ToAPIPullRequest(prs[i])
}
ctx.SetLinkHeader(int(maxResults), models.ItemsPerPage)
@@ -157,7 +158,7 @@ func GetPullRequest(ctx *context.APIContext) {
ctx.Error(http.StatusInternalServerError, "GetHeadRepo", err)
return
}
- ctx.JSON(http.StatusOK, pr.APIFormat())
+ ctx.JSON(http.StatusOK, convert.ToAPIPullRequest(pr))
}
// CreatePullRequest does what it says
@@ -321,7 +322,7 @@ func CreatePullRequest(ctx *context.APIContext, form api.CreatePullRequestOption
notification.NotifyNewPullRequest(pr)
log.Trace("Pull request created: %d/%d", repo.ID, prIssue.ID)
- ctx.JSON(http.StatusCreated, pr.APIFormat())
+ ctx.JSON(http.StatusCreated, convert.ToAPIPullRequest(pr))
}
// EditPullRequest does what it says
@@ -479,7 +480,7 @@ func EditPullRequest(ctx *context.APIContext, form api.EditPullRequestOption) {
}
// TODO this should be 200, not 201
- ctx.JSON(http.StatusCreated, pr.APIFormat())
+ ctx.JSON(http.StatusCreated, convert.ToAPIPullRequest(pr))
}
// IsPullRequestMerged checks if a PR exists given an index