Skip to content

Commit e9b1373

Browse files
authored
Refactor cmd setup and remove deadcode (#29313)
* use `setup(ctx, c.Bool("debug"))` like all other callers * `setting.RunMode = "dev"` is a no-op. * `if _, err := os.Stat(setting.RepoRootPath); err != nil` could be simplified
1 parent 182b9c1 commit e9b1373

File tree

2 files changed

+2
-13
lines changed

2 files changed

+2
-13
lines changed

cmd/keys.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func runKeys(c *cli.Context) error {
7171
ctx, cancel := installSignals()
7272
defer cancel()
7373

74-
setup(ctx, false)
74+
setup(ctx, c.Bool("debug"))
7575

7676
authorizedString, extra := private.AuthorizedPublicKeyByContent(ctx, content)
7777
// do not use handleCliResponseExtra or cli.NewExitError, if it exists immediately, it breaks some tests like Test_CmdKeys

cmd/serv.go

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -63,21 +63,10 @@ func setup(ctx context.Context, debug bool) {
6363
setupConsoleLogger(log.FATAL, false, os.Stderr)
6464
}
6565
setting.MustInstalled()
66-
if debug {
67-
setting.RunMode = "dev"
68-
}
69-
70-
// Check if setting.RepoRootPath exists. It could be the case that it doesn't exist, this can happen when
71-
// `[repository]` `ROOT` is a relative path and $GITEA_WORK_DIR isn't passed to the SSH connection.
7266
if _, err := os.Stat(setting.RepoRootPath); err != nil {
73-
if os.IsNotExist(err) {
74-
_ = fail(ctx, "Incorrect configuration, no repository directory.", "Directory `[repository].ROOT` %q was not found, please check if $GITEA_WORK_DIR is passed to the SSH connection or make `[repository].ROOT` an absolute value.", setting.RepoRootPath)
75-
} else {
76-
_ = fail(ctx, "Incorrect configuration, repository directory is inaccessible", "Directory `[repository].ROOT` %q is inaccessible. err: %v", setting.RepoRootPath, err)
77-
}
67+
_ = fail(ctx, "Unable to access repository path", "Unable to access repository path %q, err: %v", setting.RepoRootPath, err)
7868
return
7969
}
80-
8170
if err := git.InitSimple(context.Background()); err != nil {
8271
_ = fail(ctx, "Failed to init git", "Failed to init git, err: %v", err)
8372
}

0 commit comments

Comments
 (0)