Skip to content

Commit

Permalink
Merge remote-tracking branch 'giteaofficial/main'
Browse files Browse the repository at this point in the history
* 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)
  ...
  • Loading branch information
zjjhot committed Jul 26, 2023
2 parents 6f0b317 + 338d03c commit 56519b7
Show file tree
Hide file tree
Showing 328 changed files with 1,460 additions and 2,768 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pull-compliance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ jobs:
node-version: 20
- run: make deps-frontend
- run: make lint-md
- run: make docs # test if build could succeed
- run: make docs

actions:
if: needs.files-changed.outputs.actions == 'true' || needs.files-changed.outputs.actions == 'true'
Expand Down
19 changes: 6 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@ help:
@echo " - clean delete backend and integration files"
@echo " - clean-all delete backend, frontend and integration files"
@echo " - deps install dependencies"
@echo " - deps-docs install docs dependencies"
@echo " - deps-frontend install frontend dependencies"
@echo " - deps-backend install backend dependencies"
@echo " - deps-tools install tool dependencies"
Expand Down Expand Up @@ -373,11 +372,11 @@ lint-backend-fix: lint-go-fix lint-go-vet lint-editorconfig

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

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

.PHONY: lint-css
lint-css: node_modules
Expand Down Expand Up @@ -879,20 +878,14 @@ release-sources: | $(DIST_DIRS)

.PHONY: release-docs
release-docs: | $(DIST_DIRS) docs
tar -czf $(DIST)/release/gitea-docs-$(VERSION).tar.gz -C ./docs/public .
tar -czf $(DIST)/release/gitea-docs-$(VERSION).tar.gz -C ./docs .

.PHONY: docs
docs: deps-docs
cd docs; make trans-copy clean build-offline;

.PHONY: deps-docs
deps-docs:
@hash hugo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
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; \
fi
docs:
cd docs; bash scripts/trans-copy.sh;

.PHONY: deps
deps: deps-frontend deps-backend deps-tools deps-docs deps-py
deps: deps-frontend deps-backend deps-tools deps-py

.PHONY: deps-py
deps-py: .venv
Expand Down
21 changes: 16 additions & 5 deletions cmd/admin_user_generate_access_token.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,28 @@ func runGenerateAccessToken(c *cli.Context) error {
return err
}

accessTokenScope, err := auth_model.AccessTokenScope(c.String("scopes")).Normalize()
// construct token with name and user so we can make sure it is unique
t := &auth_model.AccessToken{
Name: c.String("token-name"),
UID: user.ID,
}

exist, err := auth_model.AccessTokenByNameExists(t)
if err != nil {
return err
}
if exist {
return fmt.Errorf("access token name has been used already")
}

t := &auth_model.AccessToken{
Name: c.String("token-name"),
UID: user.ID,
Scope: accessTokenScope,
// make sure the scopes are valid
accessTokenScope, err := auth_model.AccessTokenScope(c.String("scopes")).Normalize()
if err != nil {
return fmt.Errorf("invalid access token scope provided: %w", err)
}
t.Scope = accessTokenScope

// create the token
if err := auth_model.NewAccessToken(t); err != nil {
return err
}
Expand Down
34 changes: 18 additions & 16 deletions cmd/doctor.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@ import (
"xorm.io/xorm"
)

// CmdDoctor represents the available doctor sub-command.
var CmdDoctor = &cli.Command{
Name: "doctor",
var cmdDoctorCheck = &cli.Command{
Name: "check",
Usage: "Diagnose and optionally fix problems",
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.",
Action: runDoctor,
Action: runDoctorCheck,
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "list",
Expand All @@ -51,16 +50,26 @@ var CmdDoctor = &cli.Command{
},
&cli.StringFlag{
Name: "log-file",
Usage: `Name of the log file (default: "doctor.log"). Set to "-" to output to stdout, set to "" to disable`,
Usage: `Name of the log file (no verbose log output by default). Set to "-" to output to stdout`,
},
&cli.BoolFlag{
Name: "color",
Aliases: []string{"H"},
Usage: "Use color for outputted information",
},
},
}

// CmdDoctor represents the available doctor sub-command.
var CmdDoctor = &cli.Command{
Name: "doctor",
Usage: "Diagnose and optionally fix problems",
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.",

Subcommands: []*cli.Command{
cmdDoctorCheck,
cmdRecreateTable,
cmdDoctorConvert,
},
}

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

logFile := ctx.String("log-file")
if !ctx.IsSet("log-file") {
logFile = "doctor.log"
}

if len(logFile) == 0 {
// if no doctor log-file is set, do not show any log from default logger
return
}

if logFile == "-" {
if logFile == "" {
return // if no doctor log-file is set, do not show any log from default logger
} else if logFile == "-" {
setupConsoleLogger(log.TRACE, colorize, os.Stdout)
} else {
logFile, _ = filepath.Abs(logFile)
Expand All @@ -156,7 +158,7 @@ func setupDoctorDefaultLogger(ctx *cli.Context, colorize bool) {
}
}

func runDoctor(ctx *cli.Context) error {
func runDoctorCheck(ctx *cli.Context) error {
stdCtx, cancel := installSignals()
defer cancel()

Expand Down
8 changes: 4 additions & 4 deletions cmd/convert.go → cmd/doctor_convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ import (
"github.com/urfave/cli/v2"
)

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

func runConvert(ctx *cli.Context) error {
func runDoctorConvert(ctx *cli.Context) error {
stdCtx, cancel := installSignals()
defer cancel()

Expand Down
21 changes: 14 additions & 7 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/util"

"github.com/urfave/cli/v2"
)
Expand All @@ -23,9 +24,13 @@ func cmdHelp() *cli.Command {
Usage: "Shows a list of commands or help for one command",
ArgsUsage: "[command]",
Action: func(c *cli.Context) (err error) {
args := c.Args()
if args.Present() {
err = cli.ShowCommandHelp(c, args.First())
lineage := c.Lineage() // The order is from child to parent: help, doctor, Gitea, {Command:nil}
targetCmdIdx := 0
if c.Command.Name == "help" {
targetCmdIdx = 1
}
if lineage[targetCmdIdx+1].Command != nil {
err = cli.ShowCommandHelp(lineage[targetCmdIdx+1], lineage[targetCmdIdx].Command.Name)
} else {
err = cli.ShowAppHelp(c)
}
Expand Down Expand Up @@ -94,9 +99,8 @@ func prepareSubcommandWithConfig(command *cli.Command, globalFlags []cli.Flag) {
func prepareWorkPathAndCustomConf(action cli.ActionFunc) func(ctx *cli.Context) error {
return func(ctx *cli.Context) error {
var args setting.ArgWorkPathAndCustomConf
ctxLineage := ctx.Lineage()
for i := len(ctxLineage) - 1; i >= 0; i-- {
curCtx := ctxLineage[i]
// from children to parent, check the global flags
for _, curCtx := range ctx.Lineage() {
if curCtx.IsSet("work-path") && args.WorkPath == "" {
args.WorkPath = curCtx.String("work-path")
}
Expand Down Expand Up @@ -159,7 +163,6 @@ func NewMainApp() *cli.App {
CmdAdmin,
CmdMigrate,
CmdKeys,
CmdConvert,
CmdDoctor,
CmdManager,
CmdEmbedded,
Expand All @@ -170,6 +173,10 @@ func NewMainApp() *cli.App {
cmdHelp(), // the "help" sub-command was used to show the more information for "work path" and "custom config"
}

cmdConvert := util.ToPointer(*cmdDoctorConvert)
cmdConvert.Hidden = true // still support the legacy "./gitea doctor" by the hidden sub-command, remove it in next release
subCmdWithConfig = append(subCmdWithConfig, cmdConvert)

// these sub-commands do not need the config file, and they do not depend on any path or environment variable.
subCmdStandalone := []*cli.Command{
CmdCert,
Expand Down
36 changes: 0 additions & 36 deletions docs/Makefile

This file was deleted.

31 changes: 1 addition & 30 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,7 @@
[![Join the chat at https://img.shields.io/discord/322538954119184384.svg](https://img.shields.io/discord/322538954119184384.svg)](https://discord.gg/Gitea)
[![](https://images.microbadger.com/badges/image/gitea/docs.svg)](http://microbadger.com/images/gitea/docs "Get your own image badge on microbadger.com")

## Hosting

These pages are hosted using [netlifycms](https://www.netlifycms.org/) and get
automatically updated on every push to the `master` branch.

## Install

These pages use the [Hugo](https://gohugo.io/) static site generator.
If you are planning to contribute you'll want to download and install Hugo on
your local machine.

The installation of Hugo is out of the scope of this document, so please take
the [official install instructions](https://gohugo.io/installation/) to
get Hugo up and running.

## Development

To generate the website and serve it on [localhost:1313](http://localhost:1313)
just execute this command and stop it with `Ctrl+C`:

```
make server
```

When you are done with your changes just create a pull request, after merging
the pull request the website will be updated automatically.

## Contributing

Fork -> Patch -> Push -> Pull Request
These docs are ingested by our [docs repo](https://gitea.com/gitea/gitea-docusaurus).

## Authors

Expand Down
22 changes: 1 addition & 21 deletions docs/README_ZH.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,7 @@
[![Join the chat at https://img.shields.io/discord/322538954119184384.svg](https://img.shields.io/discord/322538954119184384.svg)](https://discord.gg/Gitea)
[![](https://images.microbadger.com/badges/image/gitea/docs.svg)](http://microbadger.com/images/gitea/docs "Get your own image badge on microbadger.com")

## 关于托管方式

本页面托管在我们 Docker 容器内的基础设施上, 它会在每次推送到 `master` 分支的时候自动更新,如果你想自己管理这个页面,你可以从我们的 Docker 镜像 [gitea/docs](https://hub.docker.com/r/gitea/docs/) 中获取它。

## 安装 Hugo

本页面使用了 [Hugo](https://github.com/spf13/hugo) 静态页面生成工具,如果您有维护它的意愿,则需要在本地计算机上下载并安装 Hugo。Hugo 的安装教程不在本文档的讲述范围之内,详情请参见 [官方文档](https://gohugo.io/overview/installing/)

## 如何部署

[localhost:1313](http://localhost:1313) 处构建和运行网站的命令如下,如果需要停止可以使用组合键 `Ctrl+C`:

```
make server
```

完成更改后,只需创建一个 Pull Request (PR),该 PR 一经合并网站将自动更新。

## 如何贡献您的代码

Fork -> Patch -> Push -> Pull Request
https://gitea.com/gitea/gitea-docusaurus

## 关于我们

Expand Down
Loading

0 comments on commit 56519b7

Please sign in to comment.