[BUG] Implement commit mail selection for other Git operations

- Implement the commit mail selection feature for the other supported
Git operations that can be done trough the web UI.
- Adds integration tests (goodluck reviewing this).
- Ref: #1788

Co-authored-by: 0ko <0ko@noreply.codeberg.org>
This commit is contained in:
Gusted 2024-02-18 23:41:54 +05:00 committed by Gusted
parent 2855727c85
commit 64a0d61aff
9 changed files with 377 additions and 152 deletions

View file

@ -808,6 +808,7 @@ type CherryPickForm struct {
CommitChoice string `binding:"Required;MaxSize(50)"`
NewBranchName string `binding:"GitRefName;MaxSize(100)"`
LastCommit string
CommitMailID int64 `binding:"Required"`
Revert bool
Signoff bool
}
@ -834,6 +835,7 @@ type UploadRepoFileForm struct {
CommitChoice string `binding:"Required;MaxSize(50)"`
NewBranchName string `binding:"GitRefName;MaxSize(100)"`
Files []string
CommitMailID int64 `binding:"Required"`
Signoff bool
}
@ -868,6 +870,7 @@ type DeleteRepoFileForm struct {
CommitChoice string `binding:"Required;MaxSize(50)"`
NewBranchName string `binding:"GitRefName;MaxSize(100)"`
LastCommit string
CommitMailID int64 `binding:"Required"`
Signoff bool
}

View file

@ -25,6 +25,8 @@ type UploadRepoFileOptions struct {
NewBranch string
TreePath string
Message string
Author *IdentityOptions
Committer *IdentityOptions
Files []string // In UUID format.
Signoff bool
}
@ -128,9 +130,7 @@ func UploadRepoFiles(ctx context.Context, repo *repo_model.Repository, doer *use
return err
}
// make author and committer the doer
author := doer
committer := doer
author, committer := GetAuthorAndCommitterUsers(opts.Author, opts.Committer, doer)
// Now commit the tree
commitHash, err := t.CommitTree(opts.LastCommitID, author, committer, treeHash, opts.Message, opts.Signoff)