diff options
author | Unknwon <u@gogs.io> | 2016-08-14 23:02:14 -0700 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2016-08-14 23:52:24 -0700 |
commit | cd89f6c5021ef129ecc4652aa620a3562ae30979 (patch) | |
tree | bf476d81479f249d5a1cfb195af2fdee3890d9a1 /models/pull.go | |
parent | 660e7a178a9d72a03d13f704aca61726b4672232 (diff) | |
download | gitea-cd89f6c5021ef129ecc4652aa620a3562ae30979.tar.gz gitea-cd89f6c5021ef129ecc4652aa620a3562ae30979.zip |
Web editor: improve edit file and diff preview
Diffstat (limited to 'models/pull.go')
-rw-r--r-- | models/pull.go | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/models/pull.go b/models/pull.go index 1dde7608f6..39361595ff 100644 --- a/models/pull.go +++ b/models/pull.go @@ -334,6 +334,9 @@ var patchConflicts = []string{ // testPatch checks if patch can be merged to base repository without conflit. // FIXME: make a mechanism to clean up stable local copies. func (pr *PullRequest) testPatch() (err error) { + repoWorkingPool.CheckIn(com.ToStr(pr.BaseRepoID)) + defer repoWorkingPool.CheckOut(com.ToStr(pr.BaseRepoID)) + if pr.BaseRepo == nil { pr.BaseRepo, err = GetRepositoryByID(pr.BaseRepoID) if err != nil { @@ -354,20 +357,12 @@ func (pr *PullRequest) testPatch() (err error) { log.Trace("PullRequest[%d].testPatch (patchPath): %s", pr.ID, patchPath) - if err := pr.BaseRepo.UpdateLocalCopy(pr.BaseRepo.DefaultBranch); err != nil { + if err := pr.BaseRepo.UpdateLocalCopyBranch(pr.BaseBranch); err != nil { return fmt.Errorf("UpdateLocalCopy: %v", err) } - // Checkout base branch. - _, stderr, err := process.ExecDir(-1, pr.BaseRepo.LocalCopyPath(), - fmt.Sprintf("PullRequest.Merge (git checkout): %v", pr.BaseRepo.ID), - "git", "checkout", pr.BaseBranch) - if err != nil { - return fmt.Errorf("git checkout: %s", stderr) - } - pr.Status = PULL_REQUEST_STATUS_CHECKING - _, stderr, err = process.ExecDir(-1, pr.BaseRepo.LocalCopyPath(), + _, stderr, err := process.ExecDir(-1, pr.BaseRepo.LocalCopyPath(), fmt.Sprintf("testPatch (git apply --check): %d", pr.BaseRepo.ID), "git", "apply", "--check", patchPath) if err != nil { |