From 3364092013aa4d5d27ad02806b0f47967c04de18 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Wed, 17 May 2023 18:26:43 +0800 Subject: [PATCH 01/30] Fix missed table name on iterate lfs meta objects --- models/git/lfs.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/git/lfs.go b/models/git/lfs.go index 0ba8e919d0..0f90b29200 100644 --- a/models/git/lfs.go +++ b/models/git/lfs.go @@ -390,7 +390,7 @@ func IterateLFSMetaObjectsForRepo(ctx context.Context, repoID int64, f func(cont for { beans := make([]*CountLFSMetaObject, 0, batchSize) - sess := engine.Select("`lfs_meta_object`.*, COUNT(`l1`.oid) AS `count`"). + sess := engine.Table("lfs_meta_object").Select("`lfs_meta_object`.*, COUNT(`l1`.oid) AS `count`"). Join("INNER", "`lfs_meta_object` AS l1", "`lfs_meta_object`.oid = `l1`.oid"). Where("`lfs_meta_object`.repository_id = ?", repoID) if !opts.OlderThan.IsZero() { From 29096d8ef5521442f760891d4b6c6196a70ea3ed Mon Sep 17 00:00:00 2001 From: Evur <63237520+evur@users.noreply.github.com> Date: Wed, 17 May 2023 12:55:34 +0200 Subject: [PATCH 02/30] Make the color of zero-contribution-squares in the activity heatmap more subtle (#24758) The previous color had a too high contrast with the background. --------- Co-authored-by: silverwind --- web_src/js/components/ActivityHeatmap.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web_src/js/components/ActivityHeatmap.vue b/web_src/js/components/ActivityHeatmap.vue index 7834ebe82c..acae1aedd0 100644 --- a/web_src/js/components/ActivityHeatmap.vue +++ b/web_src/js/components/ActivityHeatmap.vue @@ -31,8 +31,8 @@ export default { }, data: () => ({ colorRange: [ - 'var(--color-secondary-alpha-70)', - 'var(--color-secondary-alpha-70)', + 'var(--color-secondary-alpha-60)', + 'var(--color-secondary-alpha-60)', 'var(--color-primary-light-4)', 'var(--color-primary-light-2)', 'var(--color-primary)', From c839d6f92a63ee2adacf4f706403e93bbe69b2da Mon Sep 17 00:00:00 2001 From: Yarden Shoham Date: Wed, 17 May 2023 16:20:11 +0300 Subject: [PATCH 03/30] Revert "Fix missed table name on iterate lfs meta objects" (#24764) This reverts commit 3364092013aa4d5d27ad02806b0f47967c04de18. It was accidentally pushed to `main` without a review. --- models/git/lfs.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/git/lfs.go b/models/git/lfs.go index 0f90b29200..0ba8e919d0 100644 --- a/models/git/lfs.go +++ b/models/git/lfs.go @@ -390,7 +390,7 @@ func IterateLFSMetaObjectsForRepo(ctx context.Context, repoID int64, f func(cont for { beans := make([]*CountLFSMetaObject, 0, batchSize) - sess := engine.Table("lfs_meta_object").Select("`lfs_meta_object`.*, COUNT(`l1`.oid) AS `count`"). + sess := engine.Select("`lfs_meta_object`.*, COUNT(`l1`.oid) AS `count`"). Join("INNER", "`lfs_meta_object` AS l1", "`lfs_meta_object`.oid = `l1`.oid"). Where("`lfs_meta_object`.repository_id = ?", repoID) if !opts.OlderThan.IsZero() { From 9dd13e84ca3e614365e2ab303c7bee2d032f356c Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Wed, 17 May 2023 23:51:22 +0800 Subject: [PATCH 04/30] Fix missed table name on iterate lfs meta objects (#24768) --- models/git/lfs.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/git/lfs.go b/models/git/lfs.go index 0ba8e919d0..0f90b29200 100644 --- a/models/git/lfs.go +++ b/models/git/lfs.go @@ -390,7 +390,7 @@ func IterateLFSMetaObjectsForRepo(ctx context.Context, repoID int64, f func(cont for { beans := make([]*CountLFSMetaObject, 0, batchSize) - sess := engine.Select("`lfs_meta_object`.*, COUNT(`l1`.oid) AS `count`"). + sess := engine.Table("lfs_meta_object").Select("`lfs_meta_object`.*, COUNT(`l1`.oid) AS `count`"). Join("INNER", "`lfs_meta_object` AS l1", "`lfs_meta_object`.oid = `l1`.oid"). Where("`lfs_meta_object`.repository_id = ?", repoID) if !opts.OlderThan.IsZero() { From 655c890cbddbe99d649647232d313fc1f52c6aa2 Mon Sep 17 00:00:00 2001 From: silverwind Date: Wed, 17 May 2023 18:22:17 +0200 Subject: [PATCH 05/30] Fix TestMinioStorageIterator skip message (#24765) Followup to https://github.com/go-gitea/gitea/pull/24762, fix this message. --- modules/storage/minio_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/storage/minio_test.go b/modules/storage/minio_test.go index 861eedfe12..bfddf33032 100644 --- a/modules/storage/minio_test.go +++ b/modules/storage/minio_test.go @@ -10,7 +10,7 @@ import ( func TestMinioStorageIterator(t *testing.T) { if os.Getenv("CI") == "" { - t.Skip("minioStorage not present on CI") + t.Skip("minioStorage not present outside of CI") return } testStorageIterator(t, string(MinioStorageType), MinioStorageConfig{ From 71451ab8441b67a3629052e29b26b7ac815953f2 Mon Sep 17 00:00:00 2001 From: silverwind Date: Wed, 17 May 2023 22:59:12 +0200 Subject: [PATCH 06/30] Mark `models/fixtures` as generated (#24775) Makes diffs like https://github.com/go-gitea/gitea/pull/24676/files more readable. I'm not sure if those are actually generated, but they are good to collapse in diffs anyways. --- .gitattributes | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitattributes b/.gitattributes index 16167a2cd6..37f7311f11 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,6 +1,7 @@ * text=auto eol=lf *.tmpl linguist-language=Handlebars /assets/*.json linguist-generated +/models/fixtures/** linguist-generated /public/img/svg/*.svg linguist-generated /public/vendor/** -text -eol linguist-vendored /templates/swagger/v1_json.tmpl linguist-generated From 4aacc3ac784601339f663881e5cc253e982b3f37 Mon Sep 17 00:00:00 2001 From: silverwind Date: Thu, 18 May 2023 03:14:31 +0200 Subject: [PATCH 07/30] Add two eslint plugins (#24776) Add these two plugins and autofix issues: - [eslint-plugin-no-use-extend-native](https://github.com/dustinspecker/eslint-plugin-no-use-extend-native) - [eslint-plugin-array-func](https://github.com/freaktechnik/eslint-plugin-array-func) --- .eslintrc.yaml | 9 +++ package-lock.json | 113 +++++++++++++++++++++++++++ package.json | 2 + web_src/js/features/copycontent.js | 2 +- web_src/js/features/repo-projects.js | 2 +- web_src/js/utils/match.js | 2 +- 6 files changed, 127 insertions(+), 3 deletions(-) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index fd1b6da2c0..f4b1e67534 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -10,10 +10,12 @@ parserOptions: plugins: - "@eslint-community/eslint-plugin-eslint-comments" + - eslint-plugin-array-func - eslint-plugin-custom-elements - eslint-plugin-import - eslint-plugin-jquery - eslint-plugin-no-jquery + - eslint-plugin-no-use-extend-native - eslint-plugin-regexp - eslint-plugin-sonarjs - eslint-plugin-unicorn @@ -59,6 +61,12 @@ rules: array-bracket-spacing: [2, never] array-callback-return: [2, {checkForEach: true}] array-element-newline: [0] + array-func/avoid-reverse: [2] + array-func/from-map: [2] + array-func/no-unnecessary-this-arg: [2] + array-func/prefer-array-from: [2] + array-func/prefer-flat-map: [0] # handled by unicorn/prefer-array-flat-map + array-func/prefer-flat: [0] # handled by unicorn/prefer-array-flat arrow-body-style: [0] arrow-parens: [2, always] arrow-spacing: [2, {before: true, after: true}] @@ -444,6 +452,7 @@ rules: no-unused-private-class-members: [2] no-unused-vars: [2, {args: all, argsIgnorePattern: ^_, varsIgnorePattern: ^_, caughtErrorsIgnorePattern: ^_, destructuredArrayIgnorePattern: ^_, ignoreRestSiblings: false}] no-use-before-define: [2, {functions: false, classes: true, variables: true, allowNamedExports: true}] + no-use-extend-native/no-use-extend-native: [2] no-useless-backreference: [2] no-useless-call: [2] no-useless-catch: [2] diff --git a/package-lock.json b/package-lock.json index 7f30fe5ebc..c9d4bca3d7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -62,10 +62,12 @@ "@stoplight/spectral-cli": "6.6.0", "@vitejs/plugin-vue": "4.2.3", "eslint": "8.40.0", + "eslint-plugin-array-func": "3.1.8", "eslint-plugin-custom-elements": "0.0.8", "eslint-plugin-import": "2.27.5", "eslint-plugin-jquery": "1.5.1", "eslint-plugin-no-jquery": "2.7.0", + "eslint-plugin-no-use-extend-native": "0.5.0", "eslint-plugin-regexp": "1.15.0", "eslint-plugin-sonarjs": "0.19.0", "eslint-plugin-unicorn": "47.0.0", @@ -4602,6 +4604,18 @@ "ms": "^2.1.1" } }, + "node_modules/eslint-plugin-array-func": { + "version": "3.1.8", + "resolved": "https://registry.npmjs.org/eslint-plugin-array-func/-/eslint-plugin-array-func-3.1.8.tgz", + "integrity": "sha512-BjnbJvw+knaHgVddIL3q5xYcoqAZoK8wOdT7QF+mkvSAjXdZCdhL0z71Y7oRtgXA8BpN9QLJ2uHgD3I6ymlbOw==", + "dev": true, + "engines": { + "node": ">= 6.8.0" + }, + "peerDependencies": { + "eslint": ">=3.0.0" + } + }, "node_modules/eslint-plugin-custom-elements": { "version": "0.0.8", "resolved": "https://registry.npmjs.org/eslint-plugin-custom-elements/-/eslint-plugin-custom-elements-0.0.8.tgz", @@ -4710,6 +4724,21 @@ "eslint": ">=2.3.0" } }, + "node_modules/eslint-plugin-no-use-extend-native": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-no-use-extend-native/-/eslint-plugin-no-use-extend-native-0.5.0.tgz", + "integrity": "sha512-dBNjs8hor8rJgeXLH4HTut5eD3RGWf9JUsadIfuL7UosVQ/dnvOKwxEcRrXrFxrMZ8llUVWT+hOimxJABsAUzQ==", + "dev": true, + "dependencies": { + "is-get-set-prop": "^1.0.0", + "is-js-type": "^2.0.0", + "is-obj-prop": "^1.0.0", + "is-proto-prop": "^2.0.0" + }, + "engines": { + "node": ">=6.0.0" + } + }, "node_modules/eslint-plugin-regexp": { "version": "1.15.0", "resolved": "https://registry.npmjs.org/eslint-plugin-regexp/-/eslint-plugin-regexp-1.15.0.tgz", @@ -5269,6 +5298,15 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/get-set-props": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/get-set-props/-/get-set-props-0.1.0.tgz", + "integrity": "sha512-7oKuKzAGKj0ag+eWZwcGw2fjiZ78tXnXQoBgY0aU7ZOxTu4bB7hSuQSDgtKy978EDH062P5FmD2EWiDpQS9K9Q==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/get-source": { "version": "2.0.12", "resolved": "https://registry.npmjs.org/get-source/-/get-source-2.0.12.tgz", @@ -5999,6 +6037,16 @@ "node": ">=8" } }, + "node_modules/is-get-set-prop": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-get-set-prop/-/is-get-set-prop-1.0.0.tgz", + "integrity": "sha512-DvAYZ1ZgGUz4lzxKMPYlt08qAUqyG9ckSg2pIjfvcQ7+pkVNUHk8yVLXOnCLe5WKXhLop8oorWFBJHpwWQpszQ==", + "dev": true, + "dependencies": { + "get-set-props": "^0.1.0", + "lowercase-keys": "^1.0.0" + } + }, "node_modules/is-glob": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", @@ -6010,6 +6058,15 @@ "node": ">=0.10.0" } }, + "node_modules/is-js-type": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-js-type/-/is-js-type-2.0.0.tgz", + "integrity": "sha512-Aj13l47+uyTjlQNHtXBV8Cji3jb037vxwMWCgopRR8h6xocgBGW3qG8qGlIOEmbXQtkKShKuBM9e8AA1OeQ+xw==", + "dev": true, + "dependencies": { + "js-types": "^1.0.0" + } + }, "node_modules/is-negative-zero": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/is-negative-zero/-/is-negative-zero-2.0.2.tgz", @@ -6045,6 +6102,16 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/is-obj-prop": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-obj-prop/-/is-obj-prop-1.0.0.tgz", + "integrity": "sha512-5Idb61slRlJlsAzi0Wsfwbp+zZY+9LXKUAZpvT/1ySw+NxKLRWfa0Bzj+wXI3fX5O9hiddm5c3DAaRSNP/yl2w==", + "dev": true, + "dependencies": { + "lowercase-keys": "^1.0.0", + "obj-props": "^1.0.0" + } + }, "node_modules/is-path-inside": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz", @@ -6078,6 +6145,16 @@ "integrity": "sha512-bCYeRA2rVibKZd+s2625gGnGF/t7DSqDs4dP7CrLA1m7jKWz6pps0LpYLJN8Q64HtmPKJ1hrN3nzPNKFEKOUiQ==", "dev": true }, + "node_modules/is-proto-prop": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-proto-prop/-/is-proto-prop-2.0.0.tgz", + "integrity": "sha512-jl3NbQ/fGLv5Jhan4uX+Ge9ohnemqyblWVVCpAvtTQzNFvV2xhJq+esnkIbYQ9F1nITXoLfDDQLp7LBw/zzncg==", + "dev": true, + "dependencies": { + "lowercase-keys": "^1.0.0", + "proto-props": "^2.0.0" + } + }, "node_modules/is-reference": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/is-reference/-/is-reference-1.2.1.tgz", @@ -6295,6 +6372,15 @@ "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==" }, + "node_modules/js-types": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/js-types/-/js-types-1.0.0.tgz", + "integrity": "sha512-bfwqBW9cC/Lp7xcRpug7YrXm0IVw+T9e3g4mCYnv0Pjr3zIzU9PCQElYU9oSGAWzXlbdl9X5SAMPejO9sxkeUw==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/js-yaml": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", @@ -6701,6 +6787,15 @@ "get-func-name": "^2.0.0" } }, + "node_modules/lowercase-keys": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-1.0.1.tgz", + "integrity": "sha512-G2Lj61tXDnVFFOi8VZds+SoQjtQC3dgokKdDG2mTm1tx4m50NUHBOZSBwQQHyy0V12A0JTG4icfZQH+xPyh8VA==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/lru-cache": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", @@ -7312,6 +7407,15 @@ "integrity": "sha512-NHj4rzRo0tQdijE9ZqAx6kYDcoRwYwSYzCA8MY3JzfxlrvEU0jhnhJT9BhqhJs7I/dKcrDm6TyulaRqZPIhN5g==", "dev": true }, + "node_modules/obj-props": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/obj-props/-/obj-props-1.4.0.tgz", + "integrity": "sha512-p7p/7ltzPDiBs6DqxOrIbtRdwxxVRBj5ROukeNb9RgA+fawhrz5n2hpNz8DDmYR//tviJSj7nUnlppGmONkjiQ==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/object-assign": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", @@ -7957,6 +8061,15 @@ "react-is": "^16.13.1" } }, + "node_modules/proto-props": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/proto-props/-/proto-props-2.0.0.tgz", + "integrity": "sha512-2yma2tog9VaRZY2mn3Wq51uiSW4NcPYT1cQdBagwyrznrilKSZwIZ0UG3ZPL/mx+axEns0hE35T5ufOYZXEnBQ==", + "dev": true, + "engines": { + "node": ">=4" + } + }, "node_modules/proxy-agent": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/proxy-agent/-/proxy-agent-5.0.0.tgz", diff --git a/package.json b/package.json index 6ec0d755dc..179f0beb2d 100644 --- a/package.json +++ b/package.json @@ -62,10 +62,12 @@ "@stoplight/spectral-cli": "6.6.0", "@vitejs/plugin-vue": "4.2.3", "eslint": "8.40.0", + "eslint-plugin-array-func": "3.1.8", "eslint-plugin-custom-elements": "0.0.8", "eslint-plugin-import": "2.27.5", "eslint-plugin-jquery": "1.5.1", "eslint-plugin-no-jquery": "2.7.0", + "eslint-plugin-no-use-extend-native": "0.5.0", "eslint-plugin-regexp": "1.15.0", "eslint-plugin-sonarjs": "0.19.0", "eslint-plugin-unicorn": "47.0.0", diff --git a/web_src/js/features/copycontent.js b/web_src/js/features/copycontent.js index 646fafeb0f..621d6dab73 100644 --- a/web_src/js/features/copycontent.js +++ b/web_src/js/features/copycontent.js @@ -36,7 +36,7 @@ export function initCopyContent() { } } else { // text, read from DOM const lineEls = document.querySelectorAll('.file-view .lines-code'); - content = Array.from(lineEls).map((el) => el.textContent).join(''); + content = Array.from(lineEls, (el) => el.textContent).join(''); } // try copy original first, if that fails and it's an image, convert it to png diff --git a/web_src/js/features/repo-projects.js b/web_src/js/features/repo-projects.js index abbe23458e..b8cb651f69 100644 --- a/web_src/js/features/repo-projects.js +++ b/web_src/js/features/repo-projects.js @@ -15,7 +15,7 @@ function moveIssue({item, from, to, oldIndex}) { updateIssueCount(to); const columnSorting = { - issues: [...columnCards].map((card, i) => ({ + issues: Array.from(columnCards, (card, i) => ({ issueID: parseInt($(card).attr('data-issue')), sorting: i })) diff --git a/web_src/js/utils/match.js b/web_src/js/utils/match.js index 0d20ca336f..31763b0940 100644 --- a/web_src/js/utils/match.js +++ b/web_src/js/utils/match.js @@ -3,7 +3,7 @@ import emojis from '../../../assets/emoji.json'; const maxMatches = 6; function sortAndReduce(map) { - const sortedMap = new Map([...map.entries()].sort((a, b) => a[1] - b[1])); + const sortedMap = new Map(Array.from(map.entries()).sort((a, b) => a[1] - b[1])); return Array.from(sortedMap.keys()).slice(0, maxMatches); } From 040970c32092fb0bc1280a124163b19a70f2b320 Mon Sep 17 00:00:00 2001 From: silverwind Date: Thu, 18 May 2023 04:00:34 +0200 Subject: [PATCH 08/30] Enable two vue eslint rules (#24780) These two rules are no longer violated, so we can enable them again. --- web_src/js/components/.eslintrc.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/web_src/js/components/.eslintrc.yaml b/web_src/js/components/.eslintrc.yaml index d428b24951..4cc65edea9 100644 --- a/web_src/js/components/.eslintrc.yaml +++ b/web_src/js/components/.eslintrc.yaml @@ -10,7 +10,5 @@ env: rules: vue/attributes-order: [0] - vue/component-definition-name-casing: [0] vue/html-closing-bracket-spacing: [0] vue/max-attributes-per-line: [0] - vue/one-component-per-file: [0] From 6a3a54cf484bf5137e2af5bc93294b783feb23a4 Mon Sep 17 00:00:00 2001 From: silverwind Date: Thu, 18 May 2023 09:27:29 +0200 Subject: [PATCH 09/30] Remove background on user dashboard filter bar (#24779) Was only an issue on arc-green: ### Before Screenshot 2023-05-17 at 23 33 15 ### After Screenshot 2023-05-17 at 23 32 52 Co-authored-by: Giteabot --- templates/user/dashboard/issues.tmpl | 2 +- templates/user/dashboard/milestones.tmpl | 2 +- web_src/css/helpers.css | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/templates/user/dashboard/issues.tmpl b/templates/user/dashboard/issues.tmpl index a0b02887b0..3e225bc9ab 100644 --- a/templates/user/dashboard/issues.tmpl +++ b/templates/user/dashboard/issues.tmpl @@ -4,7 +4,7 @@
-