Skip to content

Commit f607c27

Browse files
committed
Merge remote-tracking branch 'giteaofficial/main'
* giteaofficial/main: [skip ci] Updated licenses and gitignores Use correct hash for "git update-index" (go-gitea#30626) Fix repo home UI when there is no repo description (go-gitea#30552) Fix dropdown text ellipsis (go-gitea#30628) fix(api): refactor branch and tag existence checks (go-gitea#30618) Add --skip-db option to dump command (go-gitea#30613) Fix flash on dashboard (go-gitea#30572) chore: use errors.New to replace fmt.Errorf with no parameters will much better (go-gitea#30621) Fix issue comment form and quick-submit (go-gitea#30623) Use maintained gziphandler (go-gitea#30592) [skip ci] Updated translations via Crowdin Fix package list performance (go-gitea#30520) Clarify permission "HasAccess" behavior (go-gitea#30585) Fix links in PyPI Simple Repository API page (go-gitea#30594) Use action user as the trigger user of schedules (go-gitea#30581) Fix commit file status parser (go-gitea#30602) Fix HEAD method for robots.txt (go-gitea#30603)
2 parents 5f81fe7 + 31386dc commit f607c27

Some content is hidden

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

52 files changed

+342
-244
lines changed

assets/go-licenses.json

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

cmd/admin_auth.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
package cmd
55

66
import (
7+
"errors"
78
"fmt"
89
"os"
910
"text/tabwriter"
@@ -91,7 +92,7 @@ func runListAuth(c *cli.Context) error {
9192

9293
func runDeleteAuth(c *cli.Context) error {
9394
if !c.IsSet("id") {
94-
return fmt.Errorf("--id flag is missing")
95+
return errors.New("--id flag is missing")
9596
}
9697

9798
ctx, cancel := installSignals()

cmd/admin_auth_oauth.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
package cmd
55

66
import (
7+
"errors"
78
"fmt"
89
"net/url"
910

@@ -193,7 +194,7 @@ func runAddOauth(c *cli.Context) error {
193194

194195
func runUpdateOauth(c *cli.Context) error {
195196
if !c.IsSet("id") {
196-
return fmt.Errorf("--id flag is missing")
197+
return errors.New("--id flag is missing")
197198
}
198199

199200
ctx, cancel := installSignals()

cmd/admin_auth_stmp.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ package cmd
55

66
import (
77
"errors"
8-
"fmt"
98
"strings"
109

1110
auth_model "code.gitea.io/gitea/models/auth"
@@ -166,7 +165,7 @@ func runAddSMTP(c *cli.Context) error {
166165

167166
func runUpdateSMTP(c *cli.Context) error {
168167
if !c.IsSet("id") {
169-
return fmt.Errorf("--id flag is missing")
168+
return errors.New("--id flag is missing")
170169
}
171170

172171
ctx, cancel := installSignals()

cmd/admin_user_delete.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
package cmd
55

66
import (
7+
"errors"
78
"fmt"
89
"strings"
910

@@ -42,7 +43,7 @@ var microcmdUserDelete = &cli.Command{
4243

4344
func runDeleteUser(c *cli.Context) error {
4445
if !c.IsSet("id") && !c.IsSet("username") && !c.IsSet("email") {
45-
return fmt.Errorf("You must provide the id, username or email of a user to delete")
46+
return errors.New("You must provide the id, username or email of a user to delete")
4647
}
4748

4849
ctx, cancel := installSignals()

cmd/admin_user_generate_access_token.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
package cmd
55

66
import (
7+
"errors"
78
"fmt"
89

910
auth_model "code.gitea.io/gitea/models/auth"
@@ -42,7 +43,7 @@ var microcmdUserGenerateAccessToken = &cli.Command{
4243

4344
func runGenerateAccessToken(c *cli.Context) error {
4445
if !c.IsSet("username") {
45-
return fmt.Errorf("You must provide a username to generate a token for")
46+
return errors.New("You must provide a username to generate a token for")
4647
}
4748

4849
ctx, cancel := installSignals()
@@ -68,7 +69,7 @@ func runGenerateAccessToken(c *cli.Context) error {
6869
return err
6970
}
7071
if exist {
71-
return fmt.Errorf("access token name has been used already")
72+
return errors.New("access token name has been used already")
7273
}
7374

7475
// make sure the scopes are valid

cmd/dump.go

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ var CmdDump = &cli.Command{
8787
Name: "skip-index",
8888
Usage: "Skip bleve index data",
8989
},
90+
&cli.BoolFlag{
91+
Name: "skip-db",
92+
Usage: "Skip database",
93+
},
9094
&cli.StringFlag{
9195
Name: "type",
9296
Usage: fmt.Sprintf(`Dump output format, default to "zip", supported types: %s`, strings.Join(dump.SupportedOutputTypes, ", ")),
@@ -185,35 +189,41 @@ func runDump(ctx *cli.Context) error {
185189
}
186190
}
187191

188-
tmpDir := ctx.String("tempdir")
189-
if _, err := os.Stat(tmpDir); os.IsNotExist(err) {
190-
fatal("Path does not exist: %s", tmpDir)
191-
}
192+
if ctx.Bool("skip-db") {
193+
// Ensure that we don't dump the database file that may reside in setting.AppDataPath or elsewhere.
194+
dumper.GlobalExcludeAbsPath(setting.Database.Path)
195+
log.Info("Skipping database")
196+
} else {
197+
tmpDir := ctx.String("tempdir")
198+
if _, err := os.Stat(tmpDir); os.IsNotExist(err) {
199+
fatal("Path does not exist: %s", tmpDir)
200+
}
192201

193-
dbDump, err := os.CreateTemp(tmpDir, "gitea-db.sql")
194-
if err != nil {
195-
fatal("Failed to create tmp file: %v", err)
196-
}
197-
defer func() {
198-
_ = dbDump.Close()
199-
if err := util.Remove(dbDump.Name()); err != nil {
200-
log.Warn("Unable to remove temporary file: %s: Error: %v", dbDump.Name(), err)
202+
dbDump, err := os.CreateTemp(tmpDir, "gitea-db.sql")
203+
if err != nil {
204+
fatal("Failed to create tmp file: %v", err)
201205
}
202-
}()
206+
defer func() {
207+
_ = dbDump.Close()
208+
if err := util.Remove(dbDump.Name()); err != nil {
209+
log.Warn("Unable to remove temporary file: %s: Error: %v", dbDump.Name(), err)
210+
}
211+
}()
203212

204-
targetDBType := ctx.String("database")
205-
if len(targetDBType) > 0 && targetDBType != setting.Database.Type.String() {
206-
log.Info("Dumping database %s => %s...", setting.Database.Type, targetDBType)
207-
} else {
208-
log.Info("Dumping database...")
209-
}
213+
targetDBType := ctx.String("database")
214+
if len(targetDBType) > 0 && targetDBType != setting.Database.Type.String() {
215+
log.Info("Dumping database %s => %s...", setting.Database.Type, targetDBType)
216+
} else {
217+
log.Info("Dumping database...")
218+
}
210219

211-
if err := db.DumpDatabase(dbDump.Name(), targetDBType); err != nil {
212-
fatal("Failed to dump database: %v", err)
213-
}
220+
if err := db.DumpDatabase(dbDump.Name(), targetDBType); err != nil {
221+
fatal("Failed to dump database: %v", err)
222+
}
214223

215-
if err = dumper.AddFile("gitea-db.sql", dbDump.Name()); err != nil {
216-
fatal("Failed to include gitea-db.sql: %v", err)
224+
if err = dumper.AddFile("gitea-db.sql", dbDump.Name()); err != nil {
225+
fatal("Failed to include gitea-db.sql: %v", err)
226+
}
217227
}
218228

219229
log.Info("Adding custom configuration file from %s", setting.CustomConf)

cmd/embedded.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,9 @@ func runViewDo(c *cli.Context) error {
157157
}
158158

159159
if len(matchedAssetFiles) == 0 {
160-
return fmt.Errorf("no files matched the given pattern")
160+
return errors.New("no files matched the given pattern")
161161
} else if len(matchedAssetFiles) > 1 {
162-
return fmt.Errorf("too many files matched the given pattern, try to be more specific")
162+
return errors.New("too many files matched the given pattern, try to be more specific")
163163
}
164164

165165
data, err := matchedAssetFiles[0].fs.ReadFile(matchedAssetFiles[0].name)
@@ -180,7 +180,7 @@ func runExtractDo(c *cli.Context) error {
180180
}
181181

182182
if c.NArg() == 0 {
183-
return fmt.Errorf("a list of pattern of files to extract is mandatory (e.g. '**' for all)")
183+
return errors.New("a list of pattern of files to extract is mandatory (e.g. '**' for all)")
184184
}
185185

186186
destdir := "."

cmd/manager_logging.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
package cmd
55

66
import (
7+
"errors"
78
"fmt"
89
"os"
910

@@ -249,7 +250,7 @@ func runAddFileLogger(c *cli.Context) error {
249250
if c.IsSet("filename") {
250251
vals["filename"] = c.String("filename")
251252
} else {
252-
return fmt.Errorf("filename must be set when creating a file logger")
253+
return errors.New("filename must be set when creating a file logger")
253254
}
254255
if c.IsSet("rotate") {
255256
vals["rotate"] = c.Bool("rotate")

go.mod

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ require (
1616
gitea.com/lunny/levelqueue v0.4.2-0.20230414023320-3c0159fe0fe4
1717
github.com/42wim/sshsig v0.0.0-20211121163825-841cf5bbc121
1818
github.com/Azure/go-ntlmssp v0.0.0-20221128193559-754e69321358
19-
github.com/NYTimes/gziphandler v1.1.1
2019
github.com/PuerkitoBio/goquery v1.9.1
2120
github.com/alecthomas/chroma/v2 v2.13.0
2221
github.com/blakesmith/ar v0.0.0-20190502131153-809d4375e1fb
@@ -67,7 +66,7 @@ require (
6766
github.com/json-iterator/go v1.1.12
6867
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51
6968
github.com/keybase/go-crypto v0.0.0-20200123153347-de78d2cb44f4
70-
github.com/klauspost/compress v1.17.7
69+
github.com/klauspost/compress v1.17.8
7170
github.com/klauspost/cpuid/v2 v2.2.7
7271
github.com/lib/pq v1.10.9
7372
github.com/markbates/goth v1.79.0

0 commit comments

Comments
 (0)