Remove GetOrDefault uses in favour of GitProtocol
This commit is contained in:
parent
7d8c1af009
commit
6dc04bb1e2
7 changed files with 10 additions and 33 deletions
|
|
@ -176,6 +176,7 @@ func (c *AuthConfig) GitProtocol(hostname string) string {
|
|||
|
||||
// This should not happen, as we know there is a default value for this key.
|
||||
// Perhaps it says something about our current default abstraction being not quite right?
|
||||
// The defaults are also currently used to provide information about the config options.
|
||||
return ""
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -80,10 +80,7 @@ func cloneRun(opts *CloneOptions) error {
|
|||
return err
|
||||
}
|
||||
hostname, _ := cfg.Authentication().DefaultHost()
|
||||
protocol, err := cfg.GetOrDefault(hostname, "git_protocol")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
protocol := cfg.Authentication().GitProtocol(hostname)
|
||||
gistURL = formatRemoteURL(hostname, gistURL, protocol)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ func checkoutRun(opts *CheckoutOptions) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
protocol, _ := cfg.GetOrDefault(baseRepo.RepoHost(), "git_protocol")
|
||||
protocol := cfg.Authentication().GitProtocol(baseRepo.RepoHost())
|
||||
|
||||
remotes, err := opts.Remotes()
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -761,7 +761,7 @@ func handlePush(opts CreateOptions, ctx CreateContext) error {
|
|||
return err
|
||||
}
|
||||
|
||||
cloneProtocol, _ := cfg.GetOrDefault(headRepo.RepoHost(), "git_protocol")
|
||||
cloneProtocol := cfg.Authentication().GitProtocol(headRepo.RepoHost())
|
||||
headRepoURL := ghrepo.FormatRemoteURL(headRepo, cloneProtocol)
|
||||
gitClient := ctx.GitClient
|
||||
origin, _ := remotes.FindByName("origin")
|
||||
|
|
|
|||
|
|
@ -129,10 +129,7 @@ func cloneRun(opts *CloneOptions) error {
|
|||
return err
|
||||
}
|
||||
|
||||
protocol, err = cfg.GetOrDefault(repo.RepoHost(), "git_protocol")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
protocol = cfg.Authentication().GitProtocol(repo.RepoHost())
|
||||
}
|
||||
|
||||
wantsWiki := strings.HasSuffix(repo.RepoName(), ".wiki")
|
||||
|
|
@ -166,10 +163,7 @@ func cloneRun(opts *CloneOptions) error {
|
|||
|
||||
// If the repo is a fork, add the parent as an upstream remote and set the parent as the default repo.
|
||||
if canonicalRepo.Parent != nil {
|
||||
protocol, err := cfg.GetOrDefault(canonicalRepo.Parent.RepoHost(), "git_protocol")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
protocol := cfg.Authentication().GitProtocol(canonicalRepo.Parent.RepoHost())
|
||||
upstreamURL := ghrepo.FormatRemoteURL(canonicalRepo.Parent, protocol)
|
||||
|
||||
upstreamName := opts.UpstreamName
|
||||
|
|
|
|||
|
|
@ -395,11 +395,7 @@ func createFromScratch(opts *CreateOptions) error {
|
|||
}
|
||||
|
||||
if opts.Clone {
|
||||
protocol, err := cfg.GetOrDefault(repo.RepoHost(), "git_protocol")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
protocol := cfg.Authentication().GitProtocol(repo.RepoHost())
|
||||
remoteURL := ghrepo.FormatRemoteURL(repo, protocol)
|
||||
|
||||
if !opts.AddReadme && opts.LicenseTemplate == "" && opts.GitIgnoreTemplate == "" && opts.Template == "" {
|
||||
|
|
@ -496,11 +492,7 @@ func createFromTemplate(opts *CreateOptions) error {
|
|||
}
|
||||
|
||||
if opts.Clone {
|
||||
protocol, err := cfg.GetOrDefault(repo.RepoHost(), "git_protocol")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
protocol := cfg.Authentication().GitProtocol(repo.RepoHost())
|
||||
remoteURL := ghrepo.FormatRemoteURL(repo, protocol)
|
||||
|
||||
if err := cloneWithRetry(opts, remoteURL, templateRepoMainBranch); err != nil {
|
||||
|
|
@ -622,11 +614,7 @@ func createFromLocal(opts *CreateOptions) error {
|
|||
fmt.Fprintln(stdout, repo.URL)
|
||||
}
|
||||
|
||||
protocol, err := cfg.GetOrDefault(repo.RepoHost(), "git_protocol")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
protocol := cfg.Authentication().GitProtocol(repo.RepoHost())
|
||||
remoteURL := ghrepo.FormatRemoteURL(repo, protocol)
|
||||
|
||||
if opts.Interactive {
|
||||
|
|
|
|||
|
|
@ -149,10 +149,7 @@ func updateRemote(repo ghrepo.Interface, renamed ghrepo.Interface, opts *RenameO
|
|||
return nil, err
|
||||
}
|
||||
|
||||
protocol, err := cfg.GetOrDefault(repo.RepoHost(), "git_protocol")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
protocol := cfg.Authentication().GitProtocol(repo.RepoHost())
|
||||
|
||||
remotes, err := opts.Remotes()
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue