diff options
author | Matthew Walowski <mattwalowski@gmail.com> | 2023-05-09 18:34:07 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-10 09:34:07 +0800 |
commit | 5930ab5fdf7a970fcca3cd50b44cf1cacb615a54 (patch) | |
tree | ff7c5906653807d00db102e4849a781de2827864 /services | |
parent | 9a0652f0b2e1d56e1187a9442e7f053dad453703 (diff) | |
download | gitea-5930ab5fdf7a970fcca3cd50b44cf1cacb615a54.tar.gz gitea-5930ab5fdf7a970fcca3cd50b44cf1cacb615a54.zip |
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
Diffstat (limited to 'services')
-rw-r--r-- | services/convert/git_commit.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/services/convert/git_commit.go b/services/convert/git_commit.go index 119237e0ca..e726011e02 100644 --- a/services/convert/git_commit.go +++ b/services/convert/git_commit.go @@ -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 |