Skip to content

Commit 388307a

Browse files
committed
Merge remote-tracking branch 'origin/main' into set-default-locations-in-docker
2 parents b3df346 + 9defddb commit 388307a

File tree

512 files changed

+8645
-6720
lines changed

Some content is hidden

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

512 files changed

+8645
-6720
lines changed

.air.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ bin = "gitea"
77
include_ext = ["go", "tmpl"]
88
exclude_dir = ["modules/git/tests", "services/gitdiff/testdata", "modules/avatar/testdata"]
99
include_dir = ["cmd", "models", "modules", "options", "routers", "services", "templates"]
10+
exclude_regex = ["_test.go$"]

.eslintrc

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ plugins:
1313
- eslint-plugin-import
1414
- eslint-plugin-vue
1515
- eslint-plugin-html
16+
- eslint-plugin-github
1617

1718
extends:
1819
- plugin:vue/recommended
@@ -96,6 +97,23 @@ rules:
9697
function-paren-newline: [0]
9798
generator-star-spacing: [0]
9899
getter-return: [2]
100+
github/array-foreach: [2]
101+
github/async-currenttarget: [2]
102+
github/async-preventdefault: [2]
103+
github/authenticity-token: [0]
104+
github/get-attribute: [2]
105+
github/js-class-name: [0]
106+
github/no-blur: [0]
107+
github/no-d-none: [0]
108+
github/no-dataset: [2]
109+
github/no-implicit-buggy-globals: [0]
110+
github/no-inner-html: [0]
111+
github/no-innerText: [2]
112+
github/no-then: [2]
113+
github/no-useless-passive: [2]
114+
github/prefer-observers: [0]
115+
github/require-passive-events: [2]
116+
github/unescaped-html-literal: [0]
99117
grouped-accessor-pairs: [2]
100118
guard-for-in: [0]
101119
id-blacklist: [0]

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ lint: lint-frontend lint-backend
328328

329329
.PHONY: lint-frontend
330330
lint-frontend: node_modules
331-
npx eslint --color --max-warnings=0 web_src/js build templates *.config.js
331+
npx eslint --color --max-warnings=0 web_src/js build templates *.config.js docs/assets/js
332332
npx stylelint --color --max-warnings=0 web_src/less
333333
npx editorconfig-checker templates
334334

build/code-batch-process.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,10 +267,10 @@ func main() {
267267
logVerbose("batch cmd: %s %v", subCmd, substArgs)
268268
switch subCmd {
269269
case "gitea-fmt":
270-
cmdErrors = append(cmdErrors, passThroughCmd("gofmt", substArgs))
271270
if containsString(subArgs, "-w") {
272271
cmdErrors = append(cmdErrors, giteaFormatGoImports(files))
273272
}
273+
cmdErrors = append(cmdErrors, passThroughCmd("gofmt", substArgs))
274274
case "misspell":
275275
cmdErrors = append(cmdErrors, passThroughCmd("misspell", substArgs))
276276
default:

build/generate-images.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,5 +80,5 @@ async function main() {
8080
]);
8181
}
8282

83-
main().then(exit).catch(exit);
83+
main().then(exit).catch(exit); // eslint-disable-line github/no-then
8484

build/generate-svg.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,5 @@ async function main() {
5454
]);
5555
}
5656

57-
main().then(exit).catch(exit);
57+
main().then(exit).catch(exit); // eslint-disable-line github/no-then
5858

cmd/admin.go

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"code.gitea.io/gitea/models"
1717
"code.gitea.io/gitea/models/db"
1818
"code.gitea.io/gitea/models/login"
19+
user_model "code.gitea.io/gitea/models/user"
1920
"code.gitea.io/gitea/modules/git"
2021
"code.gitea.io/gitea/modules/graceful"
2122
"code.gitea.io/gitea/modules/log"
@@ -358,15 +359,15 @@ func runChangePassword(c *cli.Context) error {
358359
return errors.New("The password you chose is on a list of stolen passwords previously exposed in public data breaches. Please try again with a different password.\nFor more details, see https://haveibeenpwned.com/Passwords")
359360
}
360361
uname := c.String("username")
361-
user, err := models.GetUserByName(uname)
362+
user, err := user_model.GetUserByName(uname)
362363
if err != nil {
363364
return err
364365
}
365366
if err = user.SetPassword(c.String("password")); err != nil {
366367
return err
367368
}
368369

369-
if err = models.UpdateUserCols(user, "passwd", "passwd_hash_algo", "salt"); err != nil {
370+
if err = user_model.UpdateUserCols(db.DefaultContext, user, "passwd", "passwd_hash_algo", "salt"); err != nil {
370371
return err
371372
}
372373

@@ -424,15 +425,15 @@ func runCreateUser(c *cli.Context) error {
424425

425426
// If this is the first user being created.
426427
// Take it as the admin and don't force a password update.
427-
if n := models.CountUsers(); n == 0 {
428+
if n := user_model.CountUsers(); n == 0 {
428429
changePassword = false
429430
}
430431

431432
if c.IsSet("must-change-password") {
432433
changePassword = c.Bool("must-change-password")
433434
}
434435

435-
u := &models.User{
436+
u := &user_model.User{
436437
Name: username,
437438
Email: c.String("email"),
438439
Passwd: password,
@@ -442,7 +443,7 @@ func runCreateUser(c *cli.Context) error {
442443
Theme: setting.UI.DefaultTheme,
443444
}
444445

445-
if err := models.CreateUser(u); err != nil {
446+
if err := user_model.CreateUser(u); err != nil {
446447
return fmt.Errorf("CreateUser: %v", err)
447448
}
448449

@@ -471,7 +472,7 @@ func runListUsers(c *cli.Context) error {
471472
return err
472473
}
473474

474-
users, err := models.GetAllUsers()
475+
users, err := user_model.GetAllUsers()
475476

476477
if err != nil {
477478
return err
@@ -516,13 +517,13 @@ func runDeleteUser(c *cli.Context) error {
516517
}
517518

518519
var err error
519-
var user *models.User
520+
var user *user_model.User
520521
if c.IsSet("email") {
521-
user, err = models.GetUserByEmail(c.String("email"))
522+
user, err = user_model.GetUserByEmail(c.String("email"))
522523
} else if c.IsSet("username") {
523-
user, err = models.GetUserByName(c.String("username"))
524+
user, err = user_model.GetUserByName(c.String("username"))
524525
} else {
525-
user, err = models.GetUserByID(c.Int64("id"))
526+
user, err = user_model.GetUserByID(c.Int64("id"))
526527
}
527528
if err != nil {
528529
return err

cmd/migrate_storage.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"code.gitea.io/gitea/models/db"
1414
"code.gitea.io/gitea/models/migrations"
1515
repo_model "code.gitea.io/gitea/models/repo"
16+
user_model "code.gitea.io/gitea/models/user"
1617
"code.gitea.io/gitea/modules/log"
1718
"code.gitea.io/gitea/modules/setting"
1819
"code.gitea.io/gitea/modules/storage"
@@ -94,7 +95,7 @@ func migrateLFS(dstStorage storage.ObjectStorage) error {
9495
}
9596

9697
func migrateAvatars(dstStorage storage.ObjectStorage) error {
97-
return models.IterateUser(func(user *models.User) error {
98+
return user_model.IterateUser(func(user *user_model.User) error {
9899
_, err := storage.Copy(dstStorage, user.CustomAvatarRelativePath(), storage.Avatars, user.CustomAvatarRelativePath())
99100
return err
100101
})

cmd/serv.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"time"
1818

1919
"code.gitea.io/gitea/models"
20+
"code.gitea.io/gitea/models/perm"
2021
"code.gitea.io/gitea/modules/git"
2122
"code.gitea.io/gitea/modules/json"
2223
"code.gitea.io/gitea/modules/log"
@@ -64,11 +65,11 @@ func setup(logPath string, debug bool) {
6465
}
6566

6667
var (
67-
allowedCommands = map[string]models.AccessMode{
68-
"git-upload-pack": models.AccessModeRead,
69-
"git-upload-archive": models.AccessModeRead,
70-
"git-receive-pack": models.AccessModeWrite,
71-
lfsAuthenticateVerb: models.AccessModeNone,
68+
allowedCommands = map[string]perm.AccessMode{
69+
"git-upload-pack": perm.AccessModeRead,
70+
"git-upload-archive": perm.AccessModeRead,
71+
"git-receive-pack": perm.AccessModeWrite,
72+
lfsAuthenticateVerb: perm.AccessModeNone,
7273
}
7374
alphaDashDotPattern = regexp.MustCompile(`[^\w-\.]`)
7475
)
@@ -214,9 +215,9 @@ func runServ(c *cli.Context) error {
214215

215216
if verb == lfsAuthenticateVerb {
216217
if lfsVerb == "upload" {
217-
requestedMode = models.AccessModeWrite
218+
requestedMode = perm.AccessModeWrite
218219
} else if lfsVerb == "download" {
219-
requestedMode = models.AccessModeRead
220+
requestedMode = perm.AccessModeRead
220221
} else {
221222
return fail("Unknown LFS verb", "Unknown lfs verb %s", lfsVerb)
222223
}

cmd/web_https.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"code.gitea.io/gitea/modules/graceful"
1414
"code.gitea.io/gitea/modules/log"
1515
"code.gitea.io/gitea/modules/setting"
16+
1617
"github.com/klauspost/cpuid/v2"
1718
)
1819

custom/conf/app.example.ini

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1719,6 +1719,12 @@ PATH =
17191719
;RUN_AT_START = false
17201720
;; Notice if not success
17211721
;NO_SUCCESS_NOTICE = true
1722+
;; Limit the number of mirrors added to the queue to this number
1723+
;; (negative values mean no limit, 0 will result in no result in no mirrors being queued effectively disabling pull mirror updating.)
1724+
;PULL_LIMIT=50
1725+
;; Limit the number of mirrors added to the queue to this number
1726+
;; (negative values mean no limit, 0 will result in no mirrors being queued effectively disabling push mirror updating)
1727+
;PUSH_LIMIT=50
17221728

17231729
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
17241730
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

docs/assets/js/search.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const fuseOptions = {
1515
shouldSort: true,
1616
includeMatches: true,
1717
matchAllTokens: true,
18-
threshold: 0.0, // for parsing diacritics
18+
threshold: 0, // for parsing diacritics
1919
tokenize: true,
2020
location: 0,
2121
distance: 100,
@@ -52,25 +52,25 @@ function doSearch() {
5252
executeSearch(searchQuery);
5353
} else {
5454
const para = document.createElement('P');
55-
para.innerText = 'Please enter a word or phrase above';
55+
para.textContent = 'Please enter a word or phrase above';
5656
document.getElementById('search-results').appendChild(para);
5757
}
5858
}
5959

6060
function getJSON(url, fn) {
6161
const request = new XMLHttpRequest();
6262
request.open('GET', url, true);
63-
request.onload = function () {
63+
request.addEventListener('load', () => {
6464
if (request.status >= 200 && request.status < 400) {
6565
const data = JSON.parse(request.responseText);
6666
fn(data);
6767
} else {
6868
console.error(`Target reached on ${url} with error ${request.status}`);
6969
}
70-
};
71-
request.onerror = function () {
70+
});
71+
request.addEventListener('error', () => {
7272
console.error(`Connection error ${request.status}`);
73-
};
73+
});
7474
request.send();
7575
}
7676

@@ -84,20 +84,20 @@ function executeSearch(searchQuery) {
8484
populateResults(result);
8585
} else {
8686
const para = document.createElement('P');
87-
para.innerText = 'No matches found';
87+
para.textContent = 'No matches found';
8888
document.getElementById('search-results').appendChild(para);
8989
}
9090
});
9191
}
9292

9393
function populateResults(result) {
94-
result.forEach((value, key) => {
94+
for (const [key, value] of result.entries()) {
9595
const content = value.item.contents;
9696
let snippet = '';
9797
const snippetHighlights = [];
9898
if (fuseOptions.tokenize) {
9999
snippetHighlights.push(searchQuery);
100-
value.matches.forEach((mvalue) => {
100+
for (const mvalue of value.matches) {
101101
if (mvalue.key === 'tags' || mvalue.key === 'categories') {
102102
snippetHighlights.push(mvalue.value);
103103
} else if (mvalue.key === 'contents') {
@@ -111,7 +111,7 @@ function populateResults(result) {
111111
snippetHighlights.push(mvalue.value.substring(mvalue.indices[0][0], mvalue.indices[0][1] - mvalue.indices[0][0] + 1));
112112
}
113113
}
114-
});
114+
}
115115
}
116116

117117
if (snippet.length < 1) {
@@ -130,10 +130,10 @@ function populateResults(result) {
130130
});
131131
document.getElementById('search-results').appendChild(htmlToElement(output));
132132

133-
snippetHighlights.forEach((snipvalue) => {
133+
for (const snipvalue of snippetHighlights) {
134134
new Mark(document.getElementById(`summary-${key}`)).mark(snipvalue);
135-
});
136-
});
135+
}
136+
}
137137
}
138138

139139
function render(templateString, data) {

docs/content/doc/advanced/adding-legal-pages.en-us.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ wget -O /path/to/custom/public/privacy.html https://raw.githubusercontent.com/go
2525

2626
Now you need to edit the page to meet your requirements. In particular you must change the email addresses, web addresses and references to "Your Gitea Instance" to match your situation.
2727

28-
You absolutely must not place a general ToS or privacy statement that implies that the gitea project is responsible for your server.
28+
You absolutely must not place a general ToS or privacy statement that implies that the Gitea project is responsible for your server.
2929

3030
## Make it Visible
3131

docs/content/doc/advanced/cmd-embedded.en-us.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,20 +76,20 @@ To extract resources embedded in Gitea's executable, use the following syntax:
7676
gitea [--config {file}] embedded extract [--destination {dir}|--custom] [--overwrite|--rename] [--include-vendored] {patterns...}
7777
```
7878

79-
The `--config` option tells gitea the location of the `app.ini` configuration file if
79+
The `--config` option tells Gitea the location of the `app.ini` configuration file if
8080
it's not in its default location. This option is only used with the `--custom` flag.
8181

82-
The `--destination` option tells gitea the directory where the files must be extracted to.
82+
The `--destination` option tells Gitea the directory where the files must be extracted to.
8383
The default is the current directory.
8484

85-
The `--custom` flag tells gitea to extract the files directly into the `custom` directory.
85+
The `--custom` flag tells Gitea to extract the files directly into the `custom` directory.
8686
For this to work, the command needs to know the location of the `app.ini` configuration
8787
file (`--config`) and, depending of the configuration, be ran from the directory where
8888
gitea normally starts. See [Customizing Gitea]({{< relref "doc/advanced/customizing-gitea.en-us.md" >}}) for details.
8989

9090
The `--overwrite` flag allows any existing files in the destination directory to be overwritten.
9191

92-
The `--rename` flag tells gitea to rename any existing files in the destination directory
92+
The `--rename` flag tells Gitea to rename any existing files in the destination directory
9393
as `filename.bak`. Previous `.bak` files are overwritten.
9494

9595
At least one file search pattern must be provided; see `list` subcomand above for pattern

0 commit comments

Comments
 (0)