From 8cd10f7f3b76c070ca1aadccd470e732fb833a2f Mon Sep 17 00:00:00 2001 From: silverwind Date: Mon, 27 Jan 2025 22:57:14 +0100 Subject: [PATCH 1/4] Updates for poetry 2.0 (#33415) - Remove removed [`no-setuptools`](https://github.com/python-poetry/poetry/pull/9331) option, it's the default now - Ran `make update-py` under poetry 2.0.1 which updated the lockfile Also see https://github.com/python-poetry/poetry/releases/tag/2.0.0 --- poetry.lock | 21 +++++++++++++++++++-- poetry.toml | 1 - 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/poetry.lock b/poetry.lock index 8c01674966d..ab5bcf05aca 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.8.5 and should not be changed by hand. +# This file is automatically @generated by Poetry 2.0.1 and should not be changed by hand. [[package]] name = "click" @@ -6,6 +6,7 @@ version = "8.1.8" description = "Composable command line interface toolkit" optional = false python-versions = ">=3.7" +groups = ["dev"] files = [ {file = "click-8.1.8-py3-none-any.whl", hash = "sha256:63c132bbbed01578a06712a2d1f497bb62d9c1c0d329b7903a866228027263b2"}, {file = "click-8.1.8.tar.gz", hash = "sha256:ed53c9d8990d83c2a27deae68e4ee337473f6330c040a31d4225c9574d16096a"}, @@ -20,6 +21,7 @@ version = "0.4.6" description = "Cross-platform colored terminal text." optional = false python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" +groups = ["dev"] files = [ {file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"}, {file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"}, @@ -31,6 +33,7 @@ version = "1.15.1" description = "CSS unobfuscator and beautifier." optional = false python-versions = "*" +groups = ["dev"] files = [ {file = "cssbeautifier-1.15.1.tar.gz", hash = "sha256:9f7064362aedd559c55eeecf6b6bed65e05f33488dcbe39044f0403c26e1c006"}, ] @@ -46,6 +49,7 @@ version = "1.36.4" description = "HTML Template Linter and Formatter" optional = false python-versions = ">=3.9" +groups = ["dev"] files = [ {file = "djlint-1.36.4-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:a2dfb60883ceb92465201bfd392291a7597c6752baede6fbb6f1980cac8d6c5c"}, {file = "djlint-1.36.4-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:4bc6a1320c0030244b530ac200642f883d3daa451a115920ef3d56d08b644292"}, @@ -90,6 +94,7 @@ version = "0.17.0" description = "EditorConfig File Locator and Interpreter for Python" optional = false python-versions = "*" +groups = ["dev"] files = [ {file = "EditorConfig-0.17.0-py3-none-any.whl", hash = "sha256:fe491719c5f65959ec00b167d07740e7ffec9a3f362038c72b289330b9991dfc"}, {file = "editorconfig-0.17.0.tar.gz", hash = "sha256:8739052279699840065d3a9f5c125d7d5a98daeefe53b0e5274261d77cb49aa2"}, @@ -101,6 +106,7 @@ version = "1.15.1" description = "JavaScript unobfuscator and beautifier." optional = false python-versions = "*" +groups = ["dev"] files = [ {file = "jsbeautifier-1.15.1.tar.gz", hash = "sha256:ebd733b560704c602d744eafc839db60a1ee9326e30a2a80c4adb8718adc1b24"}, ] @@ -115,6 +121,7 @@ version = "0.10.0" description = "A Python implementation of the JSON5 data format." optional = false python-versions = ">=3.8.0" +groups = ["dev"] files = [ {file = "json5-0.10.0-py3-none-any.whl", hash = "sha256:19b23410220a7271e8377f81ba8aacba2fdd56947fbb137ee5977cbe1f5e8dfa"}, {file = "json5-0.10.0.tar.gz", hash = "sha256:e66941c8f0a02026943c52c2eb34ebeb2a6f819a0be05920a6f5243cd30fd559"}, @@ -129,6 +136,7 @@ version = "0.12.1" description = "Utility library for gitignore style pattern matching of file paths." optional = false python-versions = ">=3.8" +groups = ["dev"] files = [ {file = "pathspec-0.12.1-py3-none-any.whl", hash = "sha256:a0d503e138a4c123b27490a4f7beda6a01c6f288df0e4a8b79c7eb0dc7b4cc08"}, {file = "pathspec-0.12.1.tar.gz", hash = "sha256:a482d51503a1ab33b1c67a6c3813a26953dbdc71c31dacaef9a838c4e29f5712"}, @@ -140,6 +148,7 @@ version = "6.0.2" description = "YAML parser and emitter for Python" optional = false python-versions = ">=3.8" +groups = ["dev"] files = [ {file = "PyYAML-6.0.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:0a9a2848a5b7feac301353437eb7d5957887edbf81d56e903999a75a3d743086"}, {file = "PyYAML-6.0.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:29717114e51c84ddfba879543fb232a6ed60086602313ca38cce623c1d62cfbf"}, @@ -202,6 +211,7 @@ version = "2024.11.6" description = "Alternative regular expression module, to replace re." optional = false python-versions = ">=3.8" +groups = ["dev"] files = [ {file = "regex-2024.11.6-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:ff590880083d60acc0433f9c3f713c51f7ac6ebb9adf889c79a261ecf541aa91"}, {file = "regex-2024.11.6-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:658f90550f38270639e83ce492f27d2c8d2cd63805c65a13a14d36ca126753f0"}, @@ -305,6 +315,7 @@ version = "1.17.0" description = "Python 2 and 3 compatibility utilities" optional = false python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,>=2.7" +groups = ["dev"] files = [ {file = "six-1.17.0-py2.py3-none-any.whl", hash = "sha256:4721f391ed90541fddacab5acf947aa0d3dc7d27b2e1e8eda2be8970586c3274"}, {file = "six-1.17.0.tar.gz", hash = "sha256:ff70335d468e7eb6ec65b95b99d3a2836546063f63acc5171de367e834932a81"}, @@ -316,6 +327,8 @@ version = "2.2.1" description = "A lil' TOML parser" optional = false python-versions = ">=3.8" +groups = ["dev"] +markers = "python_version < \"3.11\"" files = [ {file = "tomli-2.2.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:678e4fa69e4575eb77d103de3df8a895e1591b48e740211bd1067378c69e8249"}, {file = "tomli-2.2.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:023aa114dd824ade0100497eb2318602af309e5a55595f76b626d6d9f3b7b0a6"}, @@ -357,6 +370,7 @@ version = "4.67.1" description = "Fast, Extensible Progress Meter" optional = false python-versions = ">=3.7" +groups = ["dev"] files = [ {file = "tqdm-4.67.1-py3-none-any.whl", hash = "sha256:26445eca388f82e72884e0d580d5464cd801a3ea01e63e5601bdff9ba6a48de2"}, {file = "tqdm-4.67.1.tar.gz", hash = "sha256:f8aef9c52c08c13a65f30ea34f4e5aac3fd1a34959879d7e59e63027286627f2"}, @@ -378,6 +392,8 @@ version = "4.12.2" description = "Backported and Experimental Type Hints for Python 3.8+" optional = false python-versions = ">=3.8" +groups = ["dev"] +markers = "python_version < \"3.11\"" files = [ {file = "typing_extensions-4.12.2-py3-none-any.whl", hash = "sha256:04e5ca0351e0f3f85c6853954072df659d0d13fac324d0072316b67d7794700d"}, {file = "typing_extensions-4.12.2.tar.gz", hash = "sha256:1a7ead55c7e559dd4dee8856e3a88b41225abfe1ce8df57b7c13915fe121ffb8"}, @@ -389,6 +405,7 @@ version = "1.35.1" description = "A linter for YAML files." optional = false python-versions = ">=3.8" +groups = ["dev"] files = [ {file = "yamllint-1.35.1-py3-none-any.whl", hash = "sha256:2e16e504bb129ff515b37823b472750b36b6de07963bd74b307341ef5ad8bdc3"}, {file = "yamllint-1.35.1.tar.gz", hash = "sha256:7a003809f88324fd2c877734f2d575ee7881dd9043360657cc8049c809eba6cd"}, @@ -402,6 +419,6 @@ pyyaml = "*" dev = ["doc8", "flake8", "flake8-import-order", "rstcheck[sphinx]", "sphinx"] [metadata] -lock-version = "2.0" +lock-version = "2.1" python-versions = "^3.10" content-hash = "f2e8260efe6e25f77ef387daff9551e41d25027e4794b42bc7a851ed0dfafd85" diff --git a/poetry.toml b/poetry.toml index 0299355b5dd..6eda9f8effc 100644 --- a/poetry.toml +++ b/poetry.toml @@ -1,4 +1,3 @@ [virtualenvs] in-project = true options.no-pip = true -options.no-setuptools = true From 121e4c962417c7f0a355552ed2414f3c2dd209f3 Mon Sep 17 00:00:00 2001 From: GiteaBot Date: Tue, 28 Jan 2025 00:31:19 +0000 Subject: [PATCH 2/4] [skip ci] Updated translations via Crowdin --- options/locale/locale_ga-IE.ini | 2 +- options/locale/locale_pt-BR.ini | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/options/locale/locale_ga-IE.ini b/options/locale/locale_ga-IE.ini index a7309ee6483..805deb618db 100644 --- a/options/locale/locale_ga-IE.ini +++ b/options/locale/locale_ga-IE.ini @@ -1646,7 +1646,7 @@ issues.label.filter_sort.by_size=Méid is lú issues.label.filter_sort.reverse_by_size=Méid is mó issues.num_participants=%d Rannpháirtithe issues.attachment.open_tab=`Cliceáil chun "%s" a fheiceáil i gcluaisín nua` -issues.attachment.download=Cliceáil chun "%s" a íoslódáil +issues.attachment.download=`Cliceáil chun "%s" a íoslódáil` issues.subscribe=Liostáil issues.unsubscribe=Díliostáil issues.unpin=Díphoráil diff --git a/options/locale/locale_pt-BR.ini b/options/locale/locale_pt-BR.ini index d3ccc711b22..cc21c5abea0 100644 --- a/options/locale/locale_pt-BR.ini +++ b/options/locale/locale_pt-BR.ini @@ -1135,9 +1135,9 @@ file_view_raw=Ver original file_permalink=Link permanente file_too_large=O arquivo é muito grande para ser mostrado. invisible_runes_header=`Este arquivo contém caracteres Unicode invisíveis` -invisible_runes_description=Este arquivo contém caracteres Unicode invisíveis que são indistinguíveis para humanos, mas que podem ser processados de forma diferente por um computador. Se você acha que isso é intencional, pode ignorar esse aviso com segurança. Use o botão Escapar para revelá-los +invisible_runes_description=`Este arquivo contém caracteres Unicode invisíveis que são indistinguíveis para humanos, mas que podem ser processados de forma diferente por um computador. Se você acha que isso é intencional, pode ignorar esse aviso com segurança. Use o botão Escapar para revelá-los` ambiguous_runes_header=`Este arquivo contém caracteres Unicode ambíguos` -ambiguous_runes_description=Este arquivo contém caracteres Unicode que podem ser confundidos com outros caracteres. Se você acha que isso é intencional, pode ignorar esse aviso com segurança. Use o botão Escapar para revelá-los +ambiguous_runes_description=`Este arquivo contém caracteres Unicode que podem ser confundidos com outros caracteres. Se você acha que isso é intencional, pode ignorar esse aviso com segurança. Use o botão Escapar para revelá-los` invisible_runes_line=`Esta linha tem caracteres unicode invisíveis` ambiguous_runes_line=`Esta linha tem caracteres unicode ambíguos` From 8f433132e1a08ebb85e216db7d788ab795baadf5 Mon Sep 17 00:00:00 2001 From: silverwind Date: Tue, 28 Jan 2025 03:34:01 +0100 Subject: [PATCH 3/4] Update stylelint config (#33419) - Inherit stylelint config from [`stylelint-config-recommended`](https://github.com/stylelint/stylelint-config-recommended), removed all stylelint core rule options that were either already in their config or disabled. - `no-descending-specificity` diverges from their config, seems to much work currently. - Tweaked a few rules. - Added [`stylelint-define-config`](https://github.com/stylelint-types/stylelint-define-config) so that typescript can validate the config. --- package-lock.json | 55 +++++++++++++++++--- package.json | 4 +- stylelint.config.js | 120 ++++---------------------------------------- 3 files changed, 63 insertions(+), 116 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2c4f79926d0..e7dead18713 100644 --- a/package-lock.json +++ b/package-lock.json @@ -103,9 +103,11 @@ "markdownlint-cli": "0.43.0", "nolyfill": "1.0.43", "postcss-html": "1.8.0", - "stylelint": "16.13.2", + "stylelint": "16.14.1", + "stylelint-config-recommended": "15.0.0", "stylelint-declaration-block-no-ignored-properties": "2.8.0", "stylelint-declaration-strict-value": "1.10.7", + "stylelint-define-config": "16.14.0", "stylelint-value-no-unknown-custom-properties": "6.0.1", "svgo": "3.3.2", "type-fest": "4.33.0", @@ -13143,9 +13145,9 @@ "license": "ISC" }, "node_modules/stylelint": { - "version": "16.13.2", - "resolved": "https://registry.npmjs.org/stylelint/-/stylelint-16.13.2.tgz", - "integrity": "sha512-wDlgh0mRO9RtSa3TdidqHd0nOG8MmUyVKl+dxA6C1j8aZRzpNeEgdhFmU5y4sZx4Fc6r46p0fI7p1vR5O2DZqA==", + "version": "16.14.1", + "resolved": "https://registry.npmjs.org/stylelint/-/stylelint-16.14.1.tgz", + "integrity": "sha512-oqCL7AC3786oTax35T/nuLL8p2C3k/8rHKAooezrPGRvUX0wX+qqs5kMWh5YYT4PHQgVDobHT4tw55WgpYG6Sw==", "dev": true, "funding": [ { @@ -13177,7 +13179,7 @@ "globby": "^11.1.0", "globjoin": "^0.1.4", "html-tags": "^3.3.1", - "ignore": "^7.0.1", + "ignore": "^7.0.3", "imurmurhash": "^0.1.4", "is-plain-object": "^5.0.0", "known-css-properties": "^0.35.0", @@ -13186,7 +13188,7 @@ "micromatch": "^4.0.8", "normalize-path": "^3.0.0", "picocolors": "^1.1.1", - "postcss": "^8.4.49", + "postcss": "^8.5.1", "postcss-resolve-nested-selector": "^0.1.6", "postcss-safe-parser": "^7.0.1", "postcss-selector-parser": "^7.0.0", @@ -13205,6 +13207,29 @@ "node": ">=18.12.0" } }, + "node_modules/stylelint-config-recommended": { + "version": "15.0.0", + "resolved": "https://registry.npmjs.org/stylelint-config-recommended/-/stylelint-config-recommended-15.0.0.tgz", + "integrity": "sha512-9LejMFsat7L+NXttdHdTq94byn25TD+82bzGRiV1Pgasl99pWnwipXS5DguTpp3nP1XjvLXVnEJIuYBfsRjRkA==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/stylelint" + }, + { + "type": "github", + "url": "https://github.com/sponsors/stylelint" + } + ], + "license": "MIT", + "engines": { + "node": ">=18.12.0" + }, + "peerDependencies": { + "stylelint": "^16.13.0" + } + }, "node_modules/stylelint-declaration-block-no-ignored-properties": { "version": "2.8.0", "resolved": "https://registry.npmjs.org/stylelint-declaration-block-no-ignored-properties/-/stylelint-declaration-block-no-ignored-properties-2.8.0.tgz", @@ -13231,6 +13256,24 @@ "stylelint": ">=7 <=16" } }, + "node_modules/stylelint-define-config": { + "version": "16.14.0", + "resolved": "https://registry.npmjs.org/stylelint-define-config/-/stylelint-define-config-16.14.0.tgz", + "integrity": "sha512-5R7/Vv6awCkNaPcedo1GuUp+7YTFvDnexogO4l/C0i349pBDYbefN6XzsDGsGOhU++maQSh2fp3mWNO0F16IjA==", + "dev": true, + "license": "MIT", + "dependencies": { + "csstype": "^3.1.3" + }, + "engines": { + "node": ">=18.0.0", + "npm": ">=9.0.0", + "pnpm": ">=8.6.0" + }, + "peerDependencies": { + "stylelint": ">=16.0.0" + } + }, "node_modules/stylelint-value-no-unknown-custom-properties": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/stylelint-value-no-unknown-custom-properties/-/stylelint-value-no-unknown-custom-properties-6.0.1.tgz", diff --git a/package.json b/package.json index 97f73b79732..2ee785da72b 100644 --- a/package.json +++ b/package.json @@ -102,9 +102,11 @@ "markdownlint-cli": "0.43.0", "nolyfill": "1.0.43", "postcss-html": "1.8.0", - "stylelint": "16.13.2", + "stylelint": "16.14.1", + "stylelint-config-recommended": "15.0.0", "stylelint-declaration-block-no-ignored-properties": "2.8.0", "stylelint-declaration-strict-value": "1.10.7", + "stylelint-define-config": "16.14.0", "stylelint-value-no-unknown-custom-properties": "6.0.1", "svgo": "3.3.2", "type-fest": "4.33.0", diff --git a/stylelint.config.js b/stylelint.config.js index 977c35d9d5d..1153bf7308b 100644 --- a/stylelint.config.js +++ b/stylelint.config.js @@ -1,3 +1,5 @@ +// @ts-check +import {defineConfig} from 'stylelint-define-config'; import {fileURLToPath} from 'node:url'; const cssVarFiles = [ @@ -6,8 +8,8 @@ const cssVarFiles = [ fileURLToPath(new URL('web_src/css/themes/theme-gitea-dark.css', import.meta.url)), ]; -/** @type {import('stylelint').Config} */ -export default { +export default defineConfig({ + extends: 'stylelint-config-recommended', plugins: [ 'stylelint-declaration-strict-value', 'stylelint-declaration-block-no-ignored-properties', @@ -67,7 +69,7 @@ export default { '@stylistic/function-comma-space-after': null, '@stylistic/function-comma-space-before': null, '@stylistic/function-max-empty-lines': 0, - '@stylistic/function-parentheses-newline-inside': 'never-multi-line', + '@stylistic/function-parentheses-newline-inside': null, '@stylistic/function-parentheses-space-inside': null, '@stylistic/function-whitespace-after': null, '@stylistic/indentation': 2, @@ -114,134 +116,34 @@ export default { '@stylistic/value-list-comma-space-after': null, '@stylistic/value-list-comma-space-before': null, '@stylistic/value-list-max-empty-lines': 0, - 'alpha-value-notation': null, - 'annotation-no-unknown': true, - 'at-rule-allowed-list': null, - 'at-rule-disallowed-list': null, - 'at-rule-empty-line-before': null, 'at-rule-no-unknown': [true, {ignoreAtRules: ['tailwind']}], 'at-rule-no-vendor-prefix': true, - 'at-rule-property-required-list': null, - 'block-no-empty': true, - 'color-function-notation': null, - 'color-hex-alpha': null, - 'color-hex-length': null, - 'color-named': null, - 'color-no-hex': null, - 'color-no-invalid-hex': true, - 'comment-empty-line-before': null, - 'comment-no-empty': true, - 'comment-pattern': null, - 'comment-whitespace-inside': null, - 'comment-word-disallowed-list': null, 'csstools/value-no-unknown-custom-properties': [true, {importFrom: cssVarFiles}], - 'custom-media-pattern': null, - 'custom-property-empty-line-before': null, - 'custom-property-no-missing-var-function': true, - 'custom-property-pattern': null, - 'declaration-block-no-duplicate-custom-properties': true, 'declaration-block-no-duplicate-properties': [true, {ignore: ['consecutive-duplicates-with-different-values']}], - 'declaration-block-no-redundant-longhand-properties': [true, {ignoreShorthands: ['flex-flow', 'overflow']}], - 'declaration-block-no-shorthand-property-overrides': null, - 'declaration-block-single-line-max-declarations': null, - 'declaration-empty-line-before': null, - 'declaration-no-important': null, - 'declaration-property-max-values': null, - 'declaration-property-unit-allowed-list': null, + 'declaration-block-no-redundant-longhand-properties': [true, {ignoreShorthands: ['flex-flow', 'overflow', 'grid-template']}], + // @ts-expect-error - https://github.com/stylelint-types/stylelint-define-config/issues/1 'declaration-property-unit-disallowed-list': {'line-height': ['em']}, - 'declaration-property-value-allowed-list': null, + // @ts-expect-error - https://github.com/stylelint-types/stylelint-define-config/issues/1 'declaration-property-value-disallowed-list': {'word-break': ['break-word']}, - 'declaration-property-value-no-unknown': true, 'font-family-name-quotes': 'always-where-recommended', - 'font-family-no-duplicate-names': true, - 'font-family-no-missing-generic-family-keyword': true, - 'font-weight-notation': null, - 'function-allowed-list': null, - 'function-calc-no-unspaced-operator': true, - 'function-disallowed-list': null, - 'function-linear-gradient-no-nonstandard-direction': true, 'function-name-case': 'lower', - 'function-no-unknown': true, - 'function-url-no-scheme-relative': null, 'function-url-quotes': 'always', - 'function-url-scheme-allowed-list': null, - 'function-url-scheme-disallowed-list': null, - 'hue-degree-notation': null, 'import-notation': 'string', - 'keyframe-block-no-duplicate-selectors': true, - 'keyframe-declaration-no-important': true, - 'keyframe-selector-notation': null, - 'keyframes-name-pattern': null, - 'length-zero-no-unit': [true, {ignore: ['custom-properties']}, {ignoreFunctions: ['var']}], - 'max-nesting-depth': null, - 'media-feature-name-allowed-list': null, - 'media-feature-name-disallowed-list': null, - 'media-feature-name-no-unknown': true, + 'length-zero-no-unit': [true, {ignore: ['custom-properties'], ignoreFunctions: ['var']}], 'media-feature-name-no-vendor-prefix': true, - 'media-feature-name-unit-allowed-list': null, - 'media-feature-name-value-allowed-list': null, - 'media-feature-name-value-no-unknown': true, - 'media-feature-range-notation': null, - 'media-query-no-invalid': true, - 'named-grid-areas-no-invalid': true, 'no-descending-specificity': null, - 'no-duplicate-at-import-rules': true, - 'no-duplicate-selectors': true, - 'no-empty-source': true, - 'no-invalid-double-slash-comments': true, 'no-invalid-position-at-import-rule': [true, {ignoreAtRules: ['tailwind']}], - 'no-irregular-whitespace': true, 'no-unknown-animations': null, // disabled until stylelint supports multi-file linting 'no-unknown-custom-media': null, // disabled until stylelint supports multi-file linting 'no-unknown-custom-properties': null, // disabled until stylelint supports multi-file linting - 'number-max-precision': null, 'plugin/declaration-block-no-ignored-properties': true, - 'property-allowed-list': null, - 'property-disallowed-list': null, - 'property-no-unknown': true, - 'property-no-vendor-prefix': null, - 'rule-empty-line-before': null, - 'rule-selector-property-disallowed-list': null, - 'scale-unlimited/declaration-strict-value': [['/color$/', 'font-weight'], {ignoreValues: '/^(inherit|transparent|unset|initial|currentcolor|none)$/', ignoreFunctions: false, disableFix: true, expandShorthand: true}], - 'selector-anb-no-unmatchable': true, - 'selector-attribute-name-disallowed-list': null, - 'selector-attribute-operator-allowed-list': null, - 'selector-attribute-operator-disallowed-list': null, + 'scale-unlimited/declaration-strict-value': [['/color$/', 'font-weight'], {ignoreValues: '/^(inherit|transparent|unset|initial|currentcolor|none)$/', ignoreFunctions: true, disableFix: true, expandShorthand: true}], 'selector-attribute-quotes': 'always', - 'selector-class-pattern': null, - 'selector-combinator-allowed-list': null, - 'selector-combinator-disallowed-list': null, - 'selector-disallowed-list': null, - 'selector-id-pattern': null, - 'selector-max-attribute': null, - 'selector-max-class': null, - 'selector-max-combinators': null, - 'selector-max-compound-selectors': null, - 'selector-max-id': null, - 'selector-max-pseudo-class': null, - 'selector-max-specificity': null, - 'selector-max-type': null, - 'selector-max-universal': null, - 'selector-nested-pattern': null, - 'selector-no-qualifying-type': null, 'selector-no-vendor-prefix': true, - 'selector-not-notation': null, - 'selector-pseudo-class-allowed-list': null, - 'selector-pseudo-class-disallowed-list': null, - 'selector-pseudo-class-no-unknown': true, - 'selector-pseudo-element-allowed-list': null, 'selector-pseudo-element-colon-notation': 'double', - 'selector-pseudo-element-disallowed-list': null, - 'selector-pseudo-element-no-unknown': true, 'selector-type-case': 'lower', 'selector-type-no-unknown': [true, {ignore: ['custom-elements']}], 'shorthand-property-no-redundant-values': true, - 'string-no-newline': true, - 'time-min-milliseconds': null, - 'unit-allowed-list': null, - 'unit-disallowed-list': null, - 'unit-no-unknown': true, - 'value-keyword-case': null, 'value-no-vendor-prefix': [true, {ignoreValues: ['box', 'inline-box']}], }, -}; +}); From a9577e0808d8432f58a24901eb87ffc88bdc4182 Mon Sep 17 00:00:00 2001 From: Zettat123 Date: Tue, 28 Jan 2025 10:59:15 +0800 Subject: [PATCH 4/4] Fix `GetCommitBranchStart` bug (#33298) Fix #33265 Fix #33370 This PR also fixes some bugs in `TestGitGeneral`. --- modules/git/commit_test.go | 2 +- modules/git/repo_commit.go | 8 ++-- tests/integration/git_general_test.go | 69 +++++++++++++++++---------- 3 files changed, 49 insertions(+), 30 deletions(-) diff --git a/modules/git/commit_test.go b/modules/git/commit_test.go index 9560c2cd946..9a87dd32d99 100644 --- a/modules/git/commit_test.go +++ b/modules/git/commit_test.go @@ -357,5 +357,5 @@ func Test_GetCommitBranchStart(t *testing.T) { startCommitID, err := repo.GetCommitBranchStart(os.Environ(), "branch1", commit.ID.String()) assert.NoError(t, err) assert.NotEmpty(t, startCommitID) - assert.EqualValues(t, "9c9aef8dd84e02bc7ec12641deb4c930a7c30185", startCommitID) + assert.EqualValues(t, "95bb4d39648ee7e325106df01a621c530863a653", startCommitID) } diff --git a/modules/git/repo_commit.go b/modules/git/repo_commit.go index 647894bb213..02d8e163e4f 100644 --- a/modules/git/repo_commit.go +++ b/modules/git/repo_commit.go @@ -519,6 +519,7 @@ func (repo *Repository) AddLastCommitCache(cacheKey, fullName, sha string) error return nil } +// GetCommitBranchStart returns the commit where the branch diverged func (repo *Repository) GetCommitBranchStart(env []string, branch, endCommitID string) (string, error) { cmd := NewCommand(repo.Ctx, "log", prettyLogFormat) cmd.AddDynamicArguments(endCommitID) @@ -533,7 +534,8 @@ func (repo *Repository) GetCommitBranchStart(env []string, branch, endCommitID s parts := bytes.Split(bytes.TrimSpace(stdout), []byte{'\n'}) - var startCommitID string + // check the commits one by one until we find a commit contained by another branch + // and we think this commit is the divergence point for _, commitID := range parts { branches, err := repo.getBranches(env, string(commitID), 2) if err != nil { @@ -541,11 +543,9 @@ func (repo *Repository) GetCommitBranchStart(env []string, branch, endCommitID s } for _, b := range branches { if b != branch { - return startCommitID, nil + return string(commitID), nil } } - - startCommitID = string(commitID) } return "", nil diff --git a/tests/integration/git_general_test.go b/tests/integration/git_general_test.go index 6dd29a438a7..ab2a948fde5 100644 --- a/tests/integration/git_general_test.go +++ b/tests/integration/git_general_test.go @@ -80,6 +80,7 @@ func testGitGeneral(t *testing.T, u *url.URL) { mediaTest(t, &httpContext, pushedFilesStandard[0], pushedFilesStandard[1], pushedFilesLFS[0], pushedFilesLFS[1]) t.Run("CreateAgitFlowPull", doCreateAgitFlowPull(dstPath, &httpContext, "test/head")) + t.Run("CreateProtectedBranch", doCreateProtectedBranch(&httpContext, dstPath)) t.Run("BranchProtectMerge", doBranchProtectPRMerge(&httpContext, dstPath)) t.Run("AutoMerge", doAutoPRMerge(&httpContext, dstPath)) t.Run("CreatePRAndSetManuallyMerged", doCreatePRAndSetManuallyMerged(httpContext, httpContext, dstPath, "master", "test-manually-merge")) @@ -121,6 +122,7 @@ func testGitGeneral(t *testing.T, u *url.URL) { mediaTest(t, &sshContext, pushedFilesStandard[0], pushedFilesStandard[1], pushedFilesLFS[0], pushedFilesLFS[1]) t.Run("CreateAgitFlowPull", doCreateAgitFlowPull(dstPath, &sshContext, "test/head2")) + t.Run("CreateProtectedBranch", doCreateProtectedBranch(&sshContext, dstPath)) t.Run("BranchProtectMerge", doBranchProtectPRMerge(&sshContext, dstPath)) t.Run("MergeFork", func(t *testing.T) { defer tests.PrintCurrentTest(t)() @@ -325,6 +327,34 @@ func generateCommitWithNewData(size int, repoPath, email, fullName, prefix strin return filepath.Base(tmpFile.Name()), err } +func doCreateProtectedBranch(baseCtx *APITestContext, dstPath string) func(t *testing.T) { + return func(t *testing.T) { + defer tests.PrintCurrentTest(t)() + ctx := NewAPITestContext(t, baseCtx.Username, baseCtx.Reponame, auth_model.AccessTokenScopeWriteRepository) + + t.Run("ProtectBranchWithFilePatterns", doProtectBranch(ctx, "release-*", baseCtx.Username, "", "", "config*")) + + // push a new branch without any new commits + t.Run("CreateProtectedBranch-NoChanges", doGitCreateBranch(dstPath, "release-v1.0")) + t.Run("PushProtectedBranch-NoChanges", doGitPushTestRepository(dstPath, "origin", "release-v1.0")) + t.Run("CheckoutMaster-NoChanges", doGitCheckoutBranch(dstPath, "master")) + + // push a new branch with a new unprotected file + t.Run("CreateProtectedBranch-UnprotectedFile", doGitCreateBranch(dstPath, "release-v2.0")) + _, err := generateCommitWithNewData(testFileSizeSmall, dstPath, "user2@example.com", "User Two", "abc.txt") + assert.NoError(t, err) + t.Run("PushProtectedBranch-UnprotectedFile", doGitPushTestRepository(dstPath, "origin", "release-v2.0")) + t.Run("CheckoutMaster-UnprotectedFile", doGitCheckoutBranch(dstPath, "master")) + + // push a new branch with a new protected file + t.Run("CreateProtectedBranch-ProtectedFile", doGitCreateBranch(dstPath, "release-v3.0")) + _, err = generateCommitWithNewData(testFileSizeSmall, dstPath, "user2@example.com", "User Two", "config") + assert.NoError(t, err) + t.Run("PushProtectedBranch-ProtectedFile", doGitPushTestRepositoryFail(dstPath, "origin", "release-v3.0")) + t.Run("CheckoutMaster-ProtectedFile", doGitCheckoutBranch(dstPath, "master")) + } +} + func doBranchProtectPRMerge(baseCtx *APITestContext, dstPath string) func(t *testing.T) { return func(t *testing.T) { defer tests.PrintCurrentTest(t)() @@ -334,27 +364,23 @@ func doBranchProtectPRMerge(baseCtx *APITestContext, dstPath string) func(t *tes ctx := NewAPITestContext(t, baseCtx.Username, baseCtx.Reponame, auth_model.AccessTokenScopeWriteRepository) // Protect branch without any whitelisting - t.Run("ProtectBranchNoWhitelist", func(t *testing.T) { - doProtectBranch(ctx, "protected", "", "", "") - }) + t.Run("ProtectBranchNoWhitelist", doProtectBranch(ctx, "protected", "", "", "", "")) // Try to push without permissions, which should fail t.Run("TryPushWithoutPermissions", func(t *testing.T) { _, err := generateCommitWithNewData(testFileSizeSmall, dstPath, "user2@example.com", "User Two", "branch-data-file-") assert.NoError(t, err) - doGitPushTestRepositoryFail(dstPath, "origin", "protected") + doGitPushTestRepositoryFail(dstPath, "origin", "protected")(t) }) // Set up permissions for normal push but not force push - t.Run("SetupNormalPushPermissions", func(t *testing.T) { - doProtectBranch(ctx, "protected", baseCtx.Username, "", "") - }) + t.Run("SetupNormalPushPermissions", doProtectBranch(ctx, "protected", baseCtx.Username, "", "", "")) // Normal push should work t.Run("NormalPushWithPermissions", func(t *testing.T) { _, err := generateCommitWithNewData(testFileSizeSmall, dstPath, "user2@example.com", "User Two", "branch-data-file-") assert.NoError(t, err) - doGitPushTestRepository(dstPath, "origin", "protected") + doGitPushTestRepository(dstPath, "origin", "protected")(t) }) // Try to force push without force push permissions, which should fail @@ -364,30 +390,22 @@ func doBranchProtectPRMerge(baseCtx *APITestContext, dstPath string) func(t *tes _, err := generateCommitWithNewData(testFileSizeSmall, dstPath, "user2@example.com", "User Two", "branch-data-file-new") assert.NoError(t, err) }) - doGitPushTestRepositoryFail(dstPath, "-f", "origin", "protected") + doGitPushTestRepositoryFail(dstPath, "-f", "origin", "protected")(t) }) // Set up permissions for force push but not normal push - t.Run("SetupForcePushPermissions", func(t *testing.T) { - doProtectBranch(ctx, "protected", "", baseCtx.Username, "") - }) + t.Run("SetupForcePushPermissions", doProtectBranch(ctx, "protected", "", baseCtx.Username, "", "")) // Try to force push without normal push permissions, which should fail - t.Run("ForcePushWithoutNormalPermissions", func(t *testing.T) { - doGitPushTestRepositoryFail(dstPath, "-f", "origin", "protected") - }) + t.Run("ForcePushWithoutNormalPermissions", doGitPushTestRepositoryFail(dstPath, "-f", "origin", "protected")) // Set up permissions for normal and force push (both are required to force push) - t.Run("SetupNormalAndForcePushPermissions", func(t *testing.T) { - doProtectBranch(ctx, "protected", baseCtx.Username, baseCtx.Username, "") - }) + t.Run("SetupNormalAndForcePushPermissions", doProtectBranch(ctx, "protected", baseCtx.Username, baseCtx.Username, "", "")) // Force push should now work - t.Run("ForcePushWithPermissions", func(t *testing.T) { - doGitPushTestRepository(dstPath, "-f", "origin", "protected") - }) + t.Run("ForcePushWithPermissions", doGitPushTestRepository(dstPath, "-f", "origin", "protected")) - t.Run("ProtectProtectedBranchNoWhitelist", doProtectBranch(ctx, "protected", "", "", "")) + t.Run("ProtectProtectedBranchNoWhitelist", doProtectBranch(ctx, "protected", "", "", "", "")) t.Run("PushToUnprotectedBranch", doGitPushTestRepository(dstPath, "origin", "protected:unprotected")) var pr api.PullRequest var err error @@ -409,14 +427,14 @@ func doBranchProtectPRMerge(baseCtx *APITestContext, dstPath string) func(t *tes t.Run("MergePR", doAPIMergePullRequest(ctx, baseCtx.Username, baseCtx.Reponame, pr.Index)) t.Run("PullProtected", doGitPull(dstPath, "origin", "protected")) - t.Run("ProtectProtectedBranchUnprotectedFilePaths", doProtectBranch(ctx, "protected", "", "", "unprotected-file-*")) + t.Run("ProtectProtectedBranchUnprotectedFilePaths", doProtectBranch(ctx, "protected", "", "", "unprotected-file-*", "")) t.Run("GenerateCommit", func(t *testing.T) { _, err := generateCommitWithNewData(testFileSizeSmall, dstPath, "user2@example.com", "User Two", "unprotected-file-") assert.NoError(t, err) }) t.Run("PushUnprotectedFilesToProtectedBranch", doGitPushTestRepository(dstPath, "origin", "protected")) - t.Run("ProtectProtectedBranchWhitelist", doProtectBranch(ctx, "protected", baseCtx.Username, "", "")) + t.Run("ProtectProtectedBranchWhitelist", doProtectBranch(ctx, "protected", baseCtx.Username, "", "", "")) t.Run("CheckoutMaster", doGitCheckoutBranch(dstPath, "master")) t.Run("CreateBranchForced", doGitCreateBranch(dstPath, "toforce")) @@ -431,7 +449,7 @@ func doBranchProtectPRMerge(baseCtx *APITestContext, dstPath string) func(t *tes } } -func doProtectBranch(ctx APITestContext, branch, userToWhitelistPush, userToWhitelistForcePush, unprotectedFilePatterns string) func(t *testing.T) { +func doProtectBranch(ctx APITestContext, branch, userToWhitelistPush, userToWhitelistForcePush, unprotectedFilePatterns, protectedFilePatterns string) func(t *testing.T) { // We are going to just use the owner to set the protection. return func(t *testing.T) { csrf := GetUserCSRFToken(t, ctx.Session) @@ -440,6 +458,7 @@ func doProtectBranch(ctx APITestContext, branch, userToWhitelistPush, userToWhit "_csrf": csrf, "rule_name": branch, "unprotected_file_patterns": unprotectedFilePatterns, + "protected_file_patterns": protectedFilePatterns, } if userToWhitelistPush != "" {