From f64c2e0a7fe6587c824f98a0054f1fd88d969ed5 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Fri, 17 May 2024 00:06:12 +0000 Subject: [PATCH 01/41] Update dependency @github/text-expander-element to v2.7.0 --- package-lock.json | 21 ++++++++++++++++----- package.json | 2 +- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 5e9a74dd3..ee0682776 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,7 @@ "@citation-js/plugin-software-formats": "0.6.1", "@github/markdown-toolbar-element": "2.2.3", "@github/relative-time-element": "4.4.0", - "@github/text-expander-element": "2.6.1", + "@github/text-expander-element": "2.7.0", "@mcaptcha/vanilla-glue": "0.1.0-alpha-3", "@primer/octicons": "19.9.0", "add-asset-webpack-plugin": "2.0.1", @@ -1003,11 +1003,13 @@ "integrity": "sha512-CrI6oAecoahG7PF5dsgjdvlF5kCtusVMjg810EULD81TvnDsP+k/FRi/ClFubWLgBo4EGpr2EfvmumtqQFo7ow==" }, "node_modules/@github/text-expander-element": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/@github/text-expander-element/-/text-expander-element-2.6.1.tgz", - "integrity": "sha512-i6krPGXJRABfKXut0WArFd365Je4PT0MljtDoXUoCOEp+lGrmdosDMxmO0EfOYc97jBn+Hd2XO1mMsuI5+fwmQ==", + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/@github/text-expander-element/-/text-expander-element-2.7.0.tgz", + "integrity": "sha512-zeo7l2L91o6yuGHJfA1Xtpg6UgDuZGq0WCgplDwd+54pVIsNzwsynIo6oTjE03cCtqLQpdYRe1wSQxyKYZOoGw==", + "license": "MIT", "dependencies": { - "@github/combobox-nav": "^2.0.2" + "@github/combobox-nav": "^2.0.2", + "dom-input-range": "^1.1.3" } }, "node_modules/@humanwhocodes/config-array": { @@ -4809,6 +4811,15 @@ "node": ">=6.0.0" } }, + "node_modules/dom-input-range": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/dom-input-range/-/dom-input-range-1.1.5.tgz", + "integrity": "sha512-ITURvugfDoy8Wk8JC6NoI4dKyLPR4qbFnXJ+V+qVpQtTmDgT8HZjH2iNUIMiEU1kkdWEMLgDxYTSXJnPz9aeiA==", + "license": "MIT", + "workspaces": [ + "demos" + ] + }, "node_modules/dom-serializer": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-2.0.0.tgz", diff --git a/package.json b/package.json index 1aeecee61..420800b7e 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "@citation-js/plugin-software-formats": "0.6.1", "@github/markdown-toolbar-element": "2.2.3", "@github/relative-time-element": "4.4.0", - "@github/text-expander-element": "2.6.1", + "@github/text-expander-element": "2.7.0", "@mcaptcha/vanilla-glue": "0.1.0-alpha-3", "@primer/octicons": "19.9.0", "add-asset-webpack-plugin": "2.0.1", From 95ae3a3c7e4c0f81ddab3298d08b73c11c4aa9b5 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Fri, 24 May 2024 02:04:27 +0000 Subject: [PATCH 02/41] Update dependency postcss-nesting to v12.1.5 --- package-lock.json | 18 ++++++++++-------- package.json | 2 +- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2ce271fe0..73ac24a18 100644 --- a/package-lock.json +++ b/package-lock.json @@ -41,7 +41,7 @@ "pdfobject": "2.3.0", "postcss": "8.4.38", "postcss-loader": "8.1.1", - "postcss-nesting": "12.1.4", + "postcss-nesting": "12.1.5", "pretty-ms": "9.0.0", "sortablejs": "1.15.2", "swagger-ui-dist": "5.17.12", @@ -9870,9 +9870,9 @@ } }, "node_modules/postcss-nesting": { - "version": "12.1.4", - "resolved": "https://registry.npmjs.org/postcss-nesting/-/postcss-nesting-12.1.4.tgz", - "integrity": "sha512-CcHOq94K137E+U4Ommu7pexcpp0Tjm24zl4UcqWs1oSLAr5cLI+jLrqQ5h/bdjhMX6cMbzunyustVNnvrzF8Zg==", + "version": "12.1.5", + "resolved": "https://registry.npmjs.org/postcss-nesting/-/postcss-nesting-12.1.5.tgz", + "integrity": "sha512-N1NgI1PDCiAGWPTYrwqm8wpjv0bgDmkYHH72pNsqTCv9CObxjxftdYu6AKtGN+pnJa7FQjMm3v4sp8QJbFsYdQ==", "funding": [ { "type": "github", @@ -9883,10 +9883,11 @@ "url": "https://opencollective.com/csstools" } ], + "license": "MIT-0", "dependencies": { "@csstools/selector-resolve-nested": "^1.1.0", "@csstools/selector-specificity": "^3.1.1", - "postcss-selector-parser": "^6.0.13" + "postcss-selector-parser": "^6.1.0" }, "engines": { "node": "^14 || ^16 || >=18" @@ -9944,9 +9945,10 @@ } }, "node_modules/postcss-selector-parser": { - "version": "6.0.16", - "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-6.0.16.tgz", - "integrity": "sha512-A0RVJrX+IUkVZbW3ClroRWurercFhieevHB38sr2+l9eUClMqome3LmEmnhlNy+5Mr2EYN6B2Kaw9wYdd+VHiw==", + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-6.1.0.tgz", + "integrity": "sha512-UMz42UD0UY0EApS0ZL9o1XnLhSTtvvvLe5Dc2H2O56fvRZi+KulDyf5ctDhhtYJBGKStV2FL1fy6253cmLgqVQ==", + "license": "MIT", "dependencies": { "cssesc": "^3.0.0", "util-deprecate": "^1.0.2" diff --git a/package.json b/package.json index b8b37fefd..2c7ab9287 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "pdfobject": "2.3.0", "postcss": "8.4.38", "postcss-loader": "8.1.1", - "postcss-nesting": "12.1.4", + "postcss-nesting": "12.1.5", "pretty-ms": "9.0.0", "sortablejs": "1.15.2", "swagger-ui-dist": "5.17.12", From a62a88764970d70287395896f511a884129c29ac Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Mon, 20 May 2024 13:57:57 +0800 Subject: [PATCH 03/41] Fix incorrect "blob excerpt" link when comparing files (#31013) When comparing files between the base repo and forked repo, the "blob excerpt" link should point to the forked repo, because the commit doesn't exist in base repo. Co-authored-by: Giteabot (cherry picked from commit f48cc501c46a2d34eb701561f01d888d689d60d5) Conflicts: - templates/repo/diff/section_split.tmpl - templates/repo/diff/section_unified.tmpl Resolved the conflict by picking Gitea's change over ours, and porting it. - tests/integration/compare_test.go Kept our test, but picked the "compare all of the relevant links" part of the Gitea test. --- templates/repo/diff/section_split.tmpl | 7 ++++--- templates/repo/diff/section_unified.tmpl | 7 ++++--- tests/integration/compare_test.go | 12 ++++++++++-- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/templates/repo/diff/section_split.tmpl b/templates/repo/diff/section_split.tmpl index 7b1f72939..50522d989 100644 --- a/templates/repo/diff/section_split.tmpl +++ b/templates/repo/diff/section_split.tmpl @@ -1,4 +1,5 @@ {{$file := .file}} +{{$blobExcerptRepoLink := or $.root.CommitRepoLink $.root.RepoLink}} @@ -18,17 +19,17 @@
{{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 5)}} - {{end}} {{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 4)}} - {{end}} {{if eq $line.GetExpandDirection 2}} - {{end}} diff --git a/templates/repo/diff/section_unified.tmpl b/templates/repo/diff/section_unified.tmpl index d7fe75895..ab78097f2 100644 --- a/templates/repo/diff/section_unified.tmpl +++ b/templates/repo/diff/section_unified.tmpl @@ -1,4 +1,5 @@ {{$file := .file}} +{{$blobExcerptRepoLink := or $.root.CommitRepoLink $.root.RepoLink}} @@ -14,17 +15,17 @@
{{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 5)}} - {{end}} {{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 4)}} - {{end}} {{if eq $line.GetExpandDirection 2}} - {{end}} diff --git a/tests/integration/compare_test.go b/tests/integration/compare_test.go index ffcdd2f23..50c5b373a 100644 --- a/tests/integration/compare_test.go +++ b/tests/integration/compare_test.go @@ -251,8 +251,16 @@ func TestCompareCodeExpand(t *testing.T) { owner.Name, repo.Name, forker.Name, repo.Name+"-copy") resp := session.MakeRequest(t, req, http.StatusOK) htmlDoc := NewHTMLParser(t, resp.Body) - htmlDoc.AssertElement(t, fmt.Sprintf("button.code-expander-button[hx-get^='/%s/%s/blob_excerpt/'] svg.octicon-fold-up", forker.Name, repo.Name+"-copy"), true) - htmlDoc.AssertElement(t, fmt.Sprintf("button.code-expander-button[hx-get^='/%s/%s/blob_excerpt/'] svg.octicon-fold-down", forker.Name, repo.Name+"-copy"), true) + + els := htmlDoc.Find(`button.code-expander-button[hx-get]`) + + // all the links in the comparison should be to the forked repo&branch + assert.NotZero(t, els.Length()) + expectedPrefix := fmt.Sprintf("/%s/%s/blob_excerpt/", forker.Name, repo.Name+"-copy") + for i := 0; i < els.Length(); i++ { + link := els.Eq(i).AttrOr("hx-get", "") + assert.True(t, strings.HasPrefix(link, expectedPrefix)) + } }) }) } From fd9ee1901b44224d41de762dc2b28fc8a4367951 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Fri, 24 May 2024 10:30:38 +0200 Subject: [PATCH 04/41] tests: Add a test for code expansion on PRs This adds a new test case to `TestCompareCodeExpand` to exercise the case where we're viewing a PR's diff. Signed-off-by: Gergely Nagy --- tests/integration/compare_test.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/integration/compare_test.go b/tests/integration/compare_test.go index 50c5b373a..5d585e061 100644 --- a/tests/integration/compare_test.go +++ b/tests/integration/compare_test.go @@ -18,6 +18,7 @@ import ( user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/optional" + "code.gitea.io/gitea/modules/test" repo_service "code.gitea.io/gitea/services/repository" files_service "code.gitea.io/gitea/services/repository/files" "code.gitea.io/gitea/tests" @@ -262,5 +263,30 @@ func TestCompareCodeExpand(t *testing.T) { assert.True(t, strings.HasPrefix(link, expectedPrefix)) } }) + + t.Run("code expander targets the repo in a PR", func(t *testing.T) { + defer tests.PrintCurrentTest(t)() + + // Create a pullrequest + resp := testPullCreate(t, session, forker.Name, repo.Name+"-copy", false, "main", "code-expand", "This is a pull title") + + // Grab the URL for the PR + url := test.RedirectURL(resp) + "/files" + + // Visit the PR's diff + req := NewRequest(t, "GET", url) + resp = session.MakeRequest(t, req, http.StatusOK) + htmlDoc := NewHTMLParser(t, resp.Body) + + els := htmlDoc.Find(`button.code-expander-button[hx-get]`) + + // all the links in the comparison should be to the original repo&branch + assert.NotZero(t, els.Length()) + expectedPrefix := fmt.Sprintf("/%s/%s/blob_excerpt/", owner.Name, repo.Name) + for i := 0; i < els.Length(); i++ { + link := els.Eq(i).AttrOr("hx-get", "") + assert.True(t, strings.HasPrefix(link, expectedPrefix)) + } + }) }) } From bb165fadf6cc12822394ee7bc4e0a47c4383ba83 Mon Sep 17 00:00:00 2001 From: oliverpool Date: Wed, 22 May 2024 11:46:51 +0200 Subject: [PATCH 05/41] test: check hook_task deletion move test to integration to ensure Sqlite + MySQL testing --- models/fixtures/hook_task.yml | 6 ++++++ .../integration/repo_delete_test.go | 20 ++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) rename services/repository/delete_test.go => tests/integration/repo_delete_test.go (73%) diff --git a/models/fixtures/hook_task.yml b/models/fixtures/hook_task.yml index d573406b3..fc0e03bca 100644 --- a/models/fixtures/hook_task.yml +++ b/models/fixtures/hook_task.yml @@ -35,3 +35,9 @@ "X-Head": "42" } } + +- + id: 4 + hook_id: 3 + uuid: uuid4 + is_delivered: false diff --git a/services/repository/delete_test.go b/tests/integration/repo_delete_test.go similarity index 73% rename from services/repository/delete_test.go rename to tests/integration/repo_delete_test.go index 869b8af11..10e99db44 100644 --- a/services/repository/delete_test.go +++ b/tests/integration/repo_delete_test.go @@ -1,7 +1,7 @@ // Copyright 2017 The Gitea Authors. All rights reserved. // SPDX-License-Identifier: MIT -package repository_test +package integration import ( "testing" @@ -11,6 +11,7 @@ import ( repo_model "code.gitea.io/gitea/models/repo" "code.gitea.io/gitea/models/unittest" user_model "code.gitea.io/gitea/models/user" + webhook_model "code.gitea.io/gitea/models/webhook" repo_service "code.gitea.io/gitea/services/repository" "github.com/stretchr/testify/assert" @@ -51,5 +52,22 @@ func TestDeleteOwnerRepositoriesDirectly(t *testing.T) { user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2}) + deletedHookID := unittest.AssertExistsAndLoadBean(t, &webhook_model.Webhook{RepoID: 1}).ID + unittest.AssertExistsAndLoadBean(t, &webhook_model.HookTask{ + HookID: deletedHookID, + }) + + preservedHookID := unittest.AssertExistsAndLoadBean(t, &webhook_model.Webhook{RepoID: 3}).ID + unittest.AssertExistsAndLoadBean(t, &webhook_model.HookTask{ + HookID: preservedHookID, + }) + assert.NoError(t, repo_service.DeleteOwnerRepositoriesDirectly(db.DefaultContext, user)) + + unittest.AssertNotExistsBean(t, &webhook_model.HookTask{ + HookID: deletedHookID, + }) + unittest.AssertExistsAndLoadBean(t, &webhook_model.HookTask{ + HookID: preservedHookID, + }) } From 4ffda656e8fe489676e28541e5a01311e36698a9 Mon Sep 17 00:00:00 2001 From: oliverpool Date: Wed, 22 May 2024 12:16:05 +0200 Subject: [PATCH 06/41] mysql: use inner join for hook_task deletion Attempt to fix #3678 --- release-notes/8.0.0/perf/3865.md | 1 + services/repository/delete.go | 23 ++++++++++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 release-notes/8.0.0/perf/3865.md diff --git a/release-notes/8.0.0/perf/3865.md b/release-notes/8.0.0/perf/3865.md new file mode 100644 index 000000000..88860c715 --- /dev/null +++ b/release-notes/8.0.0/perf/3865.md @@ -0,0 +1 @@ +Attempt to speed up user deletion when using mariadb 10 (the subquery took advantage of the available index starting with mariadb 11). diff --git a/services/repository/delete.go b/services/repository/delete.go index 21d9ebcf0..6e8419475 100644 --- a/services/repository/delete.go +++ b/services/repository/delete.go @@ -26,6 +26,7 @@ import ( actions_module "code.gitea.io/gitea/modules/actions" "code.gitea.io/gitea/modules/lfs" "code.gitea.io/gitea/modules/log" + "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/storage" "xorm.io/builder" @@ -125,9 +126,25 @@ func DeleteRepositoryDirectly(ctx context.Context, doer *user_model.User, repoID return err } - if _, err := db.GetEngine(ctx).In("hook_id", builder.Select("id").From("webhook").Where(builder.Eq{"webhook.repo_id": repo.ID})). - Delete(&webhook.HookTask{}); err != nil { - return err + if setting.Database.Type.IsMySQL() { + // mariadb:10 does not use the hook_task KEY when using IN. + // https://codeberg.org/forgejo/forgejo/issues/3678 + // + // Version 11 does support it, but is not available in debian yet. + // Version 11.4 LTS is not available yet (stable should be released mid 2024 https://mariadb.org/mariadb/all-releases/) + + // Sqlite does not support the DELETE *** FROM *** syntax + // https://stackoverflow.com/q/24511153/3207406 + + // in the meantime, use a dedicated query for mysql... + if _, err := db.Exec(ctx, "DELETE `hook_task` FROM `hook_task` INNER JOIN `webhook` ON `webhook`.id = `hook_task`.hook_id WHERE `webhook`.repo_id = ?", repo.ID); err != nil { + return err + } + } else { + if _, err := db.GetEngine(ctx).In("hook_id", builder.Select("id").From("webhook").Where(builder.Eq{"webhook.repo_id": repo.ID})). + Delete(&webhook.HookTask{}); err != nil { + return err + } } if err := db.DeleteBeans(ctx, From f6c1fd76f2aee79d3e1923970e16fbb44ea2bf70 Mon Sep 17 00:00:00 2001 From: silverwind Date: Tue, 16 Apr 2024 10:52:45 +0200 Subject: [PATCH 07/41] Fix long branch name overflows (https://github.com/go-gitea/gitea/pull/30345) Fixes: https://github.com/go-gitea/gitea/issues/27971 Fixes: https://github.com/go-gitea/gitea/pull/28010 Screenshot 2024-04-09 at 00 19 57 Also fixes a similar issue in issue list where CSS was there but not active because of missing `display: block`. Screenshot 2024-04-09 at 00 18 25 --- Little conflict in branch_selector_field (repo.pulls.no_results is renamed in Gitea) And some weird conflict on new CSS rules added. --- templates/repo/branch_dropdown.tmpl | 4 ++-- .../sidebar/branch_selector_field.tmpl | 6 +++--- templates/repo/issue/view_title.tmpl | 2 +- templates/shared/issuelist.tmpl | 15 ++++++++------ web_src/css/base.css | 2 ++ web_src/css/repo.css | 20 ++++++------------- web_src/css/repo/issue-list.css | 6 ++++-- .../js/components/RepoBranchTagSelector.vue | 4 ++-- 8 files changed, 29 insertions(+), 30 deletions(-) diff --git a/templates/repo/branch_dropdown.tmpl b/templates/repo/branch_dropdown.tmpl index 707f670e9..dcb179248 100644 --- a/templates/repo/branch_dropdown.tmpl +++ b/templates/repo/branch_dropdown.tmpl @@ -71,7 +71,7 @@ {{/* show dummy elements before Vue componment is mounted, this code must match the code in BranchTagSelector.vue */}}