@@ -42,6 +42,18 @@ func GetSingleCommit(ctx *context.APIContext) {
42
42
// description: a git ref or commit sha
43
43
// type: string
44
44
// required: true
45
+ // - name: stat
46
+ // in: query
47
+ // description: include diff stats for every commit (disable for speedup, default 'true')
48
+ // type: boolean
49
+ // - name: verification
50
+ // in: query
51
+ // description: include verification for every commit (disable for speedup, default 'true')
52
+ // type: boolean
53
+ // - name: files
54
+ // in: query
55
+ // description: include a list of affected files for every commit (disable for speedup, default 'true')
56
+ // type: boolean
45
57
// responses:
46
58
// "200":
47
59
// "$ref": "#/responses/Commit"
@@ -55,10 +67,11 @@ func GetSingleCommit(ctx *context.APIContext) {
55
67
ctx .Error (http .StatusUnprocessableEntity , "no valid ref or sha" , fmt .Sprintf ("no valid ref or sha: %s" , sha ))
56
68
return
57
69
}
58
- getCommit (ctx , sha )
70
+
71
+ getCommit (ctx , sha , convert .ParseCommitOptions (ctx ))
59
72
}
60
73
61
- func getCommit (ctx * context.APIContext , identifier string ) {
74
+ func getCommit (ctx * context.APIContext , identifier string , toCommitOpts convert. ToCommitOptions ) {
62
75
commit , err := ctx .Repo .GitRepo .GetCommit (identifier )
63
76
if err != nil {
64
77
if git .IsErrNotExist (err ) {
@@ -69,7 +82,7 @@ func getCommit(ctx *context.APIContext, identifier string) {
69
82
return
70
83
}
71
84
72
- json , err := convert .ToCommit (ctx , ctx .Repo .Repository , ctx .Repo .GitRepo , commit , nil , convert. ToCommitOptions { Stat : true } )
85
+ json , err := convert .ToCommit (ctx , ctx .Repo .Repository , ctx .Repo .GitRepo , commit , nil , toCommitOpts )
73
86
if err != nil {
74
87
ctx .Error (http .StatusInternalServerError , "toCommit" , err )
75
88
return
@@ -240,24 +253,12 @@ func GetAllCommits(ctx *context.APIContext) {
240
253
}
241
254
242
255
pageCount := int (math .Ceil (float64 (commitsCountTotal ) / float64 (listOptions .PageSize )))
243
-
244
256
userCache := make (map [string ]* user_model.User )
245
-
246
257
apiCommits := make ([]* api.Commit , len (commits ))
247
258
248
- stat := ctx .FormString ("stat" ) == "" || ctx .FormBool ("stat" )
249
- verification := ctx .FormString ("verification" ) == "" || ctx .FormBool ("verification" )
250
- files := ctx .FormString ("files" ) == "" || ctx .FormBool ("files" )
251
-
252
259
for i , commit := range commits {
253
260
// Create json struct
254
- apiCommits [i ], err = convert .ToCommit (ctx , ctx .Repo .Repository , ctx .Repo .GitRepo , commit , userCache ,
255
- convert.ToCommitOptions {
256
- Stat : stat ,
257
- Verification : verification ,
258
- Files : files ,
259
- })
260
-
261
+ apiCommits [i ], err = convert .ToCommit (ctx , ctx .Repo .Repository , ctx .Repo .GitRepo , commit , userCache , convert .ParseCommitOptions (ctx ))
261
262
if err != nil {
262
263
ctx .Error (http .StatusInternalServerError , "toCommit" , err )
263
264
return
0 commit comments