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 'feat: When comparing in repos, mention that pull request creation requires sign-in' (#6286) from litchipi/forgejo:contrib/sign_in_pr_ui into forgejo

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/6286
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
Reviewed-by: Otto <otto@codeberg.org>

Otto 6723087a 9c43fa06

+46
+1
options/locale/locale_en-US.ini
··· 1845 1845 pulls.view = View pull request 1846 1846 pulls.edit.already_changed = Unable to save changes to the pull request. It appears the content has already been changed by another user. Please refresh the page and try editing again to avoid overwriting their changes 1847 1847 pulls.compare_changes = New pull request 1848 + pulls.sign_in_require = <a href="%s">Sign in</a> to create a new pull request. 1848 1849 pulls.allow_edits_from_maintainers = Allow edits from maintainers 1849 1850 pulls.allow_edits_from_maintainers_desc = Users with write access to the base branch can also push to this branch 1850 1851 pulls.allow_edits_from_maintainers_err = Updating failed
+1
routers/web/repo/compare.go
··· 51 51 func setCompareContext(ctx *context.Context, before, head *git.Commit, headOwner, headName string) { 52 52 ctx.Data["BeforeCommit"] = before 53 53 ctx.Data["HeadCommit"] = head 54 + ctx.Data["SignInLink"] = setting.AppSubURL + "/user/login?redirect_to=" + url.QueryEscape(ctx.Data["Link"].(string)) 54 55 55 56 ctx.Data["GetBlobByPathForCommit"] = func(commit *git.Commit, path string) *git.Blob { 56 57 if commit == nil {
+4
templates/repo/diff/compare.tmpl
··· 215 215 {{ctx.Locale.Tr "repo.archive.title_date" (DateUtils.AbsoluteLong .Repository.ArchivedUnix)}} 216 216 {{end}} 217 217 </div> 218 + {{else}} 219 + <div class="ui warning message tw-mb-4"> 220 + {{ctx.Locale.Tr "repo.pulls.sign_in_require" .SignInLink}} 221 + </div> 218 222 {{end}} 219 223 {{if $.IsSigned}} 220 224 <div class="pullrequest-form {{if not .Flash}}tw-hidden{{end}}">
+40
tests/integration/compare_test.go
··· 291 291 }) 292 292 }) 293 293 } 294 + 295 + func TestCompareSignedIn(t *testing.T) { 296 + onGiteaRun(t, func(t *testing.T, giteaURL *url.URL) { 297 + // Setup the test with a connected user 298 + session := loginUser(t, "user1") 299 + testRepoFork(t, session, "user2", "repo1", "user1", "repo1") 300 + testCreateBranch(t, session, "user1", "repo1", "branch/master", "recent-push", http.StatusSeeOther) 301 + testEditFile(t, session, "user1", "repo1", "recent-push", "README.md", "Hello recently!\n") 302 + 303 + newPrSelector := "button.ui.button.primary.show-form" 304 + 305 + t.Run("PR creation button displayed if logged in", func(t *testing.T) { 306 + defer tests.PrintCurrentTest(t)() 307 + 308 + req := NewRequest(t, "GET", "/user1/repo1/compare/master...recent-push") 309 + resp := session.MakeRequest(t, req, http.StatusOK) 310 + htmlDoc := NewHTMLParser(t, resp.Body) 311 + 312 + // Check that the "Sign in" button doesn't show up 313 + htmlDoc.AssertElement(t, "a[href='/user/login?redirect_to=%2Fuser1%2Frepo1%2Fcompare%2Fmaster...recent-push']", false) 314 + 315 + // Check that the "New pull request" button shows up 316 + htmlDoc.AssertElement(t, newPrSelector, true) 317 + }) 318 + 319 + t.Run("no PR creation button but display warning", func(t *testing.T) { 320 + defer tests.PrintCurrentTest(t)() 321 + 322 + req := NewRequest(t, "GET", "/user1/repo1/compare/master...recent-push") 323 + resp := MakeRequest(t, req, http.StatusOK) 324 + htmlDoc := NewHTMLParser(t, resp.Body) 325 + 326 + // Check that the "Sign in" button shows up 327 + htmlDoc.AssertElement(t, "a[href='/user/login?redirect_to=%2Fuser1%2Frepo1%2Fcompare%2Fmaster...recent-push']", true) 328 + 329 + // Check that the "New pull request" button doesn't show up 330 + htmlDoc.AssertElement(t, newPrSelector, false) 331 + }) 332 + }) 333 + }