Skip to content

Commit

Permalink
Merge branch 'main' into uprof
Browse files Browse the repository at this point in the history
  • Loading branch information
silverwind authored Jul 25, 2023
2 parents 3965c69 + e62ea96 commit 25f6156
Show file tree
Hide file tree
Showing 135 changed files with 1,530 additions and 1,037 deletions.
28 changes: 28 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,34 @@ This changelog goes through all the changes that have been made in each release
without substantial changes to our git log; to see the highlights of what has
been added to each release, please refer to the [blog](https://blog.gitea.io).

## [1.20.1](https://github.com/go-gitea/gitea/releases/tag/1.20.1) - 2023-07-22

* SECURITY
* Disallow dangerous URL schemes (#25960) (#25964)
* ENHANCEMENTS
* Show the mismatched ROOT_URL warning on the sign-in page if OAuth2 is enabled (#25947) (#25972)
* Make pending commit status yellow again (#25935) (#25968)
* BUGFIXES
* Fix version in rpm repodata/primary.xml.gz (#26009) (#26048)
* Fix env config parsing for "GITEA____APP_NAME" (#26001) (#26013)
* ParseScope with owner/repo always sets owner to zero (#25987) (#25989)
* Fix SSPI auth panic (#25955) (#25969)
* Avoid creating directories when loading config (#25944) (#25957)
* Make environment-to-ini work with INSTALL_LOCK=true (#25926) (#25937)
* Ignore `runs-on` with expressions when warning no matched runners (#25917) (#25933)
* Avoid opening/closing PRs which are already merged (#25883) (#25903)
* DOCS
* RPM Registry: Show zypper commands for SUSE based distros as well (#25981) (#26020)
* Correctly refer to dev tags as nightly in the docker docs (#26004) (#26019)
* Update path related documents (#25417) (#25982)
* MISC
* Adding remaining enum for migration repo model type. (#26021) (#26034)
* Fix the route for pull-request's authors (#26016) (#26018)
* Fix commit status color on dashboard repolist (#25993) (#25998)
* Avoid hard-coding height in language dropdown menu (#25986) (#25997)
* Add shutting down notice (#25920) (#25922)
* Fix incorrect milestone count when provide a keyword (#25880) (#25904)

## [1.20.0](https://github.com/go-gitea/gitea/releases/tag/v1.20.0) - 2023-07-16

* BREAKING
Expand Down
15 changes: 10 additions & 5 deletions assets/go-licenses.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 10 additions & 4 deletions cmd/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package cmd

import (
"context"
"errors"
"fmt"
"net/url"
Expand Down Expand Up @@ -297,10 +298,12 @@ var (
&cli.BoolFlag{
Name: "force-smtps",
Usage: "SMTPS is always used on port 465. Set this to force SMTPS on other ports.",
Value: true,
},
&cli.BoolFlag{
Name: "skip-verify",
Usage: "Skip TLS verify.",
Value: true,
},
&cli.StringFlag{
Name: "helo-hostname",
Expand All @@ -310,6 +313,7 @@ var (
&cli.BoolFlag{
Name: "disable-helo",
Usage: "Disable SMTP helo.",
Value: true,
},
&cli.StringFlag{
Name: "allowed-domains",
Expand All @@ -319,10 +323,12 @@ var (
&cli.BoolFlag{
Name: "skip-local-2fa",
Usage: "Skip 2FA to log on.",
Value: true,
},
&cli.BoolFlag{
Name: "active",
Usage: "This Authentication Source is Activated.",
Value: true,
},
}

Expand Down Expand Up @@ -373,7 +379,7 @@ func runRepoSyncReleases(_ *cli.Context) error {
continue
}

oldnum, err := getReleaseCount(repo.ID)
oldnum, err := getReleaseCount(ctx, repo.ID)
if err != nil {
log.Warn(" GetReleaseCountByRepoID: %v", err)
}
Expand All @@ -385,7 +391,7 @@ func runRepoSyncReleases(_ *cli.Context) error {
continue
}

count, err = getReleaseCount(repo.ID)
count, err = getReleaseCount(ctx, repo.ID)
if err != nil {
log.Warn(" GetReleaseCountByRepoID: %v", err)
gitRepo.Close()
Expand All @@ -401,9 +407,9 @@ func runRepoSyncReleases(_ *cli.Context) error {
return nil
}

func getReleaseCount(id int64) (int64, error) {
func getReleaseCount(ctx context.Context, id int64) (int64, error) {
return repo_model.GetReleaseCountByRepoID(
db.DefaultContext,
ctx,
id,
repo_model.FindReleasesOptions{
IncludeTags: true,
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
3 changes: 3 additions & 0 deletions cmd/manager_logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ var (
Name: "rotate",
Aliases: []string{"r"},
Usage: "Rotate logs",
Value: true,
},
&cli.Int64Flag{
Name: "max-size",
Expand All @@ -127,6 +128,7 @@ var (
Name: "daily",
Aliases: []string{"d"},
Usage: "Rotate logs daily",
Value: true,
},
&cli.IntFlag{
Name: "max-days",
Expand All @@ -137,6 +139,7 @@ var (
Name: "compress",
Aliases: []string{"z"},
Usage: "Compress rotated logs",
Value: true,
},
&cli.IntFlag{
Name: "compression-level",
Expand Down
39 changes: 13 additions & 26 deletions docs/content/doc/administration/command-line.en-us.md
Original file line number Diff line number Diff line change
Expand Up @@ -388,35 +388,18 @@ NB: Gitea must be running for this command to succeed.
Migrates the database. This command can be used to run other commands before starting the server for the first time.
This command is idempotent.

### convert
### doctor check

Converts an existing MySQL database from utf8 to utf8mb4.
Diagnose and potentially fix problems with the current Gitea instance.
Several checks are run by default, but additional ones can be run:

### doctor
- `gitea doctor check --list` - will list all the available checks
- `gitea doctor check --all` - will run all available checks
- `gitea doctor check --default` - will run the default checks
- `gitea doctor check --run [check(s),]...` - will run the named checks

Diagnose the problems of current Gitea instance according the given configuration.
Currently there are a check list below:

- Check if OpenSSH authorized_keys file id correct
When your Gitea instance support OpenSSH, your Gitea instance binary path will be written to `authorized_keys`
when there is any public key added or changed on your Gitea instance.
Sometimes if you moved or renamed your Gitea binary when upgrade and you haven't run `Update the '.ssh/authorized_keys' file with Gitea SSH keys. (Not needed for the built-in SSH server.)` on your Admin Panel. Then all pull/push via SSH will not be work.
This check will help you to check if it works well.

For contributors, if you want to add more checks, you can write a new function like `func(ctx *cli.Context) ([]string, error)` and
append it to `doctor.go`.

```go
var checklist = []check{
{
title: "Check if OpenSSH authorized_keys file id correct",
f: runDoctorLocationMoved,
},
// more checks please append here
}
```

This function will receive a command line context and return a list of details about the problems or error.
Some problems can be automatically fixed by passing the `--fix` option.
Extra logging can be set with `--log-file=...`.

#### doctor recreate-table

Expand Down Expand Up @@ -448,6 +431,10 @@ gitea doctor recreate-table

It is highly recommended to back-up your database before running these commands.

### doctor convert

Converts a MySQL database from utf8 to utf8mb4 or a MSSQL database from varchar to nvarchar.

### manager

Manage running server operations:
Expand Down
Loading

0 comments on commit 25f6156

Please sign in to comment.