From 4f03b81ec777813820d4e33ec11893e214ec27d2 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Sun, 15 Nov 2015 14:41:36 -0500 Subject: [PATCH] #1931 Test patch does not checkout correct base branch --- models/pull.go | 11 ++++++++++- models/repo.go | 2 +- modules/middleware/repo.go | 1 - templates/repo/sidebar.tmpl | 6 ++++-- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/models/pull.go b/models/pull.go index 56af5f82..094cb9b2 100644 --- a/models/pull.go +++ b/models/pull.go @@ -218,6 +218,7 @@ 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) { if pr.BaseRepo == nil { pr.BaseRepo, err = GetRepositoryByID(pr.BaseRepoID) @@ -243,8 +244,16 @@ func (pr *PullRequest) testPatch() (err error) { return fmt.Errorf("UpdateLocalCopy: %v", err) } - pr.Status = PULL_REQUEST_STATUS_CHECKING + // Checkout base branch. _, stderr, err := process.ExecDir(-1, pr.BaseRepo.LocalCopyPath(), + fmt.Sprintf("PullRequest.Merge(git checkout): %s", 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(), fmt.Sprintf("testPatch(git apply --check): %d", pr.BaseRepo.ID), "git", "apply", "--check", patchPath) if err != nil { diff --git a/models/repo.go b/models/repo.go index fab463b9..bbd978ff 100644 --- a/models/repo.go +++ b/models/repo.go @@ -320,7 +320,7 @@ func (repo *Repository) UpdateLocalCopy() error { } } else { _, stderr, err := process.ExecDir(-1, localPath, - fmt.Sprintf("UpdateLocalCopy(git pull): %s", repoPath), "git", "pull") + fmt.Sprintf("UpdateLocalCopy(git pull --all): %s", repoPath), "git", "pull", "--all") if err != nil { return fmt.Errorf("git pull: %v - %s", err, stderr) } diff --git a/modules/middleware/repo.go b/modules/middleware/repo.go index afa95a25..c7481743 100644 --- a/modules/middleware/repo.go +++ b/modules/middleware/repo.go @@ -81,7 +81,6 @@ func RepoRef() macaron.Handler { return func(ctx *Context) { // Empty repository does not have reference information. if ctx.Repo.Repository.IsBare { - ctx.Data["CommitsCount"] = 0 return } diff --git a/templates/repo/sidebar.tmpl b/templates/repo/sidebar.tmpl index df033c0e..2e4fdfb6 100644 --- a/templates/repo/sidebar.tmpl +++ b/templates/repo/sidebar.tmpl @@ -1,4 +1,5 @@ - +{{end}} \ No newline at end of file