MCPcopy
hub / github.com/cli/cli / ConfiguredHelper

Method ConfiguredHelper

pkg/cmd/auth/shared/gitcredentials/helper_config.go:92–112  ·  view source on GitHub ↗

ConfiguredHelper returns the configured git credential helper for a given hostname.

(hostname string)

Source from the content-addressed store, hash-verified

90
91// ConfiguredHelper returns the configured git credential helper for a given hostname.
92func (hc *HelperConfig) ConfiguredHelper(hostname string) (Helper, error) {
93 ctx := context.TODO()
94
95 hostHelperCmd, err := hc.GitClient.Config(ctx, keyFor(hostname))
96 if hostHelperCmd != "" {
97 // TODO: This is a direct refactoring removing named and naked returns
98 // but we should probably look closer at the error handling here
99 return Helper{
100 Cmd: hostHelperCmd,
101 }, err
102 }
103
104 globalHelperCmd, err := hc.GitClient.Config(ctx, "credential.helper")
105 if globalHelperCmd != "" {
106 return Helper{
107 Cmd: globalHelperCmd,
108 }, err
109 }
110
111 return Helper{}, nil
112}
113
114func keyFor(hostname string) string {
115 host := strings.TrimSuffix(ghinstance.HostPrefix(hostname), "/")

Callers 1

TestMethod · 0.95

Implementers 2

HelperConfigpkg/cmd/auth/shared/gitcredentials/hel
FakeHelperConfigpkg/cmd/auth/shared/gitcredentials/fak

Calls 2

keyForFunction · 0.85
ConfigMethod · 0.65

Tested by

no test coverage detected