1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-22 18:28:37 +00:00

Support choose email when creating a commit via web UI (more) (#33445)

Follow #33432
This commit is contained in:
wxiaoguang
2025-01-31 10:36:18 +08:00
committed by GitHub
parent b57d9f41d4
commit 5a7b42dac7
18 changed files with 228 additions and 176 deletions

View File

@@ -66,7 +66,7 @@ func NewDiffPatchPost(ctx *context.Context) {
return
}
// Cannot commit to a an existing branch if user doesn't have rights
// Cannot commit to an existing branch if user doesn't have rights
if branchName == ctx.Repo.BranchName && !canCommit {
ctx.Data["Err_NewBranchName"] = true
ctx.Data["commit_choice"] = frmCommitChoiceNewBranch
@@ -86,12 +86,21 @@ func NewDiffPatchPost(ctx *context.Context) {
message += "\n\n" + form.CommitMessage
}
gitCommitter, valid := WebGitOperationGetCommitChosenEmailIdentity(ctx, form.CommitEmail)
if !valid {
ctx.Data["Err_CommitEmail"] = true
ctx.RenderWithErr(ctx.Tr("repo.editor.invalid_commit_email"), tplPatchFile, &form)
return
}
fileResponse, err := files.ApplyDiffPatch(ctx, ctx.Repo.Repository, ctx.Doer, &files.ApplyDiffPatchOptions{
LastCommitID: form.LastCommit,
OldBranch: ctx.Repo.BranchName,
NewBranch: branchName,
Message: message,
Content: strings.ReplaceAll(form.Content, "\r", ""),
Author: gitCommitter,
Committer: gitCommitter,
})
if err != nil {
if git_model.IsErrBranchAlreadyExists(err) {