diff options
author | Alejandro Rodríguez <alejorro70@gmail.com> | 2017-06-02 21:16:42 +0300 |
---|---|---|
committer | Alejandro Rodríguez <alejorro70@gmail.com> | 2017-07-12 01:07:49 +0300 |
commit | bd1d3a30d8ae89725d84cc080fca2a1be2cbc29d (patch) | |
tree | 9c3fc60a94d0d8fd40e7dd718149a23e6664e38b /internal/helper | |
parent | e60a7c09ce99099390011dce7ca3e8cb3938ab7a (diff) |
Add config to specify a git binary path
Diffstat (limited to 'internal/helper')
-rw-r--r-- | internal/helper/command.go | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/internal/helper/command.go b/internal/helper/command.go index d66eed92a..48d8e8b43 100644 --- a/internal/helper/command.go +++ b/internal/helper/command.go @@ -6,6 +6,10 @@ import ( "os" "os/exec" "syscall" + + "gitlab.com/gitlab-org/gitaly/internal/config" + + log "github.com/Sirupsen/logrus" ) // Command encapsulates operations with commands creates with NewCommand @@ -14,6 +18,20 @@ type Command struct { *exec.Cmd } +// GitPath returns the path to the `git` binary. See `SetGitPath` for details +// on how this is set +func GitPath() string { + if config.Config.Git.BinPath == "" { + // This shouldn't happen outside of testing, SetGitPath should be called by + // main.go to ensure correctness of the configuration on start-up. + if err := config.SetGitPath(); err != nil { + log.Fatal(err) // Bail out. + } + } + + return config.Config.Git.BinPath +} + // Kill cleans the subprocess group of the command. Callers should defer a call // to kill after they get the command from NewCommand func (c *Command) Kill() { @@ -22,7 +40,7 @@ func (c *Command) Kill() { // GitCommandReader creates a git Command with the given args func GitCommandReader(args ...string) (*Command, error) { - return NewCommand(exec.Command("git", args...), nil, nil, nil) + return NewCommand(exec.Command(GitPath(), args...), nil, nil, nil) } // NewCommand creates a Command from an exec.Cmd |