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 '[gitea] week 2024-31 cherry pick (gitea/main -> forgejo)' (#4716) from earl-warren/wcp/2024-31 into forgejo

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4716
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
Reviewed-by: 0ko <0ko@noreply.codeberg.org>

+105 -10
-1
.deadcode-out
··· 86 86 WatchRepoMode 87 87 88 88 code.gitea.io/gitea/models/user 89 - IsErrPrimaryEmailCannotDelete 90 89 ErrUserInactive.Error 91 90 ErrUserInactive.Unwrap 92 91 IsErrExternalLoginUserAlreadyExist
+1
.envrc
··· 1 + use flake
+3
.gitignore
··· 115 115 *_source.tar.bz2 116 116 .DS_Store 117 117 118 + # nix-direnv generated files 119 + .direnv/ 120 + 118 121 # Make evidence files 119 122 /.make_evidence 120 123
+1
models/user/email_address.go
··· 350 350 351 351 // SearchEmailResult is an e-mail address found in the user or email_address table 352 352 type SearchEmailResult struct { 353 + ID int64 353 354 UID int64 354 355 Email string 355 356 IsActivated bool
+6 -1
modules/indexer/issues/dboptions.go
··· 44 44 searchOpt.ProjectID = optional.Some[int64](0) // Those issues with no project(projectid==0) 45 45 } 46 46 47 + if opts.AssigneeID > 0 { 48 + searchOpt.AssigneeID = optional.Some(opts.AssigneeID) 49 + } else if opts.AssigneeID == -1 { // FIXME: this is inconsistent from other places 50 + searchOpt.AssigneeID = optional.Some[int64](0) 51 + } 52 + 47 53 // See the comment of issues_model.SearchOptions for the reason why we need to convert 48 54 convertID := func(id int64) optional.Option[int64] { 49 55 if id > 0 { ··· 57 63 58 64 searchOpt.ProjectColumnID = convertID(opts.ProjectColumnID) 59 65 searchOpt.PosterID = convertID(opts.PosterID) 60 - searchOpt.AssigneeID = convertID(opts.AssigneeID) 61 66 searchOpt.MentionID = convertID(opts.MentionedID) 62 67 searchOpt.ReviewedID = convertID(opts.ReviewedID) 63 68 searchOpt.ReviewRequestedID = convertID(opts.ReviewRequestedID)
+6
modules/indexer/issues/indexer_test.go
··· 8 8 "testing" 9 9 10 10 "code.gitea.io/gitea/models/db" 11 + "code.gitea.io/gitea/models/issues" 11 12 "code.gitea.io/gitea/models/unittest" 12 13 "code.gitea.io/gitea/modules/indexer/issues/internal" 13 14 "code.gitea.io/gitea/modules/optional" ··· 149 150 AssigneeID: optional.Some(int64(1)), 150 151 }, 151 152 expectedIDs: []int64{6, 1}, 153 + }, 154 + { 155 + // NOTE: This tests no assignees filtering and also ToSearchOptions() to ensure it will set AssigneeID to 0 when it is passed as -1. 156 + opts: *ToSearchOptions("", &issues.IssuesOptions{AssigneeID: -1}), 157 + expectedIDs: []int64{22, 21, 16, 15, 14, 13, 12, 11, 20, 5, 19, 18, 10, 7, 4, 9, 8, 3, 2}, 152 158 }, 153 159 { 154 160 opts: SearchOptions{
+4
options/locale/locale_en-US.ini
··· 3094 3094 emails.duplicate_active = This email address is already active for a different user. 3095 3095 emails.change_email_header = Update Email Properties 3096 3096 emails.change_email_text = Are you sure you want to update this email address? 3097 + emails.delete = Delete Email 3098 + emails.delete_desc = Are you sure you want to delete this email address? 3099 + emails.deletion_success = The email address has been deleted. 3100 + emails.delete_primary_email_error = You can not delete the primary email. 3097 3101 3098 3102 orgs.org_manage_panel = Manage organizations 3099 3103 orgs.name = Name
+4
release-notes/4716.md
··· 1 + feat: [commit](https://codeberg.org/forgejo/forgejo/commit/8d23433dab08fcbb8043e5d239171fba59c53108): support pull_request_target event for commit status. 2 + fix: [commit](https://codeberg.org/forgejo/forgejo/commit/ee11a263f8c9de33d42fc117443f4054a311c875): add return type to GetRawFileOrLFS and GetRawFile. 3 + feat: [commit](https://codeberg.org/forgejo/forgejo/commit/cb9071bbf433715f0e16e39cb60126b65f8236a0): support delete user email in admin panel. 4 + fix: [commit](https://codeberg.org/forgejo/forgejo/commit/f61873c7e42b613405d367421ad19db80f831053): properly filter issue list given no assignees filter.
+7 -1
routers/api/v1/repo/file.go
··· 45 45 // --- 46 46 // summary: Get a file from a repository 47 47 // produces: 48 - // - application/json 48 + // - application/octet-stream 49 49 // parameters: 50 50 // - name: owner 51 51 // in: path ··· 70 70 // responses: 71 71 // 200: 72 72 // description: Returns raw file content. 73 + // schema: 74 + // type: file 73 75 // "404": 74 76 // "$ref": "#/responses/notFound" 75 77 ··· 96 98 // swagger:operation GET /repos/{owner}/{repo}/media/{filepath} repository repoGetRawFileOrLFS 97 99 // --- 98 100 // summary: Get a file or it's LFS object from a repository 101 + // produces: 102 + // - application/octet-stream 99 103 // parameters: 100 104 // - name: owner 101 105 // in: path ··· 120 124 // responses: 121 125 // 200: 122 126 // description: Returns raw file content. 127 + // schema: 128 + // type: file 123 129 // "404": 124 130 // "$ref": "#/responses/notFound" 125 131
+30
routers/web/admin/emails.go
··· 15 15 "code.gitea.io/gitea/modules/optional" 16 16 "code.gitea.io/gitea/modules/setting" 17 17 "code.gitea.io/gitea/services/context" 18 + "code.gitea.io/gitea/services/user" 18 19 ) 19 20 20 21 const ( ··· 150 151 redirect.RawQuery = q.Encode() 151 152 ctx.Redirect(redirect.String()) 152 153 } 154 + 155 + // DeleteEmail serves a POST request for delete a user's email 156 + func DeleteEmail(ctx *context.Context) { 157 + u, err := user_model.GetUserByID(ctx, ctx.FormInt64("Uid")) 158 + if err != nil || u == nil { 159 + ctx.ServerError("GetUserByID", err) 160 + return 161 + } 162 + 163 + email, err := user_model.GetEmailAddressByID(ctx, u.ID, ctx.FormInt64("id")) 164 + if err != nil || email == nil { 165 + ctx.ServerError("GetEmailAddressByID", err) 166 + return 167 + } 168 + 169 + if err := user.DeleteEmailAddresses(ctx, u, []string{email.Email}); err != nil { 170 + if user_model.IsErrPrimaryEmailCannotDelete(err) { 171 + ctx.Flash.Error(ctx.Tr("admin.emails.delete_primary_email_error")) 172 + ctx.JSONRedirect("") 173 + return 174 + } 175 + ctx.ServerError("DeleteEmailAddresses", err) 176 + return 177 + } 178 + log.Trace("Email address deleted: %s %s", u.Name, email.Email) 179 + 180 + ctx.Flash.Success(ctx.Tr("admin.emails.deletion_success")) 181 + ctx.JSONRedirect("") 182 + }
+3 -3
routers/web/feed/convert.go
··· 84 84 link := &feeds.Link{Href: act.GetCommentHTMLURL(ctx)} 85 85 86 86 // title 87 - title = act.ActUser.DisplayName() + " " 87 + title = act.ActUser.GetDisplayName() + " " 88 88 var titleExtra template.HTML 89 89 switch act.OpType { 90 90 case activities_model.ActionCreateRepo: ··· 260 260 Description: desc, 261 261 IsPermaLink: "false", 262 262 Author: &feeds.Author{ 263 - Name: act.ActUser.DisplayName(), 263 + Name: act.ActUser.GetDisplayName(), 264 264 Email: act.ActUser.GetEmail(), 265 265 }, 266 266 Id: fmt.Sprintf("%v: %v", strconv.FormatInt(act.ID, 10), link.Href), ··· 320 320 Link: link, 321 321 Created: rel.CreatedUnix.AsTime(), 322 322 Author: &feeds.Author{ 323 - Name: rel.Publisher.DisplayName(), 323 + Name: rel.Publisher.GetDisplayName(), 324 324 Email: rel.Publisher.GetEmail(), 325 325 }, 326 326 Id: fmt.Sprintf("%v: %v", strconv.FormatInt(rel.ID, 10), link.Href),
+1
routers/web/web.go
··· 696 696 m.Group("/emails", func() { 697 697 m.Get("", admin.Emails) 698 698 m.Post("/activate", admin.ActivateEmail) 699 + m.Post("/delete", admin.DeleteEmail) 699 700 }) 700 701 701 702 m.Group("/orgs", func() {
+6 -1
services/actions/commit_status.go
··· 12 12 "code.gitea.io/gitea/models/db" 13 13 git_model "code.gitea.io/gitea/models/git" 14 14 user_model "code.gitea.io/gitea/models/user" 15 + actions_module "code.gitea.io/gitea/modules/actions" 15 16 "code.gitea.io/gitea/modules/log" 16 17 api "code.gitea.io/gitea/modules/structs" 17 18 webhook_module "code.gitea.io/gitea/modules/webhook" ··· 53 54 } 54 55 sha = payload.HeadCommit.ID 55 56 case webhook_module.HookEventPullRequest, webhook_module.HookEventPullRequestSync: 56 - event = "pull_request" 57 + if run.TriggerEvent == actions_module.GithubEventPullRequestTarget { 58 + event = "pull_request_target" 59 + } else { 60 + event = "pull_request" 61 + } 57 62 payload, err := run.GetPullRequestEventPayload() 58 63 if err != nil { 59 64 return fmt.Errorf("GetPullRequestEventPayload: %w", err)
+18
templates/admin/emails/list.tmpl
··· 38 38 </th> 39 39 <th>{{ctx.Locale.Tr "admin.emails.primary"}}</th> 40 40 <th>{{ctx.Locale.Tr "admin.emails.activated"}}</th> 41 + <th></th> 41 42 </tr> 42 43 </thead> 43 44 <tbody> ··· 58 59 {{else}} 59 60 {{if .IsActivated}}{{svg "octicon-check"}}{{else}}{{svg "octicon-x"}}{{end}} 60 61 {{end}} 62 + </td> 63 + <td> 64 + <div class="tw-flex tw-gap-2"> 65 + <a class="delete-button" href="" data-url="{{$.Link}}/delete" data-id="{{.ID}}" data-data-uid="{{.UID}}">{{svg "octicon-trash"}}</a> 66 + </div> 61 67 </td> 62 68 </tr> 63 69 {{end}} ··· 95 101 </div> 96 102 97 103 </div> 104 + 105 + <div class="ui g-modal-confirm delete modal"> 106 + <div class="header"> 107 + {{svg "octicon-trash"}} 108 + {{ctx.Locale.Tr "admin.emails.delete"}} 109 + </div> 110 + <div class="content"> 111 + {{ctx.Locale.Tr "admin.emails.delete_desc"}} 112 + </div> 113 + {{template "base/modal_actions_confirm" .}} 114 + </div> 115 + 98 116 {{template "admin/layout_footer" .}}
+12 -3
templates/swagger/v1_json.tmpl
··· 10867 10867 }, 10868 10868 "/repos/{owner}/{repo}/media/{filepath}": { 10869 10869 "get": { 10870 + "produces": [ 10871 + "application/octet-stream" 10872 + ], 10870 10873 "tags": [ 10871 10874 "repository" 10872 10875 ], ··· 10903 10906 ], 10904 10907 "responses": { 10905 10908 "200": { 10906 - "description": "Returns raw file content." 10909 + "description": "Returns raw file content.", 10910 + "schema": { 10911 + "type": "file" 10912 + } 10907 10913 }, 10908 10914 "404": { 10909 10915 "$ref": "#/responses/notFound" ··· 13122 13128 "/repos/{owner}/{repo}/raw/{filepath}": { 13123 13129 "get": { 13124 13130 "produces": [ 13125 - "application/json" 13131 + "application/octet-stream" 13126 13132 ], 13127 13133 "tags": [ 13128 13134 "repository" ··· 13160 13166 ], 13161 13167 "responses": { 13162 13168 "200": { 13163 - "description": "Returns raw file content." 13169 + "description": "Returns raw file content.", 13170 + "schema": { 13171 + "type": "file" 13172 + } 13164 13173 }, 13165 13174 "404": { 13166 13175 "$ref": "#/responses/notFound"
+3
tests/integration/api_feed_plain_text_titles_test.go
··· 7 7 "net/http" 8 8 "testing" 9 9 10 + "code.gitea.io/gitea/modules/setting" 11 + "code.gitea.io/gitea/modules/test" 10 12 "code.gitea.io/gitea/tests" 11 13 12 14 "github.com/stretchr/testify/assert" ··· 15 17 func TestFeedPlainTextTitles(t *testing.T) { 16 18 // This test verifies that items' titles in feeds are generated as plain text. 17 19 // See https://codeberg.org/forgejo/forgejo/pulls/1595 20 + defer test.MockVariableValue(&setting.UI.DefaultShowFullName, true)() 18 21 19 22 t.Run("Feed plain text titles", func(t *testing.T) { 20 23 t.Run("Atom", func(t *testing.T) {