Skip to content

Commit 56519b7

Browse files
committed
Merge remote-tracking branch 'giteaofficial/main'
* giteaofficial/main: (21 commits) Only show newly pushed branches message in the same repository (go-gitea#26148) Docusaurus-ify (go-gitea#26051) Display deprecated warning in admin panel pages as well as in the log file (go-gitea#26094) Remove "misc" scope check from public API endpoints (go-gitea#26134) Fix LFS object list style (go-gitea#26133) Drop the correct deleted branch table (go-gitea#26028) Fix CLI allowing creation of access tokens with existing name (go-gitea#26071) Fix incorrect router logger (go-gitea#26137) Increase table cell horizontal padding (go-gitea#26140) Update xorm version (go-gitea#26128) Fix UI for release tag page / wiki page / subscription page (go-gitea#25948) added ssh mirror workaround description (go-gitea#26096) Improve "gitea doctor" sub-command and fix "help" commands (go-gitea#26072) Fix wrong commit status in web ui (go-gitea#26121) remove IsWarning in tmpl (go-gitea#26120) Fix minor capitalization error in string (go-gitea#26100) Improve commit graph alignment and truncating (go-gitea#26112) Fix wrong workflow status when rerun a job in an already finished workflow (go-gitea#26119) Allow Organisations to have a E-Mail (go-gitea#25082) doc sync authentication.md to zh-cn (go-gitea#26117) ...
2 parents 6f0b317 + 338d03c commit 56519b7

File tree

328 files changed

+1460
-2768
lines changed

Some content is hidden

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

328 files changed

+1460
-2768
lines changed

.github/workflows/pull-compliance.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ jobs:
154154
node-version: 20
155155
- run: make deps-frontend
156156
- run: make lint-md
157-
- run: make docs # test if build could succeed
157+
- run: make docs
158158

159159
actions:
160160
if: needs.files-changed.outputs.actions == 'true' || needs.files-changed.outputs.actions == 'true'

Makefile

+6-13
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,6 @@ help:
197197
@echo " - clean delete backend and integration files"
198198
@echo " - clean-all delete backend, frontend and integration files"
199199
@echo " - deps install dependencies"
200-
@echo " - deps-docs install docs dependencies"
201200
@echo " - deps-frontend install frontend dependencies"
202201
@echo " - deps-backend install backend dependencies"
203202
@echo " - deps-tools install tool dependencies"
@@ -373,11 +372,11 @@ lint-backend-fix: lint-go-fix lint-go-vet lint-editorconfig
373372

374373
.PHONY: lint-js
375374
lint-js: node_modules
376-
npx eslint --color --max-warnings=0 --ext js,vue web_src/js build *.config.js docs/assets/js tests/e2e
375+
npx eslint --color --max-warnings=0 --ext js,vue web_src/js build *.config.js tests/e2e
377376

378377
.PHONY: lint-js-fix
379378
lint-js-fix: node_modules
380-
npx eslint --color --max-warnings=0 --ext js,vue web_src/js build *.config.js docs/assets/js tests/e2e --fix
379+
npx eslint --color --max-warnings=0 --ext js,vue web_src/js build *.config.js tests/e2e --fix
381380

382381
.PHONY: lint-css
383382
lint-css: node_modules
@@ -879,20 +878,14 @@ release-sources: | $(DIST_DIRS)
879878

880879
.PHONY: release-docs
881880
release-docs: | $(DIST_DIRS) docs
882-
tar -czf $(DIST)/release/gitea-docs-$(VERSION).tar.gz -C ./docs/public .
881+
tar -czf $(DIST)/release/gitea-docs-$(VERSION).tar.gz -C ./docs .
883882

884883
.PHONY: docs
885-
docs: deps-docs
886-
cd docs; make trans-copy clean build-offline;
887-
888-
.PHONY: deps-docs
889-
deps-docs:
890-
@hash hugo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
891-
curl -sL https://github.com/gohugoio/hugo/releases/download/v$(HUGO_VERSION)/hugo_$(HUGO_VERSION)_Linux-64bit.tar.gz | tar zxf - -C /tmp && mkdir -p ~/go/bin && mv /tmp/hugo ~/go/bin/hugo && chmod +x ~/go/bin/hugo; \
892-
fi
884+
docs:
885+
cd docs; bash scripts/trans-copy.sh;
893886

894887
.PHONY: deps
895-
deps: deps-frontend deps-backend deps-tools deps-docs deps-py
888+
deps: deps-frontend deps-backend deps-tools deps-py
896889

897890
.PHONY: deps-py
898891
deps-py: .venv

cmd/admin_user_generate_access_token.go

+16-5
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,28 @@ func runGenerateAccessToken(c *cli.Context) error {
5757
return err
5858
}
5959

60-
accessTokenScope, err := auth_model.AccessTokenScope(c.String("scopes")).Normalize()
60+
// construct token with name and user so we can make sure it is unique
61+
t := &auth_model.AccessToken{
62+
Name: c.String("token-name"),
63+
UID: user.ID,
64+
}
65+
66+
exist, err := auth_model.AccessTokenByNameExists(t)
6167
if err != nil {
6268
return err
6369
}
70+
if exist {
71+
return fmt.Errorf("access token name has been used already")
72+
}
6473

65-
t := &auth_model.AccessToken{
66-
Name: c.String("token-name"),
67-
UID: user.ID,
68-
Scope: accessTokenScope,
74+
// make sure the scopes are valid
75+
accessTokenScope, err := auth_model.AccessTokenScope(c.String("scopes")).Normalize()
76+
if err != nil {
77+
return fmt.Errorf("invalid access token scope provided: %w", err)
6978
}
79+
t.Scope = accessTokenScope
7080

81+
// create the token
7182
if err := auth_model.NewAccessToken(t); err != nil {
7283
return err
7384
}

cmd/doctor.go

+18-16
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,11 @@ import (
2222
"xorm.io/xorm"
2323
)
2424

25-
// CmdDoctor represents the available doctor sub-command.
26-
var CmdDoctor = &cli.Command{
27-
Name: "doctor",
25+
var cmdDoctorCheck = &cli.Command{
26+
Name: "check",
2827
Usage: "Diagnose and optionally fix problems",
2928
Description: "A command to diagnose problems with the current Gitea instance according to the given configuration. Some problems can optionally be fixed by modifying the database or data storage.",
30-
Action: runDoctor,
29+
Action: runDoctorCheck,
3130
Flags: []cli.Flag{
3231
&cli.BoolFlag{
3332
Name: "list",
@@ -51,16 +50,26 @@ var CmdDoctor = &cli.Command{
5150
},
5251
&cli.StringFlag{
5352
Name: "log-file",
54-
Usage: `Name of the log file (default: "doctor.log"). Set to "-" to output to stdout, set to "" to disable`,
53+
Usage: `Name of the log file (no verbose log output by default). Set to "-" to output to stdout`,
5554
},
5655
&cli.BoolFlag{
5756
Name: "color",
5857
Aliases: []string{"H"},
5958
Usage: "Use color for outputted information",
6059
},
6160
},
61+
}
62+
63+
// CmdDoctor represents the available doctor sub-command.
64+
var CmdDoctor = &cli.Command{
65+
Name: "doctor",
66+
Usage: "Diagnose and optionally fix problems",
67+
Description: "A command to diagnose problems with the current Gitea instance according to the given configuration. Some problems can optionally be fixed by modifying the database or data storage.",
68+
6269
Subcommands: []*cli.Command{
70+
cmdDoctorCheck,
6371
cmdRecreateTable,
72+
cmdDoctorConvert,
6473
},
6574
}
6675

@@ -133,16 +142,9 @@ func setupDoctorDefaultLogger(ctx *cli.Context, colorize bool) {
133142
setupConsoleLogger(log.FATAL, log.CanColorStderr, os.Stderr)
134143

135144
logFile := ctx.String("log-file")
136-
if !ctx.IsSet("log-file") {
137-
logFile = "doctor.log"
138-
}
139-
140-
if len(logFile) == 0 {
141-
// if no doctor log-file is set, do not show any log from default logger
142-
return
143-
}
144-
145-
if logFile == "-" {
145+
if logFile == "" {
146+
return // if no doctor log-file is set, do not show any log from default logger
147+
} else if logFile == "-" {
146148
setupConsoleLogger(log.TRACE, colorize, os.Stdout)
147149
} else {
148150
logFile, _ = filepath.Abs(logFile)
@@ -156,7 +158,7 @@ func setupDoctorDefaultLogger(ctx *cli.Context, colorize bool) {
156158
}
157159
}
158160

159-
func runDoctor(ctx *cli.Context) error {
161+
func runDoctorCheck(ctx *cli.Context) error {
160162
stdCtx, cancel := installSignals()
161163
defer cancel()
162164

cmd/convert.go cmd/doctor_convert.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ import (
1313
"github.com/urfave/cli/v2"
1414
)
1515

16-
// CmdConvert represents the available convert sub-command.
17-
var CmdConvert = &cli.Command{
16+
// cmdDoctorConvert represents the available convert sub-command.
17+
var cmdDoctorConvert = &cli.Command{
1818
Name: "convert",
1919
Usage: "Convert the database",
2020
Description: "A command to convert an existing MySQL database from utf8 to utf8mb4 or MSSQL database from varchar to nvarchar",
21-
Action: runConvert,
21+
Action: runDoctorConvert,
2222
}
2323

24-
func runConvert(ctx *cli.Context) error {
24+
func runDoctorConvert(ctx *cli.Context) error {
2525
stdCtx, cancel := installSignals()
2626
defer cancel()
2727

cmd/main.go

+14-7
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111

1212
"code.gitea.io/gitea/modules/log"
1313
"code.gitea.io/gitea/modules/setting"
14+
"code.gitea.io/gitea/modules/util"
1415

1516
"github.com/urfave/cli/v2"
1617
)
@@ -23,9 +24,13 @@ func cmdHelp() *cli.Command {
2324
Usage: "Shows a list of commands or help for one command",
2425
ArgsUsage: "[command]",
2526
Action: func(c *cli.Context) (err error) {
26-
args := c.Args()
27-
if args.Present() {
28-
err = cli.ShowCommandHelp(c, args.First())
27+
lineage := c.Lineage() // The order is from child to parent: help, doctor, Gitea, {Command:nil}
28+
targetCmdIdx := 0
29+
if c.Command.Name == "help" {
30+
targetCmdIdx = 1
31+
}
32+
if lineage[targetCmdIdx+1].Command != nil {
33+
err = cli.ShowCommandHelp(lineage[targetCmdIdx+1], lineage[targetCmdIdx].Command.Name)
2934
} else {
3035
err = cli.ShowAppHelp(c)
3136
}
@@ -94,9 +99,8 @@ func prepareSubcommandWithConfig(command *cli.Command, globalFlags []cli.Flag) {
9499
func prepareWorkPathAndCustomConf(action cli.ActionFunc) func(ctx *cli.Context) error {
95100
return func(ctx *cli.Context) error {
96101
var args setting.ArgWorkPathAndCustomConf
97-
ctxLineage := ctx.Lineage()
98-
for i := len(ctxLineage) - 1; i >= 0; i-- {
99-
curCtx := ctxLineage[i]
102+
// from children to parent, check the global flags
103+
for _, curCtx := range ctx.Lineage() {
100104
if curCtx.IsSet("work-path") && args.WorkPath == "" {
101105
args.WorkPath = curCtx.String("work-path")
102106
}
@@ -159,7 +163,6 @@ func NewMainApp() *cli.App {
159163
CmdAdmin,
160164
CmdMigrate,
161165
CmdKeys,
162-
CmdConvert,
163166
CmdDoctor,
164167
CmdManager,
165168
CmdEmbedded,
@@ -170,6 +173,10 @@ func NewMainApp() *cli.App {
170173
cmdHelp(), // the "help" sub-command was used to show the more information for "work path" and "custom config"
171174
}
172175

176+
cmdConvert := util.ToPointer(*cmdDoctorConvert)
177+
cmdConvert.Hidden = true // still support the legacy "./gitea doctor" by the hidden sub-command, remove it in next release
178+
subCmdWithConfig = append(subCmdWithConfig, cmdConvert)
179+
173180
// these sub-commands do not need the config file, and they do not depend on any path or environment variable.
174181
subCmdStandalone := []*cli.Command{
175182
CmdCert,

docs/Makefile

-36
This file was deleted.

docs/README.md

+1-30
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,7 @@
33
[![Join the chat at https://img.shields.io/discord/322538954119184384.svg](https://img.shields.io/discord/322538954119184384.svg)](https://discord.gg/Gitea)
44
[![](https://images.microbadger.com/badges/image/gitea/docs.svg)](http://microbadger.com/images/gitea/docs "Get your own image badge on microbadger.com")
55

6-
## Hosting
7-
8-
These pages are hosted using [netlifycms](https://www.netlifycms.org/) and get
9-
automatically updated on every push to the `master` branch.
10-
11-
## Install
12-
13-
These pages use the [Hugo](https://gohugo.io/) static site generator.
14-
If you are planning to contribute you'll want to download and install Hugo on
15-
your local machine.
16-
17-
The installation of Hugo is out of the scope of this document, so please take
18-
the [official install instructions](https://gohugo.io/installation/) to
19-
get Hugo up and running.
20-
21-
## Development
22-
23-
To generate the website and serve it on [localhost:1313](http://localhost:1313)
24-
just execute this command and stop it with `Ctrl+C`:
25-
26-
```
27-
make server
28-
```
29-
30-
When you are done with your changes just create a pull request, after merging
31-
the pull request the website will be updated automatically.
32-
33-
## Contributing
34-
35-
Fork -> Patch -> Push -> Pull Request
6+
These docs are ingested by our [docs repo](https://gitea.com/gitea/gitea-docusaurus).
367

378
## Authors
389

docs/README_ZH.md

+1-21
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,7 @@
44
[![Join the chat at https://img.shields.io/discord/322538954119184384.svg](https://img.shields.io/discord/322538954119184384.svg)](https://discord.gg/Gitea)
55
[![](https://images.microbadger.com/badges/image/gitea/docs.svg)](http://microbadger.com/images/gitea/docs "Get your own image badge on microbadger.com")
66

7-
## 关于托管方式
8-
9-
本页面托管在我们 Docker 容器内的基础设施上, 它会在每次推送到 `master` 分支的时候自动更新,如果你想自己管理这个页面,你可以从我们的 Docker 镜像 [gitea/docs](https://hub.docker.com/r/gitea/docs/) 中获取它。
10-
11-
## 安装 Hugo
12-
13-
本页面使用了 [Hugo](https://github.com/spf13/hugo) 静态页面生成工具,如果您有维护它的意愿,则需要在本地计算机上下载并安装 Hugo。Hugo 的安装教程不在本文档的讲述范围之内,详情请参见 [官方文档](https://gohugo.io/overview/installing/)
14-
15-
## 如何部署
16-
17-
[localhost:1313](http://localhost:1313) 处构建和运行网站的命令如下,如果需要停止可以使用组合键 `Ctrl+C`:
18-
19-
```
20-
make server
21-
```
22-
23-
完成更改后,只需创建一个 Pull Request (PR),该 PR 一经合并网站将自动更新。
24-
25-
## 如何贡献您的代码
26-
27-
Fork -> Patch -> Push -> Pull Request
7+
https://gitea.com/gitea/gitea-docusaurus
288

299
## 关于我们
3010

0 commit comments

Comments
 (0)