refactor: code cleanup incorporating the PR suggestions and removed blank lines
This commit is contained in:
parent
0cef66dc67
commit
0fc9dfac37
2 changed files with 7 additions and 16 deletions
|
|
@ -386,20 +386,16 @@ var Confirm = func(prompt string, result *bool) error {
|
|||
|
||||
func repoView(cmd *cobra.Command, args []string) error {
|
||||
ctx := contextForCommand(cmd)
|
||||
|
||||
var openURL string
|
||||
var toView ghrepo.Interface
|
||||
if len(args) == 0 {
|
||||
baseRepo, err := determineBaseRepo(cmd, ctx)
|
||||
var err error
|
||||
toView, err = determineBaseRepo(cmd, ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
openURL = fmt.Sprintf("https://github.com/%s", ghrepo.FullName(baseRepo))
|
||||
toView = baseRepo
|
||||
} else {
|
||||
repoArg := args[0]
|
||||
if isURL(repoArg) {
|
||||
openURL = repoArg
|
||||
parsedURL, err := url.Parse(repoArg)
|
||||
if err != nil {
|
||||
return fmt.Errorf("did not understand argument: %w", err)
|
||||
|
|
@ -411,23 +407,19 @@ func repoView(cmd *cobra.Command, args []string) error {
|
|||
}
|
||||
} else {
|
||||
toView = ghrepo.FromFullName(repoArg)
|
||||
openURL = fmt.Sprintf("https://github.com/%s", repoArg)
|
||||
}
|
||||
}
|
||||
|
||||
apiClient, err := apiClientForContext(ctx)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = api.GitHubRepo(apiClient, toView)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err_message := api.GitHubRepo(apiClient, toView)
|
||||
if err_message != nil {
|
||||
return err_message
|
||||
}
|
||||
|
||||
openURL := fmt.Sprintf("https://github.com/%s", ghrepo.FullName(toView))
|
||||
fmt.Fprintf(cmd.ErrOrStderr(), "Opening %s in your browser.\n", displayURL(openURL))
|
||||
return utils.OpenInBrowser(openURL)
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -610,7 +610,6 @@ func TestRepoView(t *testing.T) {
|
|||
eq(t, url, "https://github.com/OWNER/REPO")
|
||||
}
|
||||
|
||||
|
||||
func TestRepoView_ownerRepo(t *testing.T) {
|
||||
ctx := context.NewBlank()
|
||||
ctx.SetBranch("master")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue