Skip to content

Commit 7859346

Browse files
committed
Cleanup CommitTreeOpts
1 parent 6957ba9 commit 7859346

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

modules/git/repo_tree.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ import (
1515
type CommitTreeOpts struct {
1616
Parents []string
1717
Message string
18-
KeyID string
19-
KeyFormat string
18+
Key SigningKey
2019
NoGPGSign bool
2120
AlwaysSign bool
2221
}
@@ -44,11 +43,11 @@ func (repo *Repository) CommitTree(author, committer *Signature, tree *Tree, opt
4443
_, _ = messageBytes.WriteString(opts.Message)
4544
_, _ = messageBytes.WriteString("\n")
4645

47-
if opts.KeyID != "" || opts.AlwaysSign {
48-
if opts.KeyFormat != "" {
49-
cmd.AddConfig("gpg.format", opts.KeyFormat)
46+
if opts.Key.KeyID != "" || opts.AlwaysSign {
47+
if opts.Key.Format != "" {
48+
cmd.AddConfig("gpg.format", opts.Key.Format)
5049
}
51-
cmd.AddOptionFormat("-S%s", opts.KeyID)
50+
cmd.AddOptionFormat("-S%s", opts.Key.KeyID)
5251
}
5352

5453
if opts.NoGPGSign {

services/wiki/wiki.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,7 @@ func updateWikiPage(ctx context.Context, doer *user_model.User, repo *repo_model
194194

195195
sign, signingKey, signer, _ := asymkey_service.SignWikiCommit(ctx, repo, doer)
196196
if sign {
197-
commitTreeOpts.KeyID = signingKey.KeyID
198-
commitTreeOpts.KeyFormat = signingKey.Format
197+
commitTreeOpts.Key = signingKey
199198
if repo.GetTrustModel() == repo_model.CommitterTrustModel || repo.GetTrustModel() == repo_model.CollaboratorCommitterTrustModel {
200199
committer = signer
201200
}
@@ -317,8 +316,7 @@ func DeleteWikiPage(ctx context.Context, doer *user_model.User, repo *repo_model
317316

318317
sign, signingKey, signer, _ := asymkey_service.SignWikiCommit(ctx, repo, doer)
319318
if sign {
320-
commitTreeOpts.KeyID = signingKey.KeyID
321-
commitTreeOpts.KeyFormat = signingKey.Format
319+
commitTreeOpts.Key = signingKey
322320
if repo.GetTrustModel() == repo_model.CommitterTrustModel || repo.GetTrustModel() == repo_model.CollaboratorCommitterTrustModel {
323321
committer = signer
324322
}

0 commit comments

Comments
 (0)