|
|
|
@ -42,6 +42,18 @@ func GetSingleCommit(ctx *context.APIContext) {
|
|
|
|
|
// description: a git ref or commit sha
|
|
|
|
|
// type: string
|
|
|
|
|
// required: true
|
|
|
|
|
// - name: stat
|
|
|
|
|
// in: query
|
|
|
|
|
// description: include diff stats for every commit (disable for speedup, default 'true')
|
|
|
|
|
// type: boolean
|
|
|
|
|
// - 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/Commit"
|
|
|
|
@ -55,10 +67,11 @@ func GetSingleCommit(ctx *context.APIContext) {
|
|
|
|
|
ctx.Error(http.StatusUnprocessableEntity, "no valid ref or sha", fmt.Sprintf("no valid ref or sha: %s", sha))
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
getCommit(ctx, sha)
|
|
|
|
|
|
|
|
|
|
getCommit(ctx, sha, convert.ParseCommitOptions(ctx))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func getCommit(ctx *context.APIContext, identifier string) {
|
|
|
|
|
func getCommit(ctx *context.APIContext, identifier string, toCommitOpts convert.ToCommitOptions) {
|
|
|
|
|
commit, err := ctx.Repo.GitRepo.GetCommit(identifier)
|
|
|
|
|
if err != nil {
|
|
|
|
|
if git.IsErrNotExist(err) {
|
|
|
|
@ -69,7 +82,7 @@ func getCommit(ctx *context.APIContext, identifier string) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
json, err := convert.ToCommit(ctx, ctx.Repo.Repository, ctx.Repo.GitRepo, commit, nil, convert.ToCommitOptions{Stat: true})
|
|
|
|
|
json, err := convert.ToCommit(ctx, ctx.Repo.Repository, ctx.Repo.GitRepo, commit, nil, toCommitOpts)
|
|
|
|
|
if err != nil {
|
|
|
|
|
ctx.Error(http.StatusInternalServerError, "toCommit", err)
|
|
|
|
|
return
|
|
|
|
@ -240,24 +253,12 @@ func GetAllCommits(ctx *context.APIContext) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pageCount := int(math.Ceil(float64(commitsCountTotal) / float64(listOptions.PageSize)))
|
|
|
|
|
|
|
|
|
|
userCache := make(map[string]*user_model.User)
|
|
|
|
|
|
|
|
|
|
apiCommits := make([]*api.Commit, len(commits))
|
|
|
|
|
|
|
|
|
|
stat := ctx.FormString("stat") == "" || ctx.FormBool("stat")
|
|
|
|
|
verification := ctx.FormString("verification") == "" || ctx.FormBool("verification")
|
|
|
|
|
files := ctx.FormString("files") == "" || ctx.FormBool("files")
|
|
|
|
|
|
|
|
|
|
for i, commit := range commits {
|
|
|
|
|
// Create json struct
|
|
|
|
|
apiCommits[i], err = convert.ToCommit(ctx, ctx.Repo.Repository, ctx.Repo.GitRepo, commit, userCache,
|
|
|
|
|
convert.ToCommitOptions{
|
|
|
|
|
Stat: stat,
|
|
|
|
|
Verification: verification,
|
|
|
|
|
Files: files,
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
apiCommits[i], err = convert.ToCommit(ctx, ctx.Repo.Repository, ctx.Repo.GitRepo, commit, userCache, convert.ParseCommitOptions(ctx))
|
|
|
|
|
if err != nil {
|
|
|
|
|
ctx.Error(http.StatusInternalServerError, "toCommit", err)
|
|
|
|
|
return
|
|
|
|
|