|
|
@ -108,13 +108,17 @@ func GetAllCommits(ctx *context.APIContext) { |
|
|
|
// in: query
|
|
|
|
// in: query
|
|
|
|
// description: SHA or branch to start listing commits from (usually 'master')
|
|
|
|
// description: SHA or branch to start listing commits from (usually 'master')
|
|
|
|
// type: string
|
|
|
|
// type: string
|
|
|
|
|
|
|
|
// - name: path
|
|
|
|
|
|
|
|
// in: query
|
|
|
|
|
|
|
|
// description: filepath of a file/dir
|
|
|
|
|
|
|
|
// type: string
|
|
|
|
// - name: page
|
|
|
|
// - name: page
|
|
|
|
// in: query
|
|
|
|
// in: query
|
|
|
|
// description: page number of results to return (1-based)
|
|
|
|
// description: page number of results to return (1-based)
|
|
|
|
// type: integer
|
|
|
|
// type: integer
|
|
|
|
// - name: limit
|
|
|
|
// - name: limit
|
|
|
|
// in: query
|
|
|
|
// in: query
|
|
|
|
// description: page size of results
|
|
|
|
// description: page size of results (ignored if used with 'path')
|
|
|
|
// type: integer
|
|
|
|
// type: integer
|
|
|
|
// responses:
|
|
|
|
// responses:
|
|
|
|
// "200":
|
|
|
|
// "200":
|
|
|
@ -149,7 +153,14 @@ func GetAllCommits(ctx *context.APIContext) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
sha := ctx.FormString("sha") |
|
|
|
sha := ctx.FormString("sha") |
|
|
|
|
|
|
|
path := ctx.FormString("path") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var ( |
|
|
|
|
|
|
|
commitsCountTotal int64 |
|
|
|
|
|
|
|
commits []*git.Commit |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if len(path) == 0 { |
|
|
|
var baseCommit *git.Commit |
|
|
|
var baseCommit *git.Commit |
|
|
|
if len(sha) == 0 { |
|
|
|
if len(sha) == 0 { |
|
|
|
// no sha supplied - use default branch
|
|
|
|
// no sha supplied - use default branch
|
|
|
@ -174,20 +185,40 @@ func GetAllCommits(ctx *context.APIContext) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Total commit count
|
|
|
|
// Total commit count
|
|
|
|
commitsCountTotal, err := baseCommit.CommitsCount() |
|
|
|
commitsCountTotal, err = baseCommit.CommitsCount() |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
ctx.Error(http.StatusInternalServerError, "GetCommitsCount", err) |
|
|
|
ctx.Error(http.StatusInternalServerError, "GetCommitsCount", err) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
pageCount := int(math.Ceil(float64(commitsCountTotal) / float64(listOptions.PageSize))) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Query commits
|
|
|
|
// Query commits
|
|
|
|
commits, err := baseCommit.CommitsByRange(listOptions.Page, listOptions.PageSize) |
|
|
|
commits, err = baseCommit.CommitsByRange(listOptions.Page, listOptions.PageSize) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
ctx.Error(http.StatusInternalServerError, "CommitsByRange", err) |
|
|
|
ctx.Error(http.StatusInternalServerError, "CommitsByRange", err) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
if len(sha) == 0 { |
|
|
|
|
|
|
|
sha = ctx.Repo.Repository.DefaultBranch |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
commitsCountTotal, err = gitRepo.FileCommitsCount(sha, path) |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
ctx.Error(http.StatusInternalServerError, "FileCommitsCount", err) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} else if commitsCountTotal == 0 { |
|
|
|
|
|
|
|
ctx.NotFound("FileCommitsCount", nil) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
commits, err = gitRepo.CommitsByFileAndRange(sha, path, listOptions.Page) |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
ctx.Error(http.StatusInternalServerError, "CommitsByFileAndRange", err) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pageCount := int(math.Ceil(float64(commitsCountTotal) / float64(listOptions.PageSize))) |
|
|
|
|
|
|
|
|
|
|
|
userCache := make(map[string]*user_model.User) |
|
|
|
userCache := make(map[string]*user_model.User) |
|
|
|
|
|
|
|
|
|
|
|