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 <jacob@gitlab.com>2019-08-19 21:41:23 +0300
committerPaul Okstad <pokstad@gitlab.com>2019-08-19 21:41:23 +0300
commit292a78410114da3511bc676386921636d08c6e8f (patch)
tree14df10ebcc76988fd008b60b340f00a50a8e5a2a /internal/linguist
parentb10c2f83e5598b17d4985e277f607149627b5052 (diff)
Prevent lazy config lookups in tempdir cleaners
Diffstat (limited to 'internal/linguist')
-rw-r--r--internal/linguist/linguist.go8
-rw-r--r--internal/linguist/linguist_test.go4
2 files changed, 6 insertions, 6 deletions
diff --git a/internal/linguist/linguist.go b/internal/linguist/linguist.go
index 8ce217e4c..3b215fd9a 100644
--- a/internal/linguist/linguist.go
+++ b/internal/linguist/linguist.go
@@ -57,8 +57,8 @@ func Color(language string) string {
}
// LoadColors loads the name->color map from the Linguist gem.
-func LoadColors() error {
- jsonReader, err := openLanguagesJSON()
+func LoadColors(cfg config.Cfg) error {
+ jsonReader, err := openLanguagesJSON(cfg)
if err != nil {
return err
}
@@ -67,8 +67,8 @@ func LoadColors() error {
return json.NewDecoder(jsonReader).Decode(&colorMap)
}
-func openLanguagesJSON() (io.ReadCloser, error) {
- if jsonPath := config.Config.Ruby.LinguistLanguagesPath; jsonPath != "" {
+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
// https://gitlab.com/gitlab-org/gitaly/issues/1119.
diff --git a/internal/linguist/linguist_test.go b/internal/linguist/linguist_test.go
index 8522c6f45..93c3e8b2b 100644
--- a/internal/linguist/linguist_test.go
+++ b/internal/linguist/linguist_test.go
@@ -11,7 +11,7 @@ import (
func TestLoadLanguages(t *testing.T) {
colorMap = make(map[string]Language)
- require.NoError(t, LoadColors(), "load colors")
+ require.NoError(t, LoadColors(config.Config), "load colors")
require.Equal(t, "#701516", Color("Ruby"), "color value for 'Ruby'")
}
@@ -23,7 +23,7 @@ func TestLoadLanguagesCustomPath(t *testing.T) {
config.Config.Ruby.LinguistLanguagesPath = jsonPath
colorMap = make(map[string]Language)
- require.NoError(t, LoadColors(), "load colors")
+ require.NoError(t, LoadColors(config.Config), "load colors")
require.Equal(t, "foo color", Color("FooBar"))
}