aboutsummaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorGusted <williamzijl7@hotmail.com>2022-04-05 22:28:10 +0200
committerGitHub <noreply@github.com>2022-04-05 16:28:10 -0400
commit606e33d38a3aa64c54dcecf5288b77ddfe4194db (patch)
tree3a4efd8337d7da0906685baba1832f01ea9c305b /cmd
parentd4f4e95c6381ec2e8049b7bfc6c3cbee0abb63c3 (diff)
downloadgitea-606e33d38a3aa64c54dcecf5288b77ddfe4194db.tar.gz
gitea-606e33d38a3aa64c54dcecf5288b77ddfe4194db.zip
Warn on SSH connection for incorrect configuration (#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. * Update cmd/serv.go Co-authored-by: delvh <dev.lh@web.de> * Don't leak configuration * Update cmd/serv.go Co-authored-by: delvh <dev.lh@web.de> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/serv.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/cmd/serv.go b/cmd/serv.go
index c834ca298a..b106d40d28 100644
--- a/cmd/serv.go
+++ b/cmd/serv.go
@@ -296,6 +296,15 @@ func runServ(c *cli.Context) error {
gitcmd = exec.CommandContext(ctx, verb, repoPath)
}
+ // Check if setting.RepoRootPath exists. It could be the case that it doesn't exist, this can happen when
+ // `[repository]` `ROOT` is a relative path and $GITEA_WORK_DIR isn't passed to the SSH connection.
+ if _, err := os.Stat(setting.RepoRootPath); err != nil {
+ if os.IsNotExist(err) {
+ return fail("Incorrect configuration.",
+ "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.")
+ }
+ }
+
gitcmd.Dir = setting.RepoRootPath
gitcmd.Stdout = os.Stdout
gitcmd.Stdin = os.Stdin