Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --quiet option to gitea dump #22969

Merged
merged 4 commits into from
Apr 10, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion cmd/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ It can be used for backup and capture Gitea server image to send to maintainer`,
Name: "verbose, V",
Usage: "Show process details",
},
cli.BoolFlag{
Name: "quiet, q",
Usage: "Only display warnings and errors",
},
cli.StringFlag{
Name: "tempdir, t",
Value: os.TempDir(),
Expand Down Expand Up @@ -190,12 +194,25 @@ func runDump(ctx *cli.Context) error {
if _, err := setting.Cfg.Section("log.console").NewKey("STDERR", "true"); err != nil {
fatal("Setting console logger to stderr failed: %v", err)
}

// Set loglevel to Warn if quiet-mode is requested
if ctx.Bool("quiet") {
if _, err := setting.Cfg.Section("log.console").NewKey("LEVEL", "Warn"); err != nil {
fredrik-eriksson marked this conversation as resolved.
Show resolved Hide resolved
fatal("Setting console log-level failed: %v", err)
}
}

if !setting.InstallLock {
log.Error("Is '%s' really the right config path?\n", setting.CustomConf)
return fmt.Errorf("gitea is not initialized")
}
setting.NewServices() // cannot access session settings otherwise

verbose := ctx.Bool("verbose")
if verbose && ctx.Bool("quiet") {
return fmt.Errorf("--quiet and --verbose cannot both be set")
}

stdCtx, cancel := installSignals()
defer cancel()

Expand All @@ -221,7 +238,6 @@ func runDump(ctx *cli.Context) error {
return err
}

verbose := ctx.Bool("verbose")
var iface interface{}
if fileName == "-" {
iface, err = archiver.ByExtension(fmt.Sprintf(".%s", outType))
Expand Down