summaryrefslogtreecommitdiff
path: root/go/internal/command/fallback/fallback.go
blob: 71e2a98d3c8bd0f522ea31c3a61c37f8abc970eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package fallback

import (
	"os"
	"path/filepath"
	"syscall"

	"gitlab.com/gitlab-org/gitlab-shell/go/internal/command/readwriter"
)

type Command struct {
	RootDir string
	Args    []string
}

var (
	// execFunc is overridden in tests
	execFunc = syscall.Exec
)

const (
	RubyProgram = "gitlab-shell-ruby"
)

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())
}