]> source.dussan.org Git - gitea.git/commitdiff
#1931 Test patch does not checkout correct base branch
authorUnknwon <u@gogs.io>
Sun, 15 Nov 2015 19:41:36 +0000 (14:41 -0500)
committerUnknwon <u@gogs.io>
Sun, 15 Nov 2015 19:41:36 +0000 (14:41 -0500)
models/pull.go
models/repo.go
modules/middleware/repo.go
templates/repo/sidebar.tmpl

index 56af5f828d22409c7f610641226fbfd81f51e917..094cb9b26a8df3121135a2d8235466cfdd19085e 100644 (file)
@@ -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 {
index fab463b948a2982a1eeaa9a0f77eea602142ea61..bbd978ff4bfe4aa42248791d3edaba857ea73434 100644 (file)
@@ -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)
                }
index afa95a250c0d10fc9363dce2de8bb0be3956a6bd..c7481743d494285b7fece6450ac38e34e22c6673 100644 (file)
@@ -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
                }
 
index df033c0e15f806d10142a65ffd81f1f2b10020fc..2e4fdfb64eb07b52c6dc5076f150299e62c52604 100644 (file)
@@ -1,4 +1,5 @@
-<div class="ui five item menu">
+{{if not .IsBareRepo}}
+<div class="ui {{if .IsRepositoryAdmin}}five{{else}}four{{end}} item menu">
     <a class="item" href="{{.RepoLink}}/issues">
       <i class="icon octicon octicon-issue-opened"></i> {{.i18n.Tr "repo.issues"}} <span class="ui blue label">{{.Repository.NumOpenIssues}}</span>
     </a>
@@ -16,4 +17,5 @@
       <i class="icon octicon octicon-tools"></i> {{.i18n.Tr "repo.settings"}}
     </a>
     {{end}}
-</div>
\ No newline at end of file
+</div>
+{{end}}
\ No newline at end of file