mirror of
https://github.com/go-gitea/gitea
synced 2025-07-05 01:57:20 +00:00
Filter get single commit (#24613)
Pretty much the same thing as #24568 but for getting a single commit instead of getting a list of commits
This commit is contained in:
@ -10,6 +10,7 @@ import (
|
||||
|
||||
repo_model "code.gitea.io/gitea/models/repo"
|
||||
user_model "code.gitea.io/gitea/models/user"
|
||||
ctx "code.gitea.io/gitea/modules/context"
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
api "code.gitea.io/gitea/modules/structs"
|
||||
@ -78,6 +79,14 @@ type ToCommitOptions struct {
|
||||
Files bool
|
||||
}
|
||||
|
||||
func ParseCommitOptions(ctx *ctx.APIContext) ToCommitOptions {
|
||||
return ToCommitOptions{
|
||||
Stat: ctx.FormString("stat") == "" || ctx.FormBool("stat"),
|
||||
Files: ctx.FormString("files") == "" || ctx.FormBool("files"),
|
||||
Verification: ctx.FormString("verification") == "" || ctx.FormBool("verification"),
|
||||
}
|
||||
}
|
||||
|
||||
// ToCommit convert a git.Commit to api.Commit
|
||||
func ToCommit(ctx context.Context, repo *repo_model.Repository, gitRepo *git.Repository, commit *git.Commit, userCache map[string]*user_model.User, opts ToCommitOptions) (*api.Commit, error) {
|
||||
var apiAuthor, apiCommitter *api.User
|
||||
|
Reference in New Issue
Block a user