Skip to content

Commit

Permalink
Warn at startup if the provided SCRIPT_TYPE is not on the PATH (#18467
Browse files Browse the repository at this point in the history
)

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>
  • Loading branch information
zeripath authored Jan 30, 2022
1 parent 246902c commit e5ec7a0
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions modules/setting/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package setting

import (
"os/exec"
"path"
"path/filepath"
"strings"
Expand Down Expand Up @@ -278,6 +279,10 @@ func newRepository() {
}
ScriptType = sec.Key("SCRIPT_TYPE").MustString("bash")

if _, err := exec.LookPath(ScriptType); err != nil {
log.Warn("SCRIPT_TYPE %q is not on the current PATH. Are you sure that this is the correct SCRIPT_TYPE?", ScriptType)
}

if err = Cfg.Section("repository").MapTo(&Repository); err != nil {
log.Fatal("Failed to map Repository settings: %v", err)
} else if err = Cfg.Section("repository.editor").MapTo(&Repository.Editor); err != nil {
Expand Down

0 comments on commit e5ec7a0

Please sign in to comment.