Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Vosmaer (GitLab) <jacob@gitlab.com>2017-09-12 04:17:29 +0300
committerAlejandro Rodríguez <alejorro70@gmail.com>2017-09-12 04:17:29 +0300
commit3f252917972bf7ea6a408ea321d71be270d73a07 (patch)
tree29a730b232642d83aeac2df0d7088c3df5fcb401 /internal/linguist
parent83ad765bf65cc77734c610761f8e480b11ec0730 (diff)
Don't use 'bundle show' to find Linguist
Diffstat (limited to 'internal/linguist')
-rw-r--r--internal/linguist/linguist.go23
1 files changed, 18 insertions, 5 deletions
diff --git a/internal/linguist/linguist.go b/internal/linguist/linguist.go
index 0a0359626..64598373f 100644
--- a/internal/linguist/linguist.go
+++ b/internal/linguist/linguist.go
@@ -9,7 +9,6 @@ import (
"os"
"os/exec"
"path"
- "strings"
"gitlab.com/gitlab-org/gitaly/internal/command"
"gitlab.com/gitlab-org/gitaly/internal/config"
@@ -54,17 +53,31 @@ func Color(language string) string {
// LoadColors loads the name->color map from the Linguist gem.
func LoadColors() error {
- cmd := exec.Command("bundle", "show", "linguist")
- cmd.Dir = config.Config.Ruby.Dir
- linguistPath, err := cmd.Output()
+ tempFile, err := ioutil.TempFile("", "gitaly-linguist")
if err != nil {
+ return err
+ }
+ defer os.Remove(tempFile.Name())
+
+ if err := tempFile.Close(); err != nil {
+ return err
+ }
+
+ // Replace the tempfile with a symlink to the directory where
+ // github-linguist is installed. We don't write the path to stdout
+ // because Bundler sometimes writes garbage to stdout.
+ rubyScript := `FileUtils.ln_sf(Bundler.rubygems.find_name('github-linguist').first.full_gem_path, ARGV.first)`
+ cmd := exec.Command("bundle", "exec", "ruby", "-r", "fileutils", "-e", rubyScript, tempFile.Name())
+ cmd.Dir = config.Config.Ruby.Dir
+
+ if err := cmd.Run(); err != nil {
if exitError, ok := err.(*exec.ExitError); ok {
err = fmt.Errorf("%v; stderr: %q", exitError, exitError.Stderr)
}
return err
}
- languageJSON, err := ioutil.ReadFile(path.Join(strings.TrimSpace(string(linguistPath)), "lib/linguist/languages.json"))
+ languageJSON, err := ioutil.ReadFile(path.Join(tempFile.Name(), "lib/linguist/languages.json"))
if err != nil {
return err
}