Skip to content

Commit ce0e4e6

Browse files
authored
Merge branch 'main' into disk-space-calc
2 parents 3603974 + f499f23 commit ce0e4e6

File tree

8 files changed

+79
-67
lines changed

8 files changed

+79
-67
lines changed

.golangci.yml

+29
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ linters:
1616
- gocritic
1717
- bidichk
1818
- ineffassign
19+
- revive
1920
enable-all: false
2021
disable-all: true
2122
fast: false
@@ -28,6 +29,34 @@ linters-settings:
2829
disabled-checks:
2930
- ifElseChain
3031
- singleCaseSwitch # Every time this occurred in the code, there was no other way.
32+
revive:
33+
ignore-generated-header: false
34+
severity: warning
35+
confidence: 0.8
36+
errorCode: 1
37+
warningCode: 1
38+
rules:
39+
- name: blank-imports
40+
- name: context-as-argument
41+
- name: context-keys-type
42+
- name: dot-imports
43+
- name: error-return
44+
- name: error-strings
45+
- name: error-naming
46+
- name: exported
47+
- name: if-return
48+
- name: increment-decrement
49+
- name: var-naming
50+
- name: var-declaration
51+
- name: package-comments
52+
- name: range
53+
- name: receiver-naming
54+
- name: time-naming
55+
- name: unexported-return
56+
- name: indent-error-flow
57+
- name: errorf
58+
- name: duplicated-imports
59+
- name: modifies-value-receiver
3160

3261
issues:
3362
exclude-rules:

.revive.toml

-27
This file was deleted.

CONTRIBUTING.md

+5
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,11 @@ and lead the development of Gitea.
299299
To honor the past owners, here's the history of the owners and the time
300300
they served:
301301

302+
* 2022-01-01 ~ 2022-12-31 - https://github.com/go-gitea/gitea/issues/17872
303+
* [Lunny Xiao](https://gitea.com/lunny) <[email protected]>
304+
* [Matti Ranta](https://gitea.com/techknowlogick) <[email protected]>
305+
* [Andrew Thornton](https://gitea.com/zeripath) <[email protected]>
306+
302307
* 2021-01-01 ~ 2021-12-31 - https://github.com/go-gitea/gitea/issues/13801
303308
* [Lunny Xiao](https://gitea.com/lunny) <[email protected]>
304309
* [Lauris Bukšis-Haberkorns](https://gitea.com/lafriks) <[email protected]>

Makefile

+2-27
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,6 @@ help:
186186
@echo " - generate-swagger generate the swagger spec from code comments"
187187
@echo " - swagger-validate check if the swagger spec is valid"
188188
@echo " - golangci-lint run golangci-lint linter"
189-
@echo " - revive run revive linter"
190-
@echo " - misspell check for misspellings"
191189
@echo " - vet examines Go source code and reports suspicious constructs"
192190
@echo " - test[\#TestSpecificName] run unit test"
193191
@echo " - test-sqlite[\#TestSpecificName] run integration test for sqlite"
@@ -280,29 +278,6 @@ errcheck:
280278
@echo "Running errcheck..."
281279
@errcheck $(GO_PACKAGES)
282280

283-
.PHONY: revive
284-
revive:
285-
@hash revive > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
286-
$(GO) install github.com/mgechev/[email protected]; \
287-
fi
288-
@revive -config .revive.toml -exclude=./vendor/... ./...
289-
290-
.PHONY: misspell-check
291-
misspell-check:
292-
@hash misspell > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
293-
$(GO) install github.com/client9/misspell/cmd/[email protected]; \
294-
fi
295-
@echo "Running misspell-check..."
296-
@$(GO) run build/code-batch-process.go misspell -error -i unknwon '{file-list}'
297-
298-
.PHONY: misspell
299-
misspell:
300-
@hash misspell > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
301-
$(GO) install github.com/client9/misspell/cmd/[email protected]; \
302-
fi
303-
@echo "Running go misspell..."
304-
@$(GO) run build/code-batch-process.go misspell -w -i unknwon '{file-list}'
305-
306281
.PHONY: fmt-check
307282
fmt-check:
308283
# get all go files and run go fmt on them
@@ -320,7 +295,7 @@ checks: checks-frontend checks-backend
320295
checks-frontend: svg-check
321296

322297
.PHONY: checks-backend
323-
checks-backend: misspell-check test-vendor swagger-check swagger-validate
298+
checks-backend: test-vendor swagger-check swagger-validate
324299

325300
.PHONY: lint
326301
lint: lint-frontend lint-backend
@@ -332,7 +307,7 @@ lint-frontend: node_modules
332307
npx editorconfig-checker templates
333308

334309
.PHONY: lint-backend
335-
lint-backend: golangci-lint revive vet
310+
lint-backend: golangci-lint vet
336311

337312
.PHONY: watch
338313
watch:

options/locale/locale_zh-CN.ini

+5
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,12 @@ error404=您正尝试访问的页面 <strong>不存在</strong> 或 <strong>您
104104
never=从不
105105

106106
[error]
107+
occurred=发生了一个错误
108+
report_message=如果您确定这是一个 Gitea bug,请在 <a href="https://github.com/go-gitea/gitea/issues" target="_blank">GitHub</a> 上搜索问题,或在必要时打开一个新问题。
107109
missing_csrf=错误的请求:没有 CSRF 令牌
110+
invalid_csrf=错误的请求:无效的 CSRF 令牌
111+
not_found=找不到目标。
112+
network_error=网络错误
108113

109114
[startpage]
110115
app_desc=一款极易搭建的自助 Git 服务

web_src/js/features/comp/CommentEasyMDE.js

+28
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,31 @@ export function getAttachedEasyMDE(el) {
9696
}
9797
return el._data_easyMDE;
9898
}
99+
100+
/**
101+
* validate if the given textarea from a form, is non-empty.
102+
* @param {jQuery | HTMLElement} form
103+
* @param {jQuery | HTMLElement} textarea
104+
* @returns {boolean} returns true if validation succeeded.
105+
*/
106+
export function validateTextareaNonEmpty(form, textarea) {
107+
if (form instanceof jQuery) {
108+
form = form[0];
109+
}
110+
if (textarea instanceof jQuery) {
111+
textarea = textarea[0];
112+
}
113+
114+
const $markdownEditorTextArea = $(getAttachedEasyMDE(textarea).codemirror.getInputField());
115+
// The original edit area HTML element is hidden and replaced by the
116+
// SimpleMDE/EasyMDE editor, breaking HTML5 input validation if the text area is empty.
117+
// This is a workaround for this upstream bug.
118+
// See https://github.com/sparksuite/simplemde-markdown-editor/issues/324
119+
if (textarea.value.length) {
120+
$markdownEditorTextArea.prop('required', true);
121+
form.reportValidity();
122+
return false;
123+
}
124+
$markdownEditorTextArea.prop('required', false);
125+
return true;
126+
}

web_src/js/features/repo-diff.js

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {initCompReactionSelector} from './comp/ReactionSelector.js';
22
import {initRepoIssueContentHistory} from './repo-issue-content.js';
3+
import {validateTextareaNonEmpty} from './comp/CommentEasyMDE.js';
34
const {csrfToken} = window.config;
45

56
export function initRepoDiffReviewButton() {
@@ -23,7 +24,13 @@ export function initRepoDiffFileViewToggle() {
2324
export function initRepoDiffConversationForm() {
2425
$(document).on('submit', '.conversation-holder form', async (e) => {
2526
e.preventDefault();
27+
2628
const form = $(e.target);
29+
const $textArea = form.find('textarea');
30+
if (!validateTextareaNonEmpty(form, $textArea)) {
31+
return;
32+
}
33+
2734
const newConversationHolder = $(await $.post(form.attr('action'), form.serialize()));
2835
const {path, side, idx} = newConversationHolder.data();
2936

web_src/js/features/repo-wiki.js

+3-13
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {initMarkupContent} from '../markup/content.js';
2+
import {validateTextareaNonEmpty} from './comp/CommentEasyMDE.js';
23
import {initCompMarkupContentPreviewTab} from './comp/MarkupContentPreview.js';
34

45
const {csrfToken} = window.config;
@@ -121,19 +122,8 @@ export function initRepoWikiForm() {
121122
const $markdownEditorTextArea = $(easyMDE.codemirror.getInputField());
122123
$markdownEditorTextArea.addClass('js-quick-submit');
123124

124-
$form.on('submit', function (e) {
125-
// The original edit area HTML element is hidden and replaced by the
126-
// SimpleMDE/EasyMDE editor, breaking HTML5 input validation if the text area is empty.
127-
// This is a workaround for this upstream bug.
128-
// See https://github.com/sparksuite/simplemde-markdown-editor/issues/324
129-
const input = $editArea.val();
130-
if (!input.length) {
131-
e.preventDefault();
132-
$markdownEditorTextArea.prop('required', true);
133-
this.reportValidity();
134-
} else {
135-
$markdownEditorTextArea.prop('required', false);
136-
}
125+
$form.on('submit', function () {
126+
validateTextareaNonEmpty(this, $editArea);
137127
});
138128

139129
setTimeout(() => {

0 commit comments

Comments
 (0)