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-26 cherry pick (gitea/main -> forgejo)' (#4213) from earl-warren/wcp/2024-26 into forgejo

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4213
Reviewed-by: twenty-panda <twenty-panda@noreply.codeberg.org>

+190 -68
+3
.air.toml
··· 24 24 ] 25 25 exclude_regex = ["_test.go$", "_gen.go$"] 26 26 stop_on_error = true 27 + 28 + [log] 29 + main_only = true
-1
.deadcode-out
··· 210 210 StdJSON.Indent 211 211 212 212 code.gitea.io/gitea/modules/markup 213 - IsSameDomain 214 213 GetRendererByType 215 214 RenderString 216 215 IsMarkupFile
+4 -4
Dockerfile
··· 3 3 FROM --platform=$BUILDPLATFORM code.forgejo.org/oci/golang:1.22-alpine3.20 as build-env 4 4 5 5 ARG GOPROXY 6 - ENV GOPROXY ${GOPROXY:-direct} 6 + ENV GOPROXY=${GOPROXY:-direct} 7 7 8 8 ARG RELEASE_VERSION 9 9 ARG TAGS="sqlite sqlite_unlock_notify" 10 - ENV TAGS "bindata timetzdata $TAGS" 10 + ENV TAGS="bindata timetzdata $TAGS" 11 11 ARG CGO_EXTRA_CFLAGS 12 12 13 13 # ··· 92 92 git && \ 93 93 echo "git:*" | chpasswd -e 94 94 95 - ENV USER git 96 - ENV GITEA_CUSTOM /data/gitea 95 + ENV USER=git 96 + ENV GITEA_CUSTOM=/data/gitea 97 97 98 98 VOLUME ["/data"] 99 99
+9 -9
Dockerfile.rootless
··· 3 3 FROM --platform=$BUILDPLATFORM code.forgejo.org/oci/golang:1.22-alpine3.20 as build-env 4 4 5 5 ARG GOPROXY 6 - ENV GOPROXY ${GOPROXY:-direct} 6 + ENV GOPROXY=${GOPROXY:-direct} 7 7 8 8 ARG RELEASE_VERSION 9 9 ARG TAGS="sqlite sqlite_unlock_notify" 10 - ENV TAGS "bindata timetzdata $TAGS" 10 + ENV TAGS="bindata timetzdata $TAGS" 11 11 ARG CGO_EXTRA_CFLAGS 12 12 13 13 # ··· 95 95 96 96 #git:git 97 97 USER 1000:1000 98 - ENV GITEA_WORK_DIR /var/lib/gitea 99 - ENV GITEA_CUSTOM /var/lib/gitea/custom 100 - ENV GITEA_TEMP /tmp/gitea 101 - ENV TMPDIR /tmp/gitea 98 + ENV GITEA_WORK_DIR=/var/lib/gitea 99 + ENV GITEA_CUSTOM=/var/lib/gitea/custom 100 + ENV GITEA_TEMP=/tmp/gitea 101 + ENV TMPDIR=/tmp/gitea 102 102 103 103 # Legacy config file for backwards compatibility 104 104 # TODO: remove on next major version release 105 - ENV GITEA_APP_INI_LEGACY /etc/gitea/app.ini 105 + ENV GITEA_APP_INI_LEGACY=/etc/gitea/app.ini 106 106 107 - ENV GITEA_APP_INI ${GITEA_CUSTOM}/conf/app.ini 108 - ENV HOME "/var/lib/gitea/git" 107 + ENV GITEA_APP_INI=${GITEA_CUSTOM}/conf/app.ini 108 + ENV HOME="/var/lib/gitea/git" 109 109 VOLUME ["/var/lib/gitea", "/etc/gitea"] 110 110 WORKDIR /var/lib/gitea 111 111
+32
modules/cache/cache.go
··· 6 6 import ( 7 7 "fmt" 8 8 "strconv" 9 + "time" 9 10 10 11 "code.gitea.io/gitea/modules/setting" 11 12 ··· 38 39 } 39 40 40 41 return err 42 + } 43 + 44 + const ( 45 + testCacheKey = "DefaultCache.TestKey" 46 + SlowCacheThreshold = 100 * time.Microsecond 47 + ) 48 + 49 + func Test() (time.Duration, error) { 50 + if conn == nil { 51 + return 0, fmt.Errorf("default cache not initialized") 52 + } 53 + 54 + testData := fmt.Sprintf("%x", make([]byte, 500)) 55 + 56 + start := time.Now() 57 + 58 + if err := conn.Delete(testCacheKey); err != nil { 59 + return 0, fmt.Errorf("expect cache to delete data based on key if exist but got: %w", err) 60 + } 61 + if err := conn.Put(testCacheKey, testData, 10); err != nil { 62 + return 0, fmt.Errorf("expect cache to store data but got: %w", err) 63 + } 64 + testVal := conn.Get(testCacheKey) 65 + if testVal == nil { 66 + return 0, fmt.Errorf("expect cache hit but got none") 67 + } 68 + if testVal != testData { 69 + return 0, fmt.Errorf("expect cache to return same value as stored but got other") 70 + } 71 + 72 + return time.Since(start), nil 41 73 } 42 74 43 75 // GetCache returns the currently configured cache
+13
modules/cache/cache_test.go
··· 9 9 "time" 10 10 11 11 "code.gitea.io/gitea/modules/setting" 12 + "code.gitea.io/gitea/modules/test" 12 13 13 14 "github.com/stretchr/testify/assert" 14 15 ) ··· 32 33 }) 33 34 assert.Error(t, err) 34 35 assert.Nil(t, con) 36 + } 37 + 38 + func TestTest(t *testing.T) { 39 + defer test.MockVariableValue(&conn, nil)() 40 + _, err := Test() 41 + assert.Error(t, err) 42 + 43 + createTestCache() 44 + elapsed, err := Test() 45 + assert.NoError(t, err) 46 + // mem cache should take from 300ns up to 1ms on modern hardware ... 47 + assert.Less(t, elapsed, SlowCacheThreshold) 35 48 } 36 49 37 50 func TestGetCache(t *testing.T) {
+6 -19
modules/markup/html.go
··· 143 143 common.LinkRegex, _ = xurls.StrictMatchingScheme(strings.Join(withAuth, "|")) 144 144 } 145 145 146 - // IsSameDomain checks if given url string has the same hostname as current Gitea instance 147 - func IsSameDomain(s string) bool { 148 - if strings.HasPrefix(s, "/") { 149 - return true 150 - } 151 - if uapp, err := url.Parse(setting.AppURL); err == nil { 152 - if u, err := url.Parse(s); err == nil { 153 - return u.Host == uapp.Host 154 - } 155 - return false 156 - } 157 - return false 158 - } 159 - 160 146 type postProcessError struct { 161 147 context string 162 148 err error ··· 393 379 // We ignore code and pre. 394 380 switch node.Type { 395 381 case html.TextNode: 396 - textNode(ctx, procs, node) 382 + processTextNodes(ctx, procs, node) 397 383 case html.ElementNode: 398 384 if node.Data == "img" { 399 385 for i, attr := range node.Attr { ··· 436 422 for n := node.FirstChild; n != nil; n = n.NextSibling { 437 423 visitNode(ctx, procs, n) 438 424 } 425 + default: 439 426 } 440 427 // ignore everything else 441 428 } 442 429 443 - // textNode runs the passed node through various processors, in order to handle 430 + // processTextNodes runs the passed node through various processors, in order to handle 444 431 // all kinds of special links handled by the post-processing. 445 - func textNode(ctx *RenderContext, procs []processor, node *html.Node) { 446 - for _, processor := range procs { 447 - processor(ctx, node) 432 + func processTextNodes(ctx *RenderContext, procs []processor, node *html.Node) { 433 + for _, p := range procs { 434 + p(ctx, node) 448 435 } 449 436 } 450 437
-11
modules/markup/html_test.go
··· 135 135 `<p><a href="`+urlWithQuery+`" rel="nofollow"><code>`+sha[:10]+`/README.md (L1-L5)</code></a></p>`) 136 136 } 137 137 138 - func TestMisc_IsSameDomain(t *testing.T) { 139 - setting.AppURL = markup.TestAppURL 140 - 141 - sha := "b6dd6210eaebc915fd5be5579c58cce4da2e2579" 142 - commit := util.URLJoin(markup.TestRepoURL, "commit", sha) 143 - 144 - assert.True(t, markup.IsSameDomain(commit)) 145 - assert.False(t, markup.IsSameDomain("http://google.com/ncr")) 146 - assert.False(t, markup.IsSameDomain("favicon.ico")) 147 - } 148 - 149 138 func TestRender_links(t *testing.T) { 150 139 setting.AppURL = markup.TestAppURL 151 140
+4
modules/markup/markdown/markdown_test.go
··· 548 548 `$$a`, 549 549 `<p>$$a</p>` + nl, 550 550 }, 551 + { 552 + "$a$ ($b$) [$c$] {$d$}", 553 + `<p><code class="language-math is-loading">a</code> (<code class="language-math is-loading">b</code>) [$c$] {$d$}</p>` + nl, 554 + }, 551 555 } 552 556 553 557 for _, test := range testcases {
+5 -1
modules/markup/markdown/math/inline_parser.go
··· 45 45 return b == '.' || b == '!' || b == '?' || b == ',' || b == ';' || b == ':' 46 46 } 47 47 48 + func isBracket(b byte) bool { 49 + return b == ')' 50 + } 51 + 48 52 func isAlphanumeric(b byte) bool { 49 53 return (b >= 'a' && b <= 'z') || (b >= 'A' && b <= 'Z') || (b >= '0' && b <= '9') 50 54 } ··· 84 88 break 85 89 } 86 90 suceedingCharacter := line[pos] 87 - if !isPunctuation(suceedingCharacter) && !(suceedingCharacter == ' ') { 91 + if !isPunctuation(suceedingCharacter) && !(suceedingCharacter == ' ') && !isBracket(suceedingCharacter) { 88 92 return nil 89 93 } 90 94 if line[ender-1] != '\\' {
+2 -2
modules/structs/org_team.go
··· 24 24 // CreateTeamOption options for creating a team 25 25 type CreateTeamOption struct { 26 26 // required: true 27 - Name string `json:"name" binding:"Required;AlphaDashDot;MaxSize(30)"` 27 + Name string `json:"name" binding:"Required;AlphaDashDot;MaxSize(255)"` 28 28 Description string `json:"description" binding:"MaxSize(255)"` 29 29 IncludesAllRepositories bool `json:"includes_all_repositories"` 30 30 // enum: read,write,admin ··· 40 40 // EditTeamOption options for editing a team 41 41 type EditTeamOption struct { 42 42 // required: true 43 - Name string `json:"name" binding:"AlphaDashDot;MaxSize(30)"` 43 + Name string `json:"name" binding:"AlphaDashDot;MaxSize(255)"` 44 44 Description *string `json:"description" binding:"MaxSize(255)"` 45 45 IncludesAllRepositories *bool `json:"includes_all_repositories"` 46 46 // enum: read,write,admin
+47
options/gitignore/IAR
··· 1 + # Compiled binaries 2 + *.o 3 + *.bin 4 + *.elf 5 + *.hex 6 + *.map 7 + *.out 8 + *.obj 9 + 10 + # Trash 11 + *.bak 12 + thumbs.db 13 + *.~* 14 + 15 + # IAR Settings 16 + **/settings/*.crun 17 + **/settings/*.dbgdt 18 + **/settings/*.cspy 19 + **/settings/*.cspy.* 20 + **/settings/*.xcl 21 + **/settings/*.dni 22 + **/settings/*.wsdt 23 + **/settings/*.wspos 24 + 25 + # IAR Debug Exe 26 + **/Exe/*.sim 27 + 28 + # IAR Debug Obj 29 + **/Obj/*.pbd 30 + **/Obj/*.pbd.* 31 + **/Obj/*.pbi 32 + **/Obj/*.pbi.* 33 + 34 + # IAR project "Debug" directory 35 + Debug/ 36 + 37 + # IAR project "Release" directory 38 + Release/ 39 + 40 + # IAR project settings directory 41 + settings/ 42 + 43 + # IAR backup files 44 + Backup* 45 + 46 + # IAR .dep files 47 + *.dep
-7
options/gitignore/Objective-C
··· 42 42 fastlane/Preview.html 43 43 fastlane/screenshots/**/*.png 44 44 fastlane/test_output 45 - 46 - # Code Injection 47 - # 48 - # After new code Injection tools there's a generated folder /iOSInjectionProject 49 - # https://github.com/johnno1962/injectionforxcode 50 - 51 - iOSInjectionProject/
-3
options/gitignore/Terraform
··· 35 35 # Ignore CLI configuration files 36 36 .terraformrc 37 37 terraform.rc 38 - 39 - # Ignore hcl file 40 - .terraform.lock.hcl
+6
options/locale/locale_en-US.ini
··· 93 93 remove_label_str = Remove item "%s" 94 94 edit = Edit 95 95 view = View 96 + test = Test 96 97 97 98 enabled = Enabled 98 99 disabled = Disabled ··· 3321 3322 config.cache_interval = Cache interval 3322 3323 config.cache_conn = Cache connection 3323 3324 config.cache_item_ttl = Cache item TTL 3325 + 3326 + config.cache_test = Test Cache 3327 + config.cache_test_failed = Failed to probe the cache: %v. 3328 + config.cache_test_slow = Cache test successful, but response is slow: %s. 3329 + config.cache_test_succeeded = Cache test successful, got a response in %s. 3324 3330 3325 3331 config.session_config = Session configuration 3326 3332 config.session_provider = Session provider
+9
routers/web/admin/admin.go
··· 14 14 activities_model "code.gitea.io/gitea/models/activities" 15 15 "code.gitea.io/gitea/models/db" 16 16 "code.gitea.io/gitea/modules/base" 17 + "code.gitea.io/gitea/modules/cache" 17 18 "code.gitea.io/gitea/modules/graceful" 18 19 "code.gitea.io/gitea/modules/log" 19 20 "code.gitea.io/gitea/modules/setting" ··· 211 212 212 213 ctx.Data["DatabaseCheckHasProblems"] = hasProblem 213 214 } 215 + 216 + elapsed, err := cache.Test() 217 + if err != nil { 218 + ctx.Data["CacheError"] = err 219 + } else if elapsed > cache.SlowCacheThreshold { 220 + ctx.Data["CacheSlow"] = fmt.Sprint(elapsed) 221 + } 222 + 214 223 ctx.HTML(http.StatusOK, tplSelfCheck) 215 224 } 216 225
+17
routers/web/admin/config.go
··· 12 12 13 13 system_model "code.gitea.io/gitea/models/system" 14 14 "code.gitea.io/gitea/modules/base" 15 + "code.gitea.io/gitea/modules/cache" 15 16 "code.gitea.io/gitea/modules/git" 16 17 "code.gitea.io/gitea/modules/json" 17 18 "code.gitea.io/gitea/modules/log" ··· 37 38 ctx.Flash.Error(ctx.Tr("admin.config.test_mail_failed", email, err)) 38 39 } else { 39 40 ctx.Flash.Info(ctx.Tr("admin.config.test_mail_sent", email)) 41 + } 42 + 43 + ctx.Redirect(setting.AppSubURL + "/admin/config") 44 + } 45 + 46 + // TestCache test the cache settings 47 + func TestCache(ctx *context.Context) { 48 + elapsed, err := cache.Test() 49 + if err != nil { 50 + ctx.Flash.Error(ctx.Tr("admin.config.cache_test_failed", err)) 51 + } else { 52 + if elapsed > cache.SlowCacheThreshold { 53 + ctx.Flash.Warning(ctx.Tr("admin.config.cache_test_slow", elapsed)) 54 + } else { 55 + ctx.Flash.Info(ctx.Tr("admin.config.cache_test_succeeded", elapsed)) 56 + } 40 57 } 41 58 42 59 ctx.Redirect(setting.AppSubURL + "/admin/config")
+1
routers/web/web.go
··· 665 665 m.Get("", admin.Config) 666 666 m.Post("", admin.ChangeConfig) 667 667 m.Post("/test_mail", admin.SendTestMail) 668 + m.Post("/test_cache", admin.TestCache) 668 669 m.Get("/settings", admin.ConfigSettings) 669 670 }) 670 671
+6
services/externalaccount/user.go
··· 5 5 6 6 import ( 7 7 "context" 8 + "strconv" 8 9 "strings" 9 10 10 11 "code.gitea.io/gitea/models/auth" ··· 82 83 83 84 // UpdateMigrationsByType updates all migrated repositories' posterid from gitServiceType to replace originalAuthorID to posterID 84 85 func UpdateMigrationsByType(ctx context.Context, tp structs.GitServiceType, externalUserID string, userID int64) error { 86 + // Skip update if externalUserID is not a valid numeric ID or exceeds int64 87 + if _, err := strconv.ParseInt(externalUserID, 10, 64); err != nil { 88 + return nil 89 + } 90 + 85 91 if err := issues_model.UpdateIssuesMigrationsByType(ctx, tp, externalUserID, userID); err != nil { 86 92 return err 87 93 }
+10 -2
templates/admin/config.tmpl
··· 233 233 <dt>{{ctx.Locale.Tr "admin.config.mailer_user"}}</dt> 234 234 <dd>{{if .Mailer.User}}{{.Mailer.User}}{{else}}(empty){{end}}</dd> 235 235 <div class="divider"></div> 236 - <dt class="tw-py-1">{{ctx.Locale.Tr "admin.config.send_test_mail"}}</dt> 237 - <dd> 236 + <dt class="tw-py-1 tw-flex tw-items-center">{{ctx.Locale.Tr "admin.config.send_test_mail"}}</dt> 237 + <dd class="tw-py-0"> 238 238 <form class="ui form ignore-dirty" action="{{AppSubUrl}}/admin/config/test_mail" method="post"> 239 239 {{.CsrfTokenHtml}} 240 240 <div class="ui tiny input"> ··· 264 264 <dt>{{ctx.Locale.Tr "admin.config.cache_item_ttl"}}</dt> 265 265 <dd><code>{{.CacheItemTTL}}</code></dd> 266 266 {{end}} 267 + <div class="divider"></div> 268 + <dt class="tw-py-1 tw-flex tw-items-center">{{ctx.Locale.Tr "admin.config.cache_test"}}</dt> 269 + <dd class="tw-py-0"> 270 + <form class="ui form ignore-dirty" action="{{AppSubUrl}}/admin/config/test_cache" method="post"> 271 + {{.CsrfTokenHtml}} 272 + <button class="ui tiny primary button">{{ctx.Locale.Tr "test"}}</button> 273 + </form> 274 + </dd> 267 275 </dl> 268 276 </div> 269 277
+7
templates/admin/self_check.tmpl
··· 28 28 {{else}} 29 29 <div class="tw-p-2">{{ctx.Locale.Tr "admin.self_check.no_problem_found"}}</div> 30 30 {{end}} 31 + 32 + {{if .CacheError}} 33 + <div class="ui red message">{{ctx.Locale.Tr "admin.config.cache_test_failed" .CacheError}}</div> 34 + {{end}} 35 + {{if .CacheSlow}} 36 + <div class="ui warning message">{{ctx.Locale.Tr "admin.config.cache_test_slow" .CacheSlow}}</div> 37 + {{end}} 31 38 </div> 32 39 </div> 33 40
+1 -1
templates/repo/blame.tmpl
··· 2 2 {{$revsFileLink := URLJoin .RepoLink "src" .BranchNameSubURL "/.git-blame-ignore-revs"}} 3 3 {{if .UsesIgnoreRevs}} 4 4 <div class="ui info message"> 5 - <p>{{ctx.Locale.Tr "repo.blame.ignore_revs" $revsFileLink (print $revsFileLink "?bypass-blame-ignore=true")}}</p> 5 + <p>{{ctx.Locale.Tr "repo.blame.ignore_revs" $revsFileLink "?bypass-blame-ignore=true"}}</p> 6 6 </div> 7 7 {{else}} 8 8 <div class="ui error message">
+3 -3
templates/repo/diff/blob_excerpt.tmpl
··· 51 51 <td colspan="2" class="lines-num"> 52 52 <div class="tw-flex"> 53 53 {{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 5)}} 54 - <button class="code-expander-button" hx-target="closest tr" hx-get="{{$.RepoLink}}/blob_excerpt/{{PathEscape $.AfterCommitID}}?data-query={{$line.GetBlobExcerptQuery}}&style=unified&direction=down&wiki={{$.PageIsWiki}}&anchor={{$.Anchor}}"> 54 + <button class="code-expander-button" hx-target="closest tr" hx-get="{{$.RepoLink}}/blob_excerpt/{{PathEscape $.AfterCommitID}}?{{$line.GetBlobExcerptQuery}}&style=unified&direction=down&wiki={{$.PageIsWiki}}&anchor={{$.Anchor}}"> 55 55 {{svg "octicon-fold-down"}} 56 56 </button> 57 57 {{end}} 58 58 {{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 4)}} 59 - <button class="code-expander-button" hx-target="closest tr" hx-get="{{$.RepoLink}}/blob_excerpt/{{PathEscape $.AfterCommitID}}?data-query={{$line.GetBlobExcerptQuery}}&style=unified&direction=up&wiki={{$.PageIsWiki}}&anchor={{$.Anchor}}"> 59 + <button class="code-expander-button" hx-target="closest tr" hx-get="{{$.RepoLink}}/blob_excerpt/{{PathEscape $.AfterCommitID}}?{{$line.GetBlobExcerptQuery}}&style=unified&direction=up&wiki={{$.PageIsWiki}}&anchor={{$.Anchor}}"> 60 60 {{svg "octicon-fold-up"}} 61 61 </button> 62 62 {{end}} 63 63 {{if eq $line.GetExpandDirection 2}} 64 - <button class="code-expander-button" hx-target="closest tr" hx-get="{{$.RepoLink}}/blob_excerpt/{{PathEscape $.AfterCommitID}}?data-query={{$line.GetBlobExcerptQuery}}&style=unified&direction=&wiki={{$.PageIsWiki}}&anchor={{$.Anchor}}"> 64 + <button class="code-expander-button" hx-target="closest tr" hx-get="{{$.RepoLink}}/blob_excerpt/{{PathEscape $.AfterCommitID}}?{{$line.GetBlobExcerptQuery}}&style=unified&direction=&wiki={{$.PageIsWiki}}&anchor={{$.Anchor}}"> 65 65 {{svg "octicon-fold"}} 66 66 </button> 67 67 {{end}}
+5 -5
web_src/css/repo.css
··· 79 79 white-space: nowrap; 80 80 } 81 81 82 + .repository .issue-content-right .filter.menu { 83 + max-height: 500px; 84 + overflow-x: auto; 85 + } 86 + 82 87 .repository .filter.menu.labels .label-filter .menu .info { 83 88 display: inline-block; 84 89 padding: 0.5rem 0; ··· 579 584 580 585 .repository.new.issue .comment.form .content .markup { 581 586 font-size: 14px; 582 - } 583 - 584 - .repository.new.issue .comment.form .issue-content-right .filter.menu { 585 - max-height: 500px; 586 - overflow-x: auto; 587 587 } 588 588 589 589 .repository.view.issue .instruct-toggle {