aboutsummaryrefslogtreecommitdiff
path: root/services/pull/patch.go
diff options
context:
space:
mode:
Diffstat (limited to 'services/pull/patch.go')
-rw-r--r--services/pull/patch.go17
1 files changed, 6 insertions, 11 deletions
diff --git a/services/pull/patch.go b/services/pull/patch.go
index c2ccc75bd..927735572 100644
--- a/services/pull/patch.go
+++ b/services/pull/patch.go
@@ -22,7 +22,6 @@ import (
"code.gitea.io/gitea/modules/graceful"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/process"
- repo_module "code.gitea.io/gitea/modules/repository"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/util"
@@ -64,25 +63,21 @@ func TestPatch(pr *issues_model.PullRequest) error {
defer finished()
// Clone base repo.
- tmpBasePath, err := createTemporaryRepo(ctx, pr)
+ prCtx, cancel, err := createTemporaryRepoForPR(ctx, pr)
if err != nil {
- log.Error("CreateTemporaryPath: %v", err)
+ log.Error("createTemporaryRepoForPR %-v: %v", pr, err)
return err
}
- defer func() {
- if err := repo_module.RemoveTemporaryPath(tmpBasePath); err != nil {
- log.Error("Merge: RemoveTemporaryPath: %s", err)
- }
- }()
+ defer cancel()
- gitRepo, err := git.OpenRepository(ctx, tmpBasePath)
+ gitRepo, err := git.OpenRepository(ctx, prCtx.tmpBasePath)
if err != nil {
return fmt.Errorf("OpenRepository: %w", err)
}
defer gitRepo.Close()
// 1. update merge base
- pr.MergeBase, _, err = git.NewCommand(ctx, "merge-base", "--", "base", "tracking").RunStdString(&git.RunOpts{Dir: tmpBasePath})
+ pr.MergeBase, _, err = git.NewCommand(ctx, "merge-base", "--", "base", "tracking").RunStdString(&git.RunOpts{Dir: prCtx.tmpBasePath})
if err != nil {
var err2 error
pr.MergeBase, err2 = gitRepo.GetRefCommitID(git.BranchPrefix + "base")
@@ -101,7 +96,7 @@ func TestPatch(pr *issues_model.PullRequest) error {
}
// 2. Check for conflicts
- if conflicts, err := checkConflicts(ctx, pr, gitRepo, tmpBasePath); err != nil || conflicts || pr.Status == issues_model.PullRequestStatusEmpty {
+ if conflicts, err := checkConflicts(ctx, pr, gitRepo, prCtx.tmpBasePath); err != nil || conflicts || pr.Status == issues_model.PullRequestStatusEmpty {
return err
}