Skip to content

Commit 0fc9dfa

Browse files
committed
refactor: code cleanup incorporating the PR suggestions and removed blank lines
1 parent 0cef66d commit 0fc9dfa

File tree

2 files changed

+6
-15
lines changed

2 files changed

+6
-15
lines changed

command/repo.go

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -386,20 +386,16 @@ var Confirm = func(prompt string, result *bool) error {
386386

387387
func repoView(cmd *cobra.Command, args []string) error {
388388
ctx := contextForCommand(cmd)
389-
390-
var openURL string
391389
var toView ghrepo.Interface
392390
if len(args) == 0 {
393-
baseRepo, err := determineBaseRepo(cmd, ctx)
391+
var err error
392+
toView, err = determineBaseRepo(cmd, ctx)
394393
if err != nil {
395394
return err
396395
}
397-
openURL = fmt.Sprintf("https://github.com/%s", ghrepo.FullName(baseRepo))
398-
toView = baseRepo
399396
} else {
400397
repoArg := args[0]
401398
if isURL(repoArg) {
402-
openURL = repoArg
403399
parsedURL, err := url.Parse(repoArg)
404400
if err != nil {
405401
return fmt.Errorf("did not understand argument: %w", err)
@@ -411,23 +407,19 @@ func repoView(cmd *cobra.Command, args []string) error {
411407
}
412408
} else {
413409
toView = ghrepo.FromFullName(repoArg)
414-
openURL = fmt.Sprintf("https://github.com/%s", repoArg)
415410
}
416411
}
417412

418413
apiClient, err := apiClientForContext(ctx)
419-
420414
if err != nil {
421415
return err
422416
}
423-
424-
_, err_message := api.GitHubRepo(apiClient, toView)
425-
if err_message != nil {
426-
return err_message
417+
_, err = api.GitHubRepo(apiClient, toView)
418+
if err != nil {
419+
return err
427420
}
428421

422+
openURL := fmt.Sprintf("https://github.com/%s", ghrepo.FullName(toView))
429423
fmt.Fprintf(cmd.ErrOrStderr(), "Opening %s in your browser.\n", displayURL(openURL))
430424
return utils.OpenInBrowser(openURL)
431-
432-
433425
}

command/repo_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,6 @@ func TestRepoView(t *testing.T) {
610610
eq(t, url, "https://github.com/OWNER/REPO")
611611
}
612612

613-
614613
func TestRepoView_ownerRepo(t *testing.T) {
615614
ctx := context.NewBlank()
616615
ctx.SetBranch("master")

0 commit comments

Comments
 (0)