diff --git a/templates/repo/home.tmpl b/templates/repo/home.tmpl index 7bf4ee4a8e..482a0db3d8 100644 --- a/templates/repo/home.tmpl +++ b/templates/repo/home.tmpl @@ -58,18 +58,6 @@
{{template "repo/branch_dropdown" dict "root" . "ContainerClasses" "tw-mr-1"}} - {{if and .CanCompareOrPull .IsViewBranch (not .Repository.IsArchived)}} - {{$cmpBranch := ""}} - {{if ne .Repository.ID .BaseRepo.ID}} - {{$cmpBranch = printf "%s/%s:" (.Repository.OwnerName|PathEscape) (.Repository.Name|PathEscape)}} - {{end}} - {{$cmpBranch = print $cmpBranch (.BranchName|PathEscapeSegments)}} - {{$compareLink := printf "%s/compare/%s...%s" .BaseRepo.Link (.BaseRepo.DefaultBranch|PathEscapeSegments) $cmpBranch}} - - {{svg "octicon-git-pull-request"}} - - {{end}} {{if $isHomepage}} {{ctx.Locale.Tr "repo.find_file.go_to_file"}} diff --git a/templates/repo/issue/list.tmpl b/templates/repo/issue/list.tmpl index 8c81bf02a1..621309fb02 100644 --- a/templates/repo/issue/list.tmpl +++ b/templates/repo/issue/list.tmpl @@ -21,7 +21,16 @@ {{if .PageIsIssueList}} {{ctx.Locale.Tr "repo.issues.new"}} {{else}} - {{ctx.Locale.Tr "repo.pulls.new"}} + {{$compareLink := ""}} + {{if .PullRequestCtx.Allowed}} + {{$cmpBranch := ""}} + {{if ne .Repository.ID .BaseRepo.ID}} + {{$cmpBranch = printf "%s/%s:" (.Repository.OwnerName|PathEscape) (.Repository.Name|PathEscape)}} + {{end}} + {{$cmpBranch = print $cmpBranch (.BranchName|PathEscapeSegments)}} + {{$compareLink = printf "%s/compare/%s...%s" .BaseRepo.Link (.BaseRepo.DefaultBranch|PathEscapeSegments) $cmpBranch}} + {{end}} + {{ctx.Locale.Tr "repo.pulls.new"}} {{end}} {{else}} {{if not .PageIsIssueList}} diff --git a/tests/integration/pull_create_test.go b/tests/integration/pull_create_test.go index 7ccbce2eae..b62eb7e164 100644 --- a/tests/integration/pull_create_test.go +++ b/tests/integration/pull_create_test.go @@ -31,12 +31,12 @@ import ( ) func testPullCreate(t *testing.T, session *TestSession, user, repo string, toSelf bool, targetBranch, sourceBranch, title string) *httptest.ResponseRecorder { - req := NewRequest(t, "GET", path.Join(user, repo)) + req := NewRequest(t, "GET", path.Join(user, repo, "pulls")) resp := session.MakeRequest(t, req, http.StatusOK) // Click the PR button to create a pull htmlDoc := NewHTMLParser(t, resp.Body) - link, exists := htmlDoc.doc.Find("#new-pull-request").Attr("href") + link, exists := htmlDoc.doc.Find(".new-pr-button").Attr("href") assert.True(t, exists, "The template has changed") targetUser := strings.Split(link, "/")[1] @@ -158,12 +158,12 @@ func TestPullCreateWithPullTemplate(t *testing.T) { testPullPreview := func(t *testing.T, session *TestSession, user, repo, message string) { t.Helper() - req := NewRequest(t, "GET", path.Join(user, repo)) + req := NewRequest(t, "GET", path.Join(user, repo, "pulls")) resp := session.MakeRequest(t, req, http.StatusOK) // Click the PR button to create a pull htmlDoc := NewHTMLParser(t, resp.Body) - link, exists := htmlDoc.doc.Find("#new-pull-request").Attr("href") + link, exists := htmlDoc.doc.Find(".new-pr-button").Attr("href") assert.True(t, exists, "The template has changed") // Load the pull request preview