summaryrefslogtreecommitdiff
path: root/go/internal/command/fallback/fallback.go
blob: f525a57f92ced83da9328bc8586c5e38176181a8 (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
package fallback

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

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