summaryrefslogtreecommitdiff
path: root/go/internal/command/fallback/fallback.go
diff options
context:
space:
mode:
authorNick Thomas <nick@gitlab.com>2019-04-10 15:09:28 +0100
committerNick Thomas <nick@gitlab.com>2019-04-12 15:16:08 +0100
commit01014c474a1cef7262ca2dafc6f33bad3225ac25 (patch)
tree65f0a53a98d64a821b1085ec101da808f684cd1c /go/internal/command/fallback/fallback.go
parentf6a7f1714763d8f0048c23f0cc75184addd6d4dc (diff)
downloadgitlab-shell-01014c474a1cef7262ca2dafc6f33bad3225ac25.tar.gz
Pass the root directory into the fallback command
Diffstat (limited to 'go/internal/command/fallback/fallback.go')
-rw-r--r--go/internal/command/fallback/fallback.go23
1 files changed, 17 insertions, 6 deletions
diff --git a/go/internal/command/fallback/fallback.go b/go/internal/command/fallback/fallback.go
index 6e6d526..71e2a98 100644
--- a/go/internal/command/fallback/fallback.go
+++ b/go/internal/command/fallback/fallback.go
@@ -8,14 +8,25 @@ import (
"gitlab.com/gitlab-org/gitlab-shell/go/internal/command/readwriter"
)
-type Command struct{}
+type Command struct {
+ RootDir string
+ Args []string
+}
var (
- binDir = filepath.Dir(os.Args[0])
+ // execFunc is overridden in tests
+ execFunc = syscall.Exec
+)
+
+const (
+ RubyProgram = "gitlab-shell-ruby"
)
-func (c *Command) Execute(_ *readwriter.ReadWriter) error {
- rubyCmd := filepath.Join(binDir, "gitlab-shell-ruby")
- execErr := syscall.Exec(rubyCmd, os.Args, os.Environ())
- return execErr
+func (c *Command) Execute(*readwriter.ReadWriter) error {
+ rubyCmd := filepath.Join(c.RootDir, "bin", RubyProgram)
+
+ // Ensure rubyArgs[0] is the full path to gitlab-shell-ruby
+ rubyArgs := append([]string{rubyCmd}, c.Args[1:]...)
+
+ return execFunc(rubyCmd, rubyArgs, os.Environ())
}