aboutsummaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authorMichael Santos <michael.santos@gmail.com>2023-10-09 07:22:12 -0400
committerGitHub <noreply@github.com>2023-10-09 11:22:12 +0000
commit5283ce9650b1ada6b4bd38212ca44ba77297a31b (patch)
treeda0de2365da103e978a83f9dd703bbc9250cf250 /routers
parent65eea1d53696badfb1ef376e5268dbae942089b6 (diff)
downloadgitea-5283ce9650b1ada6b4bd38212ca44ba77297a31b.tar.gz
gitea-5283ce9650b1ada6b4bd38212ca44ba77297a31b.zip
api: GetPullRequestCommits: return file list (#27483)
Fixes https://github.com/go-gitea/gitea/issues/27481 ---- Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Diffstat (limited to 'routers')
-rw-r--r--routers/api/v1/repo/notes.go18
-rw-r--r--routers/api/v1/repo/pull.go18
2 files changed, 34 insertions, 2 deletions
diff --git a/routers/api/v1/repo/notes.go b/routers/api/v1/repo/notes.go
index 1bd66101f0..0b259703de 100644
--- a/routers/api/v1/repo/notes.go
+++ b/routers/api/v1/repo/notes.go
@@ -36,6 +36,14 @@ func GetNote(ctx *context.APIContext) {
// description: a git ref or commit sha
// type: string
// required: true
+ // - name: verification
+ // in: query
+ // description: include verification for every commit (disable for speedup, default 'true')
+ // type: boolean
+ // - name: files
+ // in: query
+ // description: include a list of affected files for every commit (disable for speedup, default 'true')
+ // type: boolean
// responses:
// "200":
// "$ref": "#/responses/Note"
@@ -78,7 +86,15 @@ func getNote(ctx *context.APIContext, identifier string) {
return
}
- cmt, err := convert.ToCommit(ctx, ctx.Repo.Repository, ctx.Repo.GitRepo, note.Commit, nil, convert.ToCommitOptions{Stat: true})
+ verification := ctx.FormString("verification") == "" || ctx.FormBool("verification")
+ files := ctx.FormString("files") == "" || ctx.FormBool("files")
+
+ cmt, err := convert.ToCommit(ctx, ctx.Repo.Repository, ctx.Repo.GitRepo, note.Commit, nil,
+ convert.ToCommitOptions{
+ Stat: true,
+ Verification: verification,
+ Files: files,
+ })
if err != nil {
ctx.Error(http.StatusInternalServerError, "ToCommit", err)
return
diff --git a/routers/api/v1/repo/pull.go b/routers/api/v1/repo/pull.go
index 586f3385b1..6fcc5267cf 100644
--- a/routers/api/v1/repo/pull.go
+++ b/routers/api/v1/repo/pull.go
@@ -1275,6 +1275,14 @@ func GetPullRequestCommits(ctx *context.APIContext) {
// in: query
// description: page size of results
// type: integer
+ // - name: verification
+ // in: query
+ // description: include verification for every commit (disable for speedup, default 'true')
+ // type: boolean
+ // - name: files
+ // in: query
+ // description: include a list of affected files for every commit (disable for speedup, default 'true')
+ // type: boolean
// responses:
// "200":
// "$ref": "#/responses/CommitList"
@@ -1328,9 +1336,17 @@ func GetPullRequestCommits(ctx *context.APIContext) {
end = totalNumberOfCommits
}
+ verification := ctx.FormString("verification") == "" || ctx.FormBool("verification")
+ files := ctx.FormString("files") == "" || ctx.FormBool("files")
+
apiCommits := make([]*api.Commit, 0, end-start)
for i := start; i < end; i++ {
- apiCommit, err := convert.ToCommit(ctx, ctx.Repo.Repository, baseGitRepo, commits[i], userCache, convert.ToCommitOptions{Stat: true})
+ apiCommit, err := convert.ToCommit(ctx, ctx.Repo.Repository, baseGitRepo, commits[i], userCache,
+ convert.ToCommitOptions{
+ Stat: true,
+ Verification: verification,
+ Files: files,
+ })
if err != nil {
ctx.ServerError("toCommit", err)
return