Skip to content

Commit db2e80c

Browse files
committed
Merge remote-tracking branch 'origin/main' into rmapi
* origin/main: (35 commits) Remove fomantic button module (go-gitea#30475) Improve "must-change-password" logic and document (go-gitea#30472) Fix commitstatus summary (go-gitea#30431) Remove fomantic menu module (go-gitea#30325) Use `flex-container` for dashboard layout (go-gitea#30214) Rewrite and restyle reaction selector and enable no-sizzle eslint rule (go-gitea#30453) Pulse page improvements (go-gitea#30149) Fix JS error when opening to expanded code comment (go-gitea#30463) fix: Fix to delete cookie when AppSubURL is non-empty (go-gitea#30375) Add `interface{}` to `any` replacement to `make fmt`, exclude `*.pb.go` (go-gitea#30461) Fix network error when open/close organization/individual projects and redirect to project page (go-gitea#30387) Avoid losing token when updating mirror settings (go-gitea#30429) Fix label rendering (go-gitea#30456) Add comment for ContainsRedirectURI about the exact match (go-gitea#30457) Update JS and PY deps, lock eslint and related plugins (go-gitea#30452) Refactor cache and disable go-chi cache (go-gitea#30417) Fix admin notice view-detail (go-gitea#30450) Fix mirror error when mirror repo is empty (go-gitea#30432) Add `/public/assets/img/webpack` to ignore files again (go-gitea#30451) Lock a few tool dependencies to major versions (go-gitea#30439) ...
2 parents e92cc01 + 9946353 commit db2e80c

File tree

122 files changed

+5511
-9251
lines changed

Some content is hidden

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

122 files changed

+5511
-9251
lines changed

.dockerignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ cpu.out
9595
/.air
9696
/.go-licenses
9797

98+
# Files and folders that were previously generated
99+
/public/assets/img/webpack
100+
98101
# Snapcraft
99102
snap/.snapcraft/
100103
parts/

.eslintrc.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ rules:
318318
jquery/no-serialize: [2]
319319
jquery/no-show: [2]
320320
jquery/no-size: [2]
321-
jquery/no-sizzle: [0]
321+
jquery/no-sizzle: [2]
322322
jquery/no-slide: [0]
323323
jquery/no-submit: [0]
324324
jquery/no-text: [0]
@@ -470,7 +470,7 @@ rules:
470470
no-jquery/no-selector-prop: [2]
471471
no-jquery/no-serialize: [2]
472472
no-jquery/no-size: [2]
473-
no-jquery/no-sizzle: [0]
473+
no-jquery/no-sizzle: [2]
474474
no-jquery/no-slide: [2]
475475
no-jquery/no-sub: [2]
476476
no-jquery/no-support: [2]

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
* text=auto eol=lf
22
*.tmpl linguist-language=Handlebars
3+
*.pb.go linguist-generated
34
/assets/*.json linguist-generated
45
/public/assets/img/svg/*.svg linguist-generated
56
/templates/swagger/v1_json.tmpl linguist-generated

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ cpu.out
9494
/.air
9595
/.go-licenses
9696

97+
# Files and folders that were previously generated
98+
/public/assets/img/webpack
99+
97100
# Snapcraft
98101
/gitea_a*.txt
99102
snap/.snapcraft/

.golangci.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@ linters:
3030

3131
run:
3232
timeout: 10m
33-
skip-dirs:
34-
- node_modules
35-
- public
36-
- web_src
3733

3834
linters-settings:
3935
stylecheck:
@@ -90,10 +86,13 @@ linters-settings:
9086
desc: do not use the internal package, use AddXxx function instead
9187
- pkg: gopkg.in/ini.v1
9288
desc: do not use the ini package, use gitea's config system instead
89+
- pkg: gitea.com/go-chi/cache
90+
desc: do not use the go-chi cache package, use gitea's cache system
9391

9492
issues:
9593
max-issues-per-linter: 0
9694
max-same-issues: 0
95+
exclude-dirs: [node_modules, public, web_src]
9796
exclude-rules:
9897
# Exclude some linters from running on tests files.
9998
- path: _test\.go

Makefile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,17 @@ COMMA := ,
2525

2626
XGO_VERSION := go-1.22.x
2727

28-
AIR_PACKAGE ?= github.com/cosmtrek/air@v1.49.0
28+
AIR_PACKAGE ?= github.com/cosmtrek/air@v1
2929
EDITORCONFIG_CHECKER_PACKAGE ?= github.com/editorconfig-checker/editorconfig-checker/cmd/[email protected]
3030
GOFUMPT_PACKAGE ?= mvdan.cc/[email protected]
31-
GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/golangci-lint@v1.56.1
31+
GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/golangci-lint@v1.57.2
3232
GXZ_PACKAGE ?= github.com/ulikunitz/xz/cmd/[email protected]
3333
MISSPELL_PACKAGE ?= github.com/golangci/misspell/cmd/[email protected]
3434
SWAGGER_PACKAGE ?= github.com/go-swagger/go-swagger/cmd/swagger@db51e79a0e37c572d8b59ae0c58bf2bbbbe53285
3535
XGO_PACKAGE ?= src.techknowlogick.com/xgo@latest
36-
GO_LICENSES_PACKAGE ?= github.com/google/go-licenses@v1.6.0
37-
GOVULNCHECK_PACKAGE ?= golang.org/x/vuln/cmd/govulncheck@v1.0.3
38-
ACTIONLINT_PACKAGE ?= github.com/rhysd/actionlint/cmd/actionlint@v1.6.26
36+
GO_LICENSES_PACKAGE ?= github.com/google/go-licenses@v1
37+
GOVULNCHECK_PACKAGE ?= golang.org/x/vuln/cmd/govulncheck@v1
38+
ACTIONLINT_PACKAGE ?= github.com/rhysd/actionlint/cmd/actionlint@v1
3939

4040
DOCKER_IMAGE ?= gitea/gitea
4141
DOCKER_TAG ?= latest
@@ -295,7 +295,7 @@ clean:
295295

296296
.PHONY: fmt
297297
fmt:
298-
GOFUMPT_PACKAGE=$(GOFUMPT_PACKAGE) $(GO) run build/code-batch-process.go gitea-fmt -w '{file-list}'
298+
@GOFUMPT_PACKAGE=$(GOFUMPT_PACKAGE) $(GO) run build/code-batch-process.go gitea-fmt -w '{file-list}'
299299
$(eval TEMPLATES := $(shell find templates -type f -name '*.tmpl'))
300300
@# strip whitespace after '{{' or '(' and before '}}' or ')' unless there is only
301301
@# whitespace before it

assets/go-licenses.json

Lines changed: 10 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/code-batch-process.go

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ func newFileCollector(fileFilter string, batchSize int) (*fileCollector, error)
6969
co.includePatterns = append(co.includePatterns, regexp.MustCompile(`.*\.go$`))
7070

7171
co.excludePatterns = append(co.excludePatterns, regexp.MustCompile(`.*\bbindata\.go$`))
72+
co.excludePatterns = append(co.excludePatterns, regexp.MustCompile(`\.pb\.go$`))
7273
co.excludePatterns = append(co.excludePatterns, regexp.MustCompile(`tests/gitea-repositories-meta`))
7374
co.excludePatterns = append(co.excludePatterns, regexp.MustCompile(`tests/integration/migration-test`))
7475
co.excludePatterns = append(co.excludePatterns, regexp.MustCompile(`modules/git/tests`))
@@ -203,17 +204,6 @@ Example:
203204
`, "file-batch-exec")
204205
}
205206

206-
func getGoVersion() string {
207-
goModFile, err := os.ReadFile("go.mod")
208-
if err != nil {
209-
log.Fatalf(`Faild to read "go.mod": %v`, err)
210-
os.Exit(1)
211-
}
212-
goModVersionRegex := regexp.MustCompile(`go \d+\.\d+`)
213-
goModVersionLine := goModVersionRegex.Find(goModFile)
214-
return string(goModVersionLine[3:])
215-
}
216-
217207
func newFileCollectorFromMainOptions(mainOptions map[string]string) (fc *fileCollector, err error) {
218208
fileFilter := mainOptions["file-filter"]
219209
if fileFilter == "" {
@@ -278,7 +268,8 @@ func main() {
278268
log.Print("the -d option is not supported by gitea-fmt")
279269
}
280270
cmdErrors = append(cmdErrors, giteaFormatGoImports(files, containsString(subArgs, "-w")))
281-
cmdErrors = append(cmdErrors, passThroughCmd("go", append([]string{"run", os.Getenv("GOFUMPT_PACKAGE"), "-extra", "-lang", getGoVersion()}, substArgs...)))
271+
cmdErrors = append(cmdErrors, passThroughCmd("gofmt", append([]string{"-w", "-r", "interface{} -> any"}, substArgs...)))
272+
cmdErrors = append(cmdErrors, passThroughCmd("go", append([]string{"run", os.Getenv("GOFUMPT_PACKAGE"), "-extra"}, substArgs...)))
282273
default:
283274
log.Fatalf("unknown cmd: %s %v", subCmd, subArgs)
284275
}

cmd/admin_user_change_password.go

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ var microcmdUserChangePassword = &cli.Command{
3636
&cli.BoolFlag{
3737
Name: "must-change-password",
3838
Usage: "User must change password",
39+
Value: true,
3940
},
4041
},
4142
}
@@ -57,23 +58,18 @@ func runChangePassword(c *cli.Context) error {
5758
return err
5859
}
5960

60-
var mustChangePassword optional.Option[bool]
61-
if c.IsSet("must-change-password") {
62-
mustChangePassword = optional.Some(c.Bool("must-change-password"))
63-
}
64-
6561
opts := &user_service.UpdateAuthOptions{
6662
Password: optional.Some(c.String("password")),
67-
MustChangePassword: mustChangePassword,
63+
MustChangePassword: optional.Some(c.Bool("must-change-password")),
6864
}
6965
if err := user_service.UpdateAuth(ctx, user, opts); err != nil {
7066
switch {
7167
case errors.Is(err, password.ErrMinLength):
72-
return fmt.Errorf("Password is not long enough. Needs to be at least %d", setting.MinPasswordLength)
68+
return fmt.Errorf("password is not long enough, needs to be at least %d characters", setting.MinPasswordLength)
7369
case errors.Is(err, password.ErrComplexity):
74-
return errors.New("Password does not meet complexity requirements")
70+
return errors.New("password does not meet complexity requirements")
7571
case errors.Is(err, password.ErrIsPwned):
76-
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")
72+
return errors.New("the password is in a list of stolen passwords previously exposed in public data breaches, please try again with a different password, to see more details: https://haveibeenpwned.com/Passwords")
7773
default:
7874
return err
7975
}

cmd/admin_user_create.go

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"fmt"
99

1010
auth_model "code.gitea.io/gitea/models/auth"
11+
"code.gitea.io/gitea/models/db"
1112
user_model "code.gitea.io/gitea/models/user"
1213
pwd "code.gitea.io/gitea/modules/auth/password"
1314
"code.gitea.io/gitea/modules/optional"
@@ -46,8 +47,9 @@ var microcmdUserCreate = &cli.Command{
4647
Usage: "Generate a random password for the user",
4748
},
4849
&cli.BoolFlag{
49-
Name: "must-change-password",
50-
Usage: "Set this option to false to prevent forcing the user to change their password after initial login, (Default: true)",
50+
Name: "must-change-password",
51+
Usage: "Set to false to prevent forcing the user to change their password after initial login",
52+
DisableDefaultText: true,
5153
},
5254
&cli.IntFlag{
5355
Name: "random-password-length",
@@ -71,10 +73,10 @@ func runCreateUser(c *cli.Context) error {
7173
}
7274

7375
if c.IsSet("name") && c.IsSet("username") {
74-
return errors.New("Cannot set both --name and --username flags")
76+
return errors.New("cannot set both --name and --username flags")
7577
}
7678
if !c.IsSet("name") && !c.IsSet("username") {
77-
return errors.New("One of --name or --username flags must be set")
79+
return errors.New("one of --name or --username flags must be set")
7880
}
7981

8082
if c.IsSet("password") && c.IsSet("random-password") {
@@ -110,17 +112,21 @@ func runCreateUser(c *cli.Context) error {
110112
return errors.New("must set either password or random-password flag")
111113
}
112114

113-
// always default to true
114-
changePassword := true
115-
116-
// If this is the first user being created.
117-
// Take it as the admin and don't force a password update.
118-
if n := user_model.CountUsers(ctx, nil); n == 0 {
119-
changePassword = false
120-
}
121-
115+
isAdmin := c.Bool("admin")
116+
mustChangePassword := true // always default to true
122117
if c.IsSet("must-change-password") {
123-
changePassword = c.Bool("must-change-password")
118+
// if the flag is set, use the value provided by the user
119+
mustChangePassword = c.Bool("must-change-password")
120+
} else {
121+
// check whether there are users in the database
122+
hasUserRecord, err := db.IsTableNotEmpty(&user_model.User{})
123+
if err != nil {
124+
return fmt.Errorf("IsTableNotEmpty: %w", err)
125+
}
126+
if !hasUserRecord && isAdmin {
127+
// if this is the first admin being created, don't force to change password (keep the old behavior)
128+
mustChangePassword = false
129+
}
124130
}
125131

126132
restricted := optional.None[bool]()
@@ -136,8 +142,8 @@ func runCreateUser(c *cli.Context) error {
136142
Name: username,
137143
Email: c.String("email"),
138144
Passwd: password,
139-
IsAdmin: c.Bool("admin"),
140-
MustChangePassword: changePassword,
145+
IsAdmin: isAdmin,
146+
MustChangePassword: mustChangePassword,
141147
Visibility: visibility,
142148
}
143149

docs/content/administration/command-line.en-us.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,7 @@ Admin operations:
8383
- `--email value`: Email. Required.
8484
- `--admin`: If provided, this makes the user an admin. Optional.
8585
- `--access-token`: If provided, an access token will be created for the user. Optional. (default: false).
86-
- `--must-change-password`: If provided, the created user will be required to choose a newer password after the
87-
initial login. Optional. (default: true).
86+
- `--must-change-password`: The created user will be required to set a new password after the initial login, default: true. It could be disabled by `--must-change-password=false`.
8887
- `--random-password`: If provided, a randomly generated password will be used as the password of the created
8988
user. The value of `--password` will be discarded. Optional.
9089
- `--random-password-length`: If provided, it will be used to configure the length of the randomly generated
@@ -95,7 +94,7 @@ Admin operations:
9594
- Options:
9695
- `--username value`, `-u value`: Username. Required.
9796
- `--password value`, `-p value`: New password. Required.
98-
- `--must-change-password`: If provided, the user is required to choose a new password after the login. Optional.
97+
- `--must-change-password`: The user is required to set a new password after the login, default: true. It could be disabled by `--must-change-password=false`.
9998
- Examples:
10099
- `gitea admin user change-password --username myname --password asecurepassword`
101100
- `must-change-password`:

docs/content/usage/actions/act-runner.en-us.md

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -303,34 +303,3 @@ sudo systemctl enable act_runner --now
303303
```
304304

305305
If using Docker, the `act_runner` user should also be added to the `docker` group before starting the service. Keep in mind that this effectively gives `act_runner` root access to the system [[1]](https://docs.docker.com/engine/security/#docker-daemon-attack-surface).
306-
307-
## Configuration variable
308-
309-
You can create configuration variables on the user, organization and repository level.
310-
The level of the variable depends on where you created it.
311-
312-
### Naming conventions
313-
314-
The following rules apply to variable names:
315-
316-
- Variable names can only contain alphanumeric characters (`[a-z]`, `[A-Z]`, `[0-9]`) or underscores (`_`). Spaces are not allowed.
317-
318-
- Variable names must not start with the `GITHUB_` and `GITEA_` prefix.
319-
320-
- Variable names must not start with a number.
321-
322-
- Variable names are case-insensitive.
323-
324-
- Variable names must be unique at the level they are created at.
325-
326-
- Variable names must not be `CI`.
327-
328-
### Using variable
329-
330-
After creating configuration variables, they will be automatically filled in the `vars` context.
331-
They can be accessed through expressions like `{{ vars.VARIABLE_NAME }}` in the workflow.
332-
333-
### Precedence
334-
335-
If a variable with the same name exists at multiple levels, the variable at the lowest level takes precedence:
336-
A repository variable will always be chosen over an organization/user variable.

0 commit comments

Comments
 (0)