Skip to content

Commit

Permalink
Merge branch 'main' into disk-space-calc
Browse files Browse the repository at this point in the history
  • Loading branch information
wxiaoguang authored Jan 3, 2022
2 parents 3603974 + f499f23 commit ce0e4e6
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 67 deletions.
29 changes: 29 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ linters:
- gocritic
- bidichk
- ineffassign
- revive
enable-all: false
disable-all: true
fast: false
Expand All @@ -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:
Expand Down
27 changes: 0 additions & 27 deletions .revive.toml

This file was deleted.

5 changes: 5 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) <xiaolunwen@gmail.com>
* [Matti Ranta](https://gitea.com/techknowlogick) <techknowlogick@gitea.io>
* [Andrew Thornton](https://gitea.com/zeripath) <art27@cantab.net>

* 2021-01-01 ~ 2021-12-31 - https://github.com/go-gitea/gitea/issues/13801
* [Lunny Xiao](https://gitea.com/lunny) <xiaolunwen@gmail.com>
* [Lauris Bukšis-Haberkorns](https://gitea.com/lafriks) <lauris@nix.lv>
Expand Down
29 changes: 2 additions & 27 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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:
Expand Down
5 changes: 5 additions & 0 deletions options/locale/locale_zh-CN.ini
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,12 @@ error404=您正尝试访问的页面 <strong>不存在</strong> 或 <strong>您
never=从不

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

[startpage]
app_desc=一款极易搭建的自助 Git 服务
Expand Down
28 changes: 28 additions & 0 deletions web_src/js/features/comp/CommentEasyMDE.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
7 changes: 7 additions & 0 deletions web_src/js/features/repo-diff.js
Original file line number Diff line number Diff line change
@@ -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() {
Expand All @@ -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();

Expand Down
16 changes: 3 additions & 13 deletions web_src/js/features/repo-wiki.js
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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(() => {
Expand Down

0 comments on commit ce0e4e6

Please sign in to comment.