loading up the forgejo repo on tangled to test page performance
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request '[PORT] Add warning message in merge instructions when `AutodetectManualMerge` was not enabled (gitea#31805)' (#4930) from gusted/forgejo-gt-bp-31805 into forgejo

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4930
Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>

+53 -2
+1
options/locale/locale_en-US.ini
··· 1952 1952 pulls.cmd_instruction_checkout_desc = From your project repository, check out a new branch and test the changes. 1953 1953 pulls.cmd_instruction_merge_title = Merge 1954 1954 pulls.cmd_instruction_merge_desc = Merge the changes and update on Forgejo. 1955 + pulls.cmd_instruction_merge_warning = <b>Warning:</b> The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards. 1955 1956 pulls.clear_merge_message = Clear merge message 1956 1957 pulls.clear_merge_message_hint = Clearing the merge message will only remove the commit message content and keep generated git trailers such as "Co-Authored-By …". 1957 1958 pulls.reopen_failed.head_branch = The pull request cannot be reopened, because the head branch doesn't exist anymore.
+2
routers/web/repo/issue.go
··· 1881 1881 } 1882 1882 prConfig := prUnit.PullRequestsConfig() 1883 1883 1884 + ctx.Data["AutodetectManualMerge"] = prConfig.AutodetectManualMerge 1885 + 1884 1886 var mergeStyle repo_model.MergeStyle 1885 1887 // Check correct values and select default 1886 1888 if ms, ok := ctx.Data["MergeStyle"].(repo_model.MergeStyle); !ok ||
+1 -1
templates/repo/issue/view_content/pull.tmpl
··· 388 388 {{end}} 389 389 390 390 {{if and .Issue.PullRequest.HeadRepo (not .Issue.PullRequest.HasMerged) (not .Issue.IsClosed)}} 391 - {{template "repo/issue/view_content/pull_merge_instruction" dict "PullRequest" .Issue.PullRequest "ShowMergeInstructions" .ShowMergeInstructions}} 391 + {{template "repo/issue/view_content/pull_merge_instruction" dict "PullRequest" .Issue.PullRequest "ShowMergeInstructions" .ShowMergeInstructions "AutodetectManualMerge" .AutodetectManualMerge}} 392 392 {{end}} 393 393 </div> 394 394 </div>
+7 -1
templates/repo/issue/view_content/pull_merge_instruction.tmpl
··· 15 15 <div>git checkout {{$localBranch}}</div> 16 16 </div> 17 17 {{if .ShowMergeInstructions}} 18 - <div><h3>{{ctx.Locale.Tr "repo.pulls.cmd_instruction_merge_title"}}</h3>{{ctx.Locale.Tr "repo.pulls.cmd_instruction_merge_desc"}}</div> 18 + <div id="merge-instructions"> 19 + <h3>{{ctx.Locale.Tr "repo.pulls.cmd_instruction_merge_title"}}</h3> 20 + {{ctx.Locale.Tr "repo.pulls.cmd_instruction_merge_desc"}} 21 + {{if not .AutodetectManualMerge}} 22 + <p>{{ctx.Locale.Tr "repo.pulls.cmd_instruction_merge_warning"}}</p> 23 + {{end}} 24 + </div> 19 25 <div class="ui secondary segment"> 20 26 <div data-pull-merge-style="merge"> 21 27 <div>git checkout {{.PullRequest.BaseBranch}}</div>
+42
tests/integration/pull_test.go
··· 7 7 "net/http" 8 8 "testing" 9 9 10 + "code.gitea.io/gitea/models/db" 11 + repo_model "code.gitea.io/gitea/models/repo" 12 + "code.gitea.io/gitea/models/unit" 13 + "code.gitea.io/gitea/models/unittest" 14 + user_model "code.gitea.io/gitea/models/user" 10 15 "code.gitea.io/gitea/tests" 11 16 12 17 "github.com/stretchr/testify/assert" 18 + "github.com/stretchr/testify/require" 13 19 ) 14 20 15 21 func TestViewPulls(t *testing.T) { ··· 23 29 placeholder, _ := search.Attr("placeholder") 24 30 assert.Equal(t, "Search pulls...", placeholder) 25 31 } 32 + 33 + func TestPullManuallyMergeWarning(t *testing.T) { 34 + defer tests.PrepareTestEnv(t)() 35 + 36 + user2 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2}) 37 + session := loginUser(t, user2.Name) 38 + 39 + warningMessage := `Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.` 40 + t.Run("Autodetect disabled", func(t *testing.T) { 41 + defer tests.PrintCurrentTest(t)() 42 + 43 + req := NewRequest(t, "GET", "/user2/repo1/pulls/3") 44 + resp := session.MakeRequest(t, req, http.StatusOK) 45 + 46 + htmlDoc := NewHTMLParser(t, resp.Body) 47 + mergeInstructions := htmlDoc.Find("#merge-instructions").Text() 48 + assert.Contains(t, mergeInstructions, warningMessage) 49 + }) 50 + 51 + pullRequestUnit := unittest.AssertExistsAndLoadBean(t, &repo_model.RepoUnit{RepoID: 1, Type: unit.TypePullRequests}) 52 + config := pullRequestUnit.PullRequestsConfig() 53 + config.AutodetectManualMerge = true 54 + _, err := db.GetEngine(db.DefaultContext).ID(pullRequestUnit.ID).Cols("config").Update(pullRequestUnit) 55 + require.NoError(t, err) 56 + 57 + t.Run("Autodetect enabled", func(t *testing.T) { 58 + defer tests.PrintCurrentTest(t)() 59 + 60 + req := NewRequest(t, "GET", "/user2/repo1/pulls/3") 61 + resp := session.MakeRequest(t, req, http.StatusOK) 62 + 63 + htmlDoc := NewHTMLParser(t, resp.Body) 64 + mergeInstructions := htmlDoc.Find("#merge-instructions").Text() 65 + assert.NotContains(t, mergeInstructions, warningMessage) 66 + }) 67 + }