gitindex/index.go: replaced usage of configLookupString
This utility func exists in go-git as a method of Options struct.
Switch to using the provided method instead of custom func to simplify
the code.
Change-Id: I44518f37273ac1e8af5f70175a5261d5a9c81614
diff --git a/gitindex/index.go b/gitindex/index.go
index cacafb5..9680d25 100644
--- a/gitindex/index.go
+++ b/gitindex/index.go
@@ -37,7 +37,6 @@
"github.com/go-git/go-git/v5/plumbing/object"
git "github.com/go-git/go-git/v5"
- plumcfg "github.com/go-git/go-git/v5/plumbing/format/config"
)
// RepoModTime returns the time of last fetch of a git repository.
@@ -178,17 +177,6 @@
return rc.URLs[0]
}
-func configLookupString(sec *plumcfg.Section, key string) string {
- for _, o := range sec.Options {
- if o.Key != key {
- continue
- }
- return o.Value
- }
-
- return ""
-}
-
func isMissingBranchError(err error) bool {
return err != nil && err.Error() == "reference not found"
}
@@ -206,8 +194,8 @@
sec := cfg.Raw.Section("zoekt")
- webURLStr := configLookupString(sec, "web-url")
- webURLType := configLookupString(sec, "web-url-type")
+ webURLStr := sec.Options.Get("web-url")
+ webURLType := sec.Options.Get("web-url-type")
if webURLType != "" && webURLStr != "" {
webURL, err := url.Parse(webURLStr)
@@ -219,7 +207,7 @@
}
}
- name := configLookupString(sec, "name")
+ name := sec.Options.Get("name")
if name != "" {
desc.Name = name
} else {
@@ -248,7 +236,7 @@
// Github:
traction := 0
for _, s := range []string{"github-stars", "github-forks", "github-watchers", "github-subscribers"} {
- f, err := strconv.Atoi(configLookupString(sec, s))
+ f, err := strconv.Atoi(sec.Options.Get(s))
if err == nil {
traction += f
}