Skip to content

Commit 00da2da

Browse files
authored
Merge branch 'master' into block_merge_on_offical_review_request
2 parents 3275695 + 7ed5bf8 commit 00da2da

File tree

99 files changed

+904
-563
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+904
-563
lines changed

.eslintrc

+12-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ reportUnusedDisableDirectives: true
33

44
ignorePatterns:
55
- /web_src/js/vendor
6+
- /templates/base/head.tmpl
7+
- /templates/repo/activity.tmpl
8+
- /templates/repo/view_file.tmpl
69

710
parserOptions:
811
sourceType: module
@@ -12,6 +15,7 @@ plugins:
1215
- eslint-plugin-unicorn
1316
- eslint-plugin-import
1417
- eslint-plugin-vue
18+
- eslint-plugin-html
1519

1620
extends:
1721
- plugin:vue/recommended
@@ -27,12 +31,19 @@ globals:
2731
SimpleMDE: false
2832
u2fApi: false
2933

34+
settings:
35+
html/html-extensions: [".tmpl"]
36+
3037
overrides:
31-
- files: ["web_src/**/*.js", "web_src/**/*.vue"]
38+
- files: ["web_src/**/*.js", "web_src/**/*.vue", "templates/**/*.tmpl"]
3239
env:
3340
browser: true
3441
jquery: true
3542
node: false
43+
- files: ["templates/**/*.tmpl"]
44+
rules:
45+
no-tabs: [0]
46+
indent: [2, tab, {SwitchCase: 1}]
3647
- files: ["web_src/**/*worker.js"]
3748
env:
3849
worker: true

Makefile

+3-3
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ all: build
152152
.PHONY: help
153153
help:
154154
@echo "Make Routines:"
155-
@echo " - \"\" equivalent to \"build\""
155+
@echo " - \"\" equivalent to \"build\""
156156
@echo " - build build everything"
157157
@echo " - frontend build frontend files"
158158
@echo " - backend build backend files"
@@ -180,7 +180,7 @@ help:
180180
@echo " - revive run revive linter"
181181
@echo " - misspell check for misspellings"
182182
@echo " - vet examines Go source code and reports suspicious constructs"
183-
@echo " - test[\#TestSpecificName] run unit test"
183+
@echo " - test[\#TestSpecificName] run unit test"
184184
@echo " - test-sqlite[\#TestSpecificName] run integration test for sqlite"
185185
@echo " - pr#<index> build and start gitea from a PR with integration test data loaded"
186186

@@ -312,7 +312,7 @@ lint: lint-frontend lint-backend
312312

313313
.PHONY: lint-frontend
314314
lint-frontend: node_modules
315-
npx eslint --max-warnings=0 web_src/js build webpack.config.js
315+
npx eslint --max-warnings=0 web_src/js build templates webpack.config.js
316316
npx stylelint --max-warnings=0 web_src/less
317317

318318
.PHONY: lint-backend

build/update-locales.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ sed -i -r -e '/^[a-zA-Z0-9_.-]+[ ]*=[ ]*".*"$/ {
1010
}' ./options/locale/*.ini
1111

1212
# Remove translation under 25% of en_us
13-
baselines=`wc -l "./options/locale_en-US.ini" | cut -d" " -f1`
13+
baselines=$(wc -l "./options/locale_en-US.ini" | cut -d" " -f1)
1414
baselines=$((baselines / 4))
1515
for filename in ./options/locale/*.ini; do
16-
lines=`wc -l "$filename" | cut -d" " -f1`
16+
lines=$(wc -l "$filename" | cut -d" " -f1)
1717
if [ $lines -lt $baselines ]; then
1818
echo "Removing $filename: $lines/$baselines"
1919
rm "$filename"

cmd/dump.go

+14-5
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import (
2323

2424
"gitea.com/macaron/session"
2525
archiver "github.com/mholt/archiver/v3"
26-
"github.com/unknwon/com"
2726
"github.com/urfave/cli"
2827
)
2928

@@ -306,7 +305,11 @@ func runDump(ctx *cli.Context) error {
306305
log.Info("Custom dir %s doesn't exist, skipped", setting.CustomPath)
307306
}
308307

309-
if com.IsExist(setting.AppDataPath) {
308+
isExist, err := util.IsExist(setting.AppDataPath)
309+
if err != nil {
310+
log.Error("Unable to check if %s exists. Error: %v", setting.AppDataPath, err)
311+
}
312+
if isExist {
310313
log.Info("Packing data directory...%s", setting.AppDataPath)
311314

312315
var excludes []string
@@ -349,9 +352,15 @@ func runDump(ctx *cli.Context) error {
349352
// yet or not.
350353
if ctx.IsSet("skip-log") && ctx.Bool("skip-log") {
351354
log.Info("Skip dumping log files")
352-
} else if com.IsExist(setting.LogRootPath) {
353-
if err := addRecursive(w, "log", setting.LogRootPath, verbose); err != nil {
354-
fatal("Failed to include log: %v", err)
355+
} else {
356+
isExist, err := util.IsExist(setting.LogRootPath)
357+
if err != nil {
358+
log.Error("Unable to check if %s exists. Error: %v", setting.LogRootPath, err)
359+
}
360+
if isExist {
361+
if err := addRecursive(w, "log", setting.LogRootPath, verbose); err != nil {
362+
fatal("Failed to include log: %v", err)
363+
}
355364
}
356365
}
357366

cmd/web.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ import (
1616
"code.gitea.io/gitea/modules/graceful"
1717
"code.gitea.io/gitea/modules/log"
1818
"code.gitea.io/gitea/modules/setting"
19+
"code.gitea.io/gitea/modules/util"
1920
"code.gitea.io/gitea/routers"
2021
"code.gitea.io/gitea/routers/routes"
2122

2223
context2 "github.com/gorilla/context"
23-
"github.com/unknwon/com"
2424
"github.com/urfave/cli"
2525
"golang.org/x/crypto/acme/autocert"
2626
ini "gopkg.in/ini.v1"
@@ -188,7 +188,11 @@ func setPort(port string) error {
188188
default:
189189
// Save LOCAL_ROOT_URL if port changed
190190
cfg := ini.Empty()
191-
if com.IsFile(setting.CustomConf) {
191+
isFile, err := util.IsFile(setting.CustomConf)
192+
if err != nil {
193+
log.Fatal("Unable to check if %s is a file", err)
194+
}
195+
if isFile {
192196
// Keeps custom settings if there is already something.
193197
if err := cfg.Append(setting.CustomConf); err != nil {
194198
return fmt.Errorf("Failed to load custom conf '%s': %v", setting.CustomConf, err)

contrib/environment-to-ini/environment-to-ini.go

+7-3
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import (
1212

1313
"code.gitea.io/gitea/modules/log"
1414
"code.gitea.io/gitea/modules/setting"
15+
"code.gitea.io/gitea/modules/util"
1516

16-
"github.com/unknwon/com"
1717
"github.com/urfave/cli"
1818
ini "gopkg.in/ini.v1"
1919
)
@@ -97,7 +97,11 @@ func runEnvironmentToIni(c *cli.Context) error {
9797
setting.SetCustomPathAndConf(providedCustom, providedConf, providedWorkPath)
9898

9999
cfg := ini.Empty()
100-
if com.IsFile(setting.CustomConf) {
100+
isFile, err := util.IsFile(setting.CustomConf)
101+
if err != nil {
102+
log.Fatal("Unable to check if %s is a file. Error: %v", setting.CustomConf, err)
103+
}
104+
if isFile {
101105
if err := cfg.Append(setting.CustomConf); err != nil {
102106
log.Fatal("Failed to load custom conf '%s': %v", setting.CustomConf, err)
103107
}
@@ -145,7 +149,7 @@ func runEnvironmentToIni(c *cli.Context) error {
145149
if len(destination) == 0 {
146150
destination = setting.CustomConf
147151
}
148-
err := cfg.SaveTo(destination)
152+
err = cfg.SaveTo(destination)
149153
if err != nil {
150154
return err
151155
}

custom/conf/app.example.ini

+29-29
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ SCRIPT_TYPE = bash
2323
; If the charsets have equal confidence, tie-breaking will be done by order in this list
2424
; with charsets earlier in the list chosen in preference to those later.
2525
; Adding "defaults" will place the unused charsets at that position.
26-
DETECTED_CHARSETS_ORDER=UTF-8, UTF-16BE, UTF-16LE, UTF-32BE, UTF-32LE, ISO-8859, windows-1252, ISO-8859, windows-1250, ISO-8859, ISO-8859, ISO-8859, windows-1253, ISO-8859, windows-1255, ISO-8859, windows-1251, windows-1256, KOI8-R, ISO-8859, windows-1254, Shift_JIS, GB18030, EUC-JP, EUC-KR, Big5, ISO-2022, ISO-2022, ISO-2022, IBM424_rtl, IBM424_ltr, IBM420_rtl, IBM420_ltr
26+
DETECTED_CHARSETS_ORDER = UTF-8, UTF-16BE, UTF-16LE, UTF-32BE, UTF-32LE, ISO-8859, windows-1252, ISO-8859, windows-1250, ISO-8859, ISO-8859, ISO-8859, windows-1253, ISO-8859, windows-1255, ISO-8859, windows-1251, windows-1256, KOI8-R, ISO-8859, windows-1254, Shift_JIS, GB18030, EUC-JP, EUC-KR, Big5, ISO-2022, ISO-2022, ISO-2022, IBM424_rtl, IBM424_ltr, IBM420_rtl, IBM420_ltr
2727
; Default ANSI charset to override non-UTF-8 charsets to
2828
ANSI_CHARSET =
2929
; Force every new repository to be private
@@ -65,11 +65,11 @@ PREFIX_ARCHIVE_FILES = true
6565
; Disable the creation of new mirrors. Pre-existing mirrors remain valid.
6666
DISABLE_MIRRORS = false
6767
; The default branch name of new repositories
68-
DEFAULT_BRANCH=master
68+
DEFAULT_BRANCH = master
6969
; Allow adoption of unadopted repositories
70-
ALLOW_ADOPTION_OF_UNADOPTED_REPOSITORIES=false
70+
ALLOW_ADOPTION_OF_UNADOPTED_REPOSITORIES = false
7171
; Allow deletion of unadopted repositories
72-
ALLOW_DELETION_OF_UNADOPTED_REPOSITORIES=false
72+
ALLOW_DELETION_OF_UNADOPTED_REPOSITORIES = false
7373

7474
[repository.editor]
7575
; List of file extensions for which lines should be wrapped in the Monaco editor
@@ -97,25 +97,25 @@ MAX_FILES = 5
9797

9898
[repository.pull-request]
9999
; List of prefixes used in Pull Request title to mark them as Work In Progress
100-
WORK_IN_PROGRESS_PREFIXES=WIP:,[WIP]
100+
WORK_IN_PROGRESS_PREFIXES = WIP:,[WIP]
101101
; List of keywords used in Pull Request comments to automatically close a related issue
102-
CLOSE_KEYWORDS=close,closes,closed,fix,fixes,fixed,resolve,resolves,resolved
102+
CLOSE_KEYWORDS = close,closes,closed,fix,fixes,fixed,resolve,resolves,resolved
103103
; List of keywords used in Pull Request comments to automatically reopen a related issue
104-
REOPEN_KEYWORDS=reopen,reopens,reopened
104+
REOPEN_KEYWORDS = reopen,reopens,reopened
105105
; In the default merge message for squash commits include at most this many commits
106-
DEFAULT_MERGE_MESSAGE_COMMITS_LIMIT=50
106+
DEFAULT_MERGE_MESSAGE_COMMITS_LIMIT = 50
107107
; In the default merge message for squash commits limit the size of the commit messages to this
108-
DEFAULT_MERGE_MESSAGE_SIZE=5120
108+
DEFAULT_MERGE_MESSAGE_SIZE = 5120
109109
; In the default merge message for squash commits walk all commits to include all authors in the Co-authored-by otherwise just use those in the limited list
110-
DEFAULT_MERGE_MESSAGE_ALL_AUTHORS=false
110+
DEFAULT_MERGE_MESSAGE_ALL_AUTHORS = false
111111
; In default merge messages limit the number of approvers listed as Reviewed-by: to this many
112-
DEFAULT_MERGE_MESSAGE_MAX_APPROVERS=10
112+
DEFAULT_MERGE_MESSAGE_MAX_APPROVERS = 10
113113
; In default merge messages only include approvers who are official
114-
DEFAULT_MERGE_MESSAGE_OFFICIAL_APPROVERS_ONLY=true
114+
DEFAULT_MERGE_MESSAGE_OFFICIAL_APPROVERS_ONLY = true
115115

116116
[repository.issue]
117117
; List of reasons why a Pull Request or Issue can be locked
118-
LOCK_REASONS=Too heated,Off-topic,Resolved,Spam
118+
LOCK_REASONS = Too heated,Off-topic,Resolved,Spam
119119

120120
[repository.release]
121121
; Comma-separated list of allowed file extensions (`.zip`), mime types (`text/plain`) or wildcard type (`image/*`, `audio/*`, `video/*`). Empty value or `*/*` allows all types.
@@ -133,7 +133,7 @@ SIGNING_KEY = default
133133
SIGNING_NAME =
134134
SIGNING_EMAIL =
135135
; Sets the default trust model for repositories. Options are: collaborator, committer, collaboratorcommitter
136-
DEFAULT_TRUST_MODEL=collaborator
136+
DEFAULT_TRUST_MODEL = collaborator
137137
; Determines when gitea should sign the initial commit when creating a repository
138138
; Either:
139139
; - never
@@ -158,19 +158,19 @@ MERGES = pubkey, twofa, basesigned, commitssigned
158158
[cors]
159159
; More information about CORS can be found here: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS#The_HTTP_response_headers
160160
; enable cors headers (disabled by default)
161-
ENABLED=false
161+
ENABLED = false
162162
; scheme of allowed requests
163-
SCHEME=http
163+
SCHEME = http
164164
; list of requesting domains that are allowed
165-
ALLOW_DOMAIN=*
165+
ALLOW_DOMAIN = *
166166
; allow subdomains of headers listed above to request
167-
ALLOW_SUBDOMAIN=false
167+
ALLOW_SUBDOMAIN = false
168168
; list of methods allowed to request
169-
METHODS=GET,HEAD,POST,PUT,PATCH,DELETE,OPTIONS
169+
METHODS = GET,HEAD,POST,PUT,PATCH,DELETE,OPTIONS
170170
; max time to cache response
171-
MAX_AGE=10m
171+
MAX_AGE = 10m
172172
; allow request with credentials
173-
ALLOW_CREDENTIALS=false
173+
ALLOW_CREDENTIALS = false
174174

175175
[ui]
176176
; Number of repositories that are displayed on one explore page
@@ -456,7 +456,7 @@ ISSUE_INDEXER_QUEUE_CONN_STR = "addrs=127.0.0.1:6379 db=0"
456456
ISSUE_INDEXER_QUEUE_BATCH_NUMBER = 20
457457
; Timeout the indexer if it takes longer than this to start.
458458
; Set to zero to disable timeout.
459-
STARTUP_TIMEOUT=30s
459+
STARTUP_TIMEOUT = 30s
460460

461461
; repo indexer by default disabled, since it uses a lot of disk space
462462
REPO_INDEXER_ENABLED = false
@@ -597,7 +597,7 @@ RESET_PASSWD_CODE_LIVE_MINUTES = 180
597597
REGISTER_EMAIL_CONFIRM = false
598598
; List of domain names that are allowed to be used to register on a Gitea instance
599599
; gitea.io,example.com
600-
EMAIL_DOMAIN_WHITELIST=
600+
EMAIL_DOMAIN_WHITELIST =
601601
; Disallow registration, only allow admins to create accounts.
602602
DISABLE_REGISTRATION = false
603603
; Allow registration only using third-party services, it works only when DISABLE_REGISTRATION is false
@@ -620,7 +620,7 @@ ENABLE_CAPTCHA = false
620620
CAPTCHA_TYPE = image
621621
; Enable recaptcha to use Google's recaptcha service
622622
; Go to https://www.google.com/recaptcha/admin to sign up for a key
623-
RECAPTCHA_SECRET =
623+
RECAPTCHA_SECRET =
624624
RECAPTCHA_SITEKEY =
625625
; For hCaptcha, create an account at https://accounts.hcaptcha.com/login to get your keys
626626
HCAPTCHA_SECRET =
@@ -1117,15 +1117,15 @@ DEFAULT_MAX_BLOB_SIZE = 10485760
11171117
; Enables OAuth2 provider
11181118
ENABLE = true
11191119
; Lifetime of an OAuth2 access token in seconds
1120-
ACCESS_TOKEN_EXPIRATION_TIME=3600
1120+
ACCESS_TOKEN_EXPIRATION_TIME = 3600
11211121
; Lifetime of an OAuth2 refresh token in hours
1122-
REFRESH_TOKEN_EXPIRATION_TIME=730
1122+
REFRESH_TOKEN_EXPIRATION_TIME = 730
11231123
; Check if refresh token got already used
1124-
INVALIDATE_REFRESH_TOKENS=false
1124+
INVALIDATE_REFRESH_TOKENS = false
11251125
; OAuth2 authentication secret for access and refresh tokens, change this yourself to a unique string. CLI generate option is helpful in this case. https://docs.gitea.io/en-us/command-line/#generate
1126-
JWT_SECRET=
1126+
JWT_SECRET =
11271127
; Maximum length of oauth2 token/cookie stored on server
1128-
MAX_TOKEN_LENGTH=32767
1128+
MAX_TOKEN_LENGTH = 32767
11291129

11301130
[i18n]
11311131
LANGS = en-US,zh-CN,zh-HK,zh-TW,de-DE,fr-FR,nl-NL,lv-LV,ru-RU,uk-UA,ja-JP,es-ES,pt-BR,pt-PT,pl-PL,bg-BG,it-IT,fi-FI,tr-TR,cs-CZ,sr-SP,sv-SE,ko-KR

docker/root/etc/s6/gitea/run

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
[[ -f ./setup ]] && source ./setup
33

4-
pushd /app/gitea > /dev/null
5-
exec su-exec $USER /app/gitea/gitea web
4+
pushd /app/gitea >/dev/null
5+
exec su-exec $USER /app/gitea/gitea web
66
popd

docker/root/etc/s6/openssh/run

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
[[ -f ./setup ]] && source ./setup
33

4-
pushd /root > /dev/null
5-
exec su-exec root /usr/sbin/sshd -D -e 2>&1
4+
pushd /root >/dev/null
5+
exec su-exec root /usr/sbin/sshd -D -e 2>&1
66
popd

docs/.editorconfig

-34
This file was deleted.

0 commit comments

Comments
 (0)