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:
authorPavlo Strokov <pstrokov@gitlab.com>2020-11-08 18:24:31 +0300
committerPavlo Strokov <pstrokov@gitlab.com>2020-11-20 13:07:13 +0300
commita874e075ed161671d4eb91a57e0dd4d9b2e4a610 (patch)
treeed5bf9af1edbdf47d954ba27c0c9ef15f2720483 /internal/gitaly/linguist/linguist.go
parent9191f8f0f17d3b7a958424f91527aa8d8b4c3fcb (diff)
Unbound initialization and validation funcs from global Config
In order to remove dependency on the global config.Config var we need to break dependencies between Config and it's initialization and validation functions. Most of them now represented as a methods on the config.Cfg type. It allows us to setup required Cfg struct for the tests to run without need to sync changes done on the shared global Config var. The tests that were heavily dependent on the Config var now depend on the struct initialized inside the test instead. Part of: https://gitlab.com/gitlab-org/gitaly/-/issues/2699 Blocks: https://gitlab.com/gitlab-org/gitaly/-/issues/3166
Diffstat (limited to 'internal/gitaly/linguist/linguist.go')
-rw-r--r--internal/gitaly/linguist/linguist.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/internal/gitaly/linguist/linguist.go b/internal/gitaly/linguist/linguist.go
index 29916e934..9d92e05b7 100644
--- a/internal/gitaly/linguist/linguist.go
+++ b/internal/gitaly/linguist/linguist.go
@@ -63,7 +63,7 @@ func Color(language string) string {
}
// LoadColors loads the name->color map from the Linguist gem.
-func LoadColors(cfg config.Cfg) error {
+func LoadColors(cfg *config.Cfg) error {
jsonReader, err := openLanguagesJSON(cfg)
if err != nil {
return err
@@ -115,7 +115,7 @@ func startGitLinguist(ctx context.Context, repoPath string, commitID string, lin
return internalCmd, nil
}
-func openLanguagesJSON(cfg config.Cfg) (io.ReadCloser, error) {
+func openLanguagesJSON(cfg *config.Cfg) (io.ReadCloser, error) {
if jsonPath := cfg.Ruby.LinguistLanguagesPath; jsonPath != "" {
// This is a fallback for environments where dynamic discovery of the
// linguist path via Bundler is not working for some reason, for example
@@ -137,7 +137,7 @@ func openLanguagesJSON(cfg config.Cfg) (io.ReadCloser, error) {
// on its stdout.
rubyScript := `FileUtils.ln_sf(Bundler.rubygems.find_name('github-linguist').first.full_gem_path, ARGV.first)`
cmd := exec.Command("bundle", "exec", "ruby", "-rfileutils", "-e", rubyScript, linguistPathSymlink.Name())
- cmd.Dir = config.Config.Ruby.Dir
+ cmd.Dir = cfg.Ruby.Dir
// We have learned that in practice the command we are about to run is a
// canary for Ruby/Bundler configuration problems. Including stderr and