Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clone - simplify complexity of getting hostStr #2987

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
clone - simplify complexity of getting hostStr
The usage of `host` variable could be limited by one if-block.
Also since error is checked from `config.DefaultHost()` we could assume that `host` is not nil anymore.
  • Loading branch information
vkd committed Jul 10, 2022
commit a39086cb250fdfa2502d825c4881706009690339
9 changes: 2 additions & 7 deletions commands/clone.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,20 +103,15 @@ func getCloneURL(nameWithOwner string, allowPush, allowPrivate bool) string {
name = split[1]
}

var host *github.Host
var hostStr string
if owner == "" {
config := github.CurrentConfig()
h, err := config.DefaultHost()
host, err := config.DefaultHost()
if err != nil {
utils.Check(github.FormatError("cloning repository", err))
}

host = h
owner = host.User
}

var hostStr string
if host != nil {
hostStr = host.Host
}

Expand Down