From 766cb481f71144a150c48b04197a2396f4174baa Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Sun, 2 Jan 2022 17:54:49 +0100 Subject: [PATCH 1/4] Update owners for 2022 (#18155) --- CONTRIBUTING.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b91291127ed85..fad535bb2ac3a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -299,6 +299,11 @@ and lead the development of Gitea. To honor the past owners, here's the history of the owners and the time they served: +* 2022-01-01 ~ 2022-12-31 - https://github.com/go-gitea/gitea/issues/17872 + * [Lunny Xiao](https://gitea.com/lunny) + * [Matti Ranta](https://gitea.com/techknowlogick) + * [Andrew Thornton](https://gitea.com/zeripath) + * 2021-01-01 ~ 2021-12-31 - https://github.com/go-gitea/gitea/issues/13801 * [Lunny Xiao](https://gitea.com/lunny) * [Lauris Bukšis-Haberkorns](https://gitea.com/lafriks) From 948949f42989bbbb701a51cfe9d6bd3cd6b246c8 Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Mon, 3 Jan 2022 03:30:40 +0800 Subject: [PATCH 2/4] chore(lint): use golangci-lint to call revive and misspell checker. (#18145) replace revive and misspell with golangci-lint Signed-off-by: Bo-Yi Wu --- .golangci.yml | 29 +++++++++++++++++++++++++++++ .revive.toml | 27 --------------------------- Makefile | 29 ++--------------------------- 3 files changed, 31 insertions(+), 54 deletions(-) delete mode 100644 .revive.toml diff --git a/.golangci.yml b/.golangci.yml index 9e64d71b594a7..235bb76715bdc 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -16,6 +16,7 @@ linters: - gocritic - bidichk - ineffassign + - revive enable-all: false disable-all: true fast: false @@ -28,6 +29,34 @@ linters-settings: disabled-checks: - ifElseChain - singleCaseSwitch # Every time this occurred in the code, there was no other way. + revive: + ignore-generated-header: false + severity: warning + confidence: 0.8 + errorCode: 1 + warningCode: 1 + rules: + - name: blank-imports + - name: context-as-argument + - name: context-keys-type + - name: dot-imports + - name: error-return + - name: error-strings + - name: error-naming + - name: exported + - name: if-return + - name: increment-decrement + - name: var-naming + - name: var-declaration + - name: package-comments + - name: range + - name: receiver-naming + - name: time-naming + - name: unexported-return + - name: indent-error-flow + - name: errorf + - name: duplicated-imports + - name: modifies-value-receiver issues: exclude-rules: diff --git a/.revive.toml b/.revive.toml deleted file mode 100644 index 54f075f84f512..0000000000000 --- a/.revive.toml +++ /dev/null @@ -1,27 +0,0 @@ -ignoreGeneratedHeader = false -severity = "warning" -confidence = 0.8 -errorCode = 1 -warningCode = 1 - -[rule.blank-imports] -[rule.context-as-argument] -[rule.context-keys-type] -[rule.dot-imports] -[rule.error-return] -[rule.error-strings] -[rule.error-naming] -[rule.exported] -[rule.if-return] -[rule.increment-decrement] -[rule.var-naming] -[rule.var-declaration] -[rule.package-comments] -[rule.range] -[rule.receiver-naming] -[rule.time-naming] -[rule.unexported-return] -[rule.indent-error-flow] -[rule.errorf] -[rule.duplicated-imports] -[rule.modifies-value-receiver] diff --git a/Makefile b/Makefile index 4800bb480696c..00318b4afde47 100644 --- a/Makefile +++ b/Makefile @@ -186,8 +186,6 @@ help: @echo " - generate-swagger generate the swagger spec from code comments" @echo " - swagger-validate check if the swagger spec is valid" @echo " - golangci-lint run golangci-lint linter" - @echo " - revive run revive linter" - @echo " - misspell check for misspellings" @echo " - vet examines Go source code and reports suspicious constructs" @echo " - test[\#TestSpecificName] run unit test" @echo " - test-sqlite[\#TestSpecificName] run integration test for sqlite" @@ -280,29 +278,6 @@ errcheck: @echo "Running errcheck..." @errcheck $(GO_PACKAGES) -.PHONY: revive -revive: - @hash revive > /dev/null 2>&1; if [ $$? -ne 0 ]; then \ - $(GO) install github.com/mgechev/revive@v1.1.2; \ - fi - @revive -config .revive.toml -exclude=./vendor/... ./... - -.PHONY: misspell-check -misspell-check: - @hash misspell > /dev/null 2>&1; if [ $$? -ne 0 ]; then \ - $(GO) install github.com/client9/misspell/cmd/misspell@v0.3.4; \ - fi - @echo "Running misspell-check..." - @$(GO) run build/code-batch-process.go misspell -error -i unknwon '{file-list}' - -.PHONY: misspell -misspell: - @hash misspell > /dev/null 2>&1; if [ $$? -ne 0 ]; then \ - $(GO) install github.com/client9/misspell/cmd/misspell@v0.3.4; \ - fi - @echo "Running go misspell..." - @$(GO) run build/code-batch-process.go misspell -w -i unknwon '{file-list}' - .PHONY: fmt-check fmt-check: # get all go files and run go fmt on them @@ -320,7 +295,7 @@ checks: checks-frontend checks-backend checks-frontend: svg-check .PHONY: checks-backend -checks-backend: misspell-check test-vendor swagger-check swagger-validate +checks-backend: test-vendor swagger-check swagger-validate .PHONY: lint lint: lint-frontend lint-backend @@ -332,7 +307,7 @@ lint-frontend: node_modules npx editorconfig-checker templates .PHONY: lint-backend -lint-backend: golangci-lint revive vet +lint-backend: golangci-lint vet .PHONY: watch watch: From 496acbe9e5fb02b6c9ad1a85c328220d4db51a6b Mon Sep 17 00:00:00 2001 From: Gusted Date: Sun, 2 Jan 2022 22:31:03 +0000 Subject: [PATCH 3/4] Require codereview to have content (#18156) - Report a validityError when the codeReview have no comment. - Resolves #18151 - Refactor --- web_src/js/features/comp/CommentEasyMDE.js | 28 ++++++++++++++++++++++ web_src/js/features/repo-diff.js | 7 ++++++ web_src/js/features/repo-wiki.js | 16 +++---------- 3 files changed, 38 insertions(+), 13 deletions(-) diff --git a/web_src/js/features/comp/CommentEasyMDE.js b/web_src/js/features/comp/CommentEasyMDE.js index 47e80e69c1cf1..8efbe4d34de91 100644 --- a/web_src/js/features/comp/CommentEasyMDE.js +++ b/web_src/js/features/comp/CommentEasyMDE.js @@ -96,3 +96,31 @@ export function getAttachedEasyMDE(el) { } return el._data_easyMDE; } + +/** + * validate if the given textarea from a form, is non-empty. + * @param {jQuery | HTMLElement} form + * @param {jQuery | HTMLElement} textarea + * @returns {boolean} returns true if validation succeeded. + */ +export function validateTextareaNonEmpty(form, textarea) { + if (form instanceof jQuery) { + form = form[0]; + } + if (textarea instanceof jQuery) { + textarea = textarea[0]; + } + + const $markdownEditorTextArea = $(getAttachedEasyMDE(textarea).codemirror.getInputField()); + // The original edit area HTML element is hidden and replaced by the + // SimpleMDE/EasyMDE editor, breaking HTML5 input validation if the text area is empty. + // This is a workaround for this upstream bug. + // See https://github.com/sparksuite/simplemde-markdown-editor/issues/324 + if (textarea.value.length) { + $markdownEditorTextArea.prop('required', true); + form.reportValidity(); + return false; + } + $markdownEditorTextArea.prop('required', false); + return true; +} diff --git a/web_src/js/features/repo-diff.js b/web_src/js/features/repo-diff.js index f8f6c38b765af..d2502315b44ba 100644 --- a/web_src/js/features/repo-diff.js +++ b/web_src/js/features/repo-diff.js @@ -1,5 +1,6 @@ import {initCompReactionSelector} from './comp/ReactionSelector.js'; import {initRepoIssueContentHistory} from './repo-issue-content.js'; +import {validateTextareaNonEmpty} from './comp/CommentEasyMDE.js'; const {csrfToken} = window.config; export function initRepoDiffReviewButton() { @@ -23,7 +24,13 @@ export function initRepoDiffFileViewToggle() { export function initRepoDiffConversationForm() { $(document).on('submit', '.conversation-holder form', async (e) => { e.preventDefault(); + const form = $(e.target); + const $textArea = form.find('textarea'); + if (!validateTextareaNonEmpty(form, $textArea)) { + return; + } + const newConversationHolder = $(await $.post(form.attr('action'), form.serialize())); const {path, side, idx} = newConversationHolder.data(); diff --git a/web_src/js/features/repo-wiki.js b/web_src/js/features/repo-wiki.js index ee23dda8c473b..c7b902d31df4f 100644 --- a/web_src/js/features/repo-wiki.js +++ b/web_src/js/features/repo-wiki.js @@ -1,4 +1,5 @@ import {initMarkupContent} from '../markup/content.js'; +import {validateTextareaNonEmpty} from './comp/CommentEasyMDE.js'; import {initCompMarkupContentPreviewTab} from './comp/MarkupContentPreview.js'; const {csrfToken} = window.config; @@ -121,19 +122,8 @@ export function initRepoWikiForm() { const $markdownEditorTextArea = $(easyMDE.codemirror.getInputField()); $markdownEditorTextArea.addClass('js-quick-submit'); - $form.on('submit', function (e) { - // The original edit area HTML element is hidden and replaced by the - // SimpleMDE/EasyMDE editor, breaking HTML5 input validation if the text area is empty. - // This is a workaround for this upstream bug. - // See https://github.com/sparksuite/simplemde-markdown-editor/issues/324 - const input = $editArea.val(); - if (!input.length) { - e.preventDefault(); - $markdownEditorTextArea.prop('required', true); - this.reportValidity(); - } else { - $markdownEditorTextArea.prop('required', false); - } + $form.on('submit', function () { + validateTextareaNonEmpty(this, $editArea); }); setTimeout(() => { From f499f23039a46a7b0b48ca848ead242fe430da29 Mon Sep 17 00:00:00 2001 From: GiteaBot Date: Mon, 3 Jan 2022 00:28:34 +0000 Subject: [PATCH 4/4] [skip ci] Updated translations via Crowdin --- options/locale/locale_zh-CN.ini | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index ff25560f90531..a35263d48c806 100644 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -104,7 +104,12 @@ error404=您正尝试访问的页面 不存在您 never=从不 [error] +occurred=发生了一个错误 +report_message=如果您确定这是一个 Gitea bug,请在 GitHub 上搜索问题,或在必要时打开一个新问题。 missing_csrf=错误的请求:没有 CSRF 令牌 +invalid_csrf=错误的请求:无效的 CSRF 令牌 +not_found=找不到目标。 +network_error=网络错误 [startpage] app_desc=一款极易搭建的自助 Git 服务