Skip to content

Commit e5ec7a0

Browse files
authored
Warn at startup if the provided SCRIPT_TYPE is not on the PATH (#18467)
Several users run Gitea in situations whereby `bash` is not available. If the `SCRIPT_TYPE` is not changed this will cause hooks to fail. A simple test to check if the provided type is on the PATH should be sufficient to warn them about this problem. Signed-off-by: Andrew Thornton <art27@cantab.net>
1 parent 246902c commit e5ec7a0

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

modules/setting/repository.go

+5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
package setting
66

77
import (
8+
"os/exec"
89
"path"
910
"path/filepath"
1011
"strings"
@@ -278,6 +279,10 @@ func newRepository() {
278279
}
279280
ScriptType = sec.Key("SCRIPT_TYPE").MustString("bash")
280281

282+
if _, err := exec.LookPath(ScriptType); err != nil {
283+
log.Warn("SCRIPT_TYPE %q is not on the current PATH. Are you sure that this is the correct SCRIPT_TYPE?", ScriptType)
284+
}
285+
281286
if err = Cfg.Section("repository").MapTo(&Repository); err != nil {
282287
log.Fatal("Failed to map Repository settings: %v", err)
283288
} else if err = Cfg.Section("repository.editor").MapTo(&Repository.Editor); err != nil {

0 commit comments

Comments
 (0)