Skip to content

Commit 6bddfd3

Browse files
6543delvhwxiaoguangtechknowlogick
authored
Warn on SSH connection for incorrect configuration (#19317) (#19437)
Backport #19317 - Warn on SSH connection for incorrect configuration - When `setting.RepoRootPath` cannot be found(most likely due to incorrect configuration) show "Gitea: Incorrect configuration" on the client-side to help easier with debugging the problem. Co-authored-by: delvh <[email protected]> Co-authored-by: wxiaoguang <[email protected]> Co-authored-by: techknowlogick <[email protected]>
1 parent dd8a726 commit 6bddfd3

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

cmd/serv.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,15 @@ func runServ(c *cli.Context) error {
297297
gitcmd = exec.CommandContext(ctx, verb, repoPath)
298298
}
299299

300+
// Check if setting.RepoRootPath exists. It could be the case that it doesn't exist, this can happen when
301+
// `[repository]` `ROOT` is a relative path and $GITEA_WORK_DIR isn't passed to the SSH connection.
302+
if _, err := os.Stat(setting.RepoRootPath); err != nil {
303+
if os.IsNotExist(err) {
304+
return fail("Incorrect configuration.",
305+
"Directory `[repository]` `ROOT` was not found, please check if $GITEA_WORK_DIR is passed to the SSH connection or make `[repository]` `ROOT` an absolute value.")
306+
}
307+
}
308+
300309
gitcmd.Dir = setting.RepoRootPath
301310
gitcmd.Stdout = os.Stdout
302311
gitcmd.Stdin = os.Stdin

0 commit comments

Comments
 (0)