add GetOrDefault functionality to config

This commit is contained in:
nate smith 2022-01-11 14:56:58 -06:00
parent eaa64df801
commit 562f1b3d0d
33 changed files with 116 additions and 58 deletions

View file

@ -83,7 +83,7 @@ func (rr *remoteResolver) Resolver() func() (context.Remotes, error) {
dummyHostname := "example.com" // any non-github.com hostname is fine here
if config.IsHostEnv(src) {
return nil, fmt.Errorf("none of the git remotes configured for this repository correspond to the %s environment variable. Try adding a matching remote or unsetting the variable.", src)
} else if v, src, _ := cfg.GetWithSource(dummyHostname, "oauth_token"); v != "" && config.IsEnterpriseEnv(src) {
} else if v, src, _ := cfg.GetOrDefaultWithSource(dummyHostname, "oauth_token"); v != "" && config.IsEnterpriseEnv(src) {
return nil, errors.New("set the GH_HOST environment variable to specify which GitHub host to use")
}
return nil, errors.New("none of the git remotes configured for this repository point to a known GitHub host. To tell gh about a new GitHub host, please use `gh auth login`")