Skip to content

Commit 16132a5

Browse files
committed
add context to CommitTree
1 parent 099e128 commit 16132a5

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

modules/git/repo_tree.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package git
66

77
import (
88
"bytes"
9+
"context"
910
"os"
1011
"strings"
1112
"time"
@@ -21,7 +22,7 @@ type CommitTreeOpts struct {
2122
}
2223

2324
// CommitTree creates a commit from a given tree id for the user with provided message
24-
func (repo *Repository) CommitTree(author, committer *Signature, tree *Tree, opts CommitTreeOpts) (ObjectID, error) {
25+
func (repo *Repository) CommitTree(ctx context.Context, author, committer *Signature, tree *Tree, opts CommitTreeOpts) (ObjectID, error) {
2526
commitTimeStr := time.Now().Format(time.RFC3339)
2627

2728
// Because this may call hooks we should pass in the environment
@@ -53,7 +54,7 @@ func (repo *Repository) CommitTree(author, committer *Signature, tree *Tree, opt
5354

5455
stdout := new(bytes.Buffer)
5556
stderr := new(bytes.Buffer)
56-
err := cmd.Run(repo.Ctx, &RunOpts{
57+
err := cmd.Run(ctx, &RunOpts{
5758
Env: env,
5859
Dir: repo.Path,
5960
Stdin: messageBytes,

services/wiki/wiki.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ func updateWikiPage(ctx context.Context, doer *user_model.User, repo *repo_model
209209
commitTreeOpts.Parents = []string{"HEAD"}
210210
}
211211

212-
commitHash, err := gitRepo.CommitTree(doer.NewGitSig(), committer, tree, commitTreeOpts)
212+
commitHash, err := gitRepo.CommitTree(ctx, doer.NewGitSig(), committer, tree, commitTreeOpts)
213213
if err != nil {
214214
log.Error("CommitTree failed: %v", err)
215215
return err
@@ -332,7 +332,7 @@ func DeleteWikiPage(ctx context.Context, doer *user_model.User, repo *repo_model
332332
commitTreeOpts.NoGPGSign = true
333333
}
334334

335-
commitHash, err := gitRepo.CommitTree(doer.NewGitSig(), committer, tree, commitTreeOpts)
335+
commitHash, err := gitRepo.CommitTree(ctx, doer.NewGitSig(), committer, tree, commitTreeOpts)
336336
if err != nil {
337337
return err
338338
}

0 commit comments

Comments
 (0)