Skip to content

Commit 6a8deb1

Browse files
authored
Integrate latest go-gh packages (cli#6084)
1 parent eee1b1c commit 6a8deb1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+189
-1008
lines changed

go.mod

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@ require (
66
github.com/AlecAivazis/survey/v2 v2.3.5
77
github.com/MakeNowJust/heredoc v1.0.0
88
github.com/briandowns/spinner v1.18.1
9-
github.com/charmbracelet/glamour v0.4.0
9+
github.com/charmbracelet/glamour v0.5.0
1010
github.com/charmbracelet/lipgloss v0.5.0
11-
github.com/cli/browser v1.1.0
12-
github.com/cli/go-gh v0.1.0
11+
github.com/cli/go-gh v0.1.1-0.20220817122932-3630ab390fe7
1312
github.com/cli/oauth v0.9.0
1413
github.com/cli/safeexec v1.0.0
1514
github.com/cli/shurcooL-graphql v0.0.1
@@ -22,14 +21,13 @@ require (
2221
github.com/hashicorp/go-multierror v1.1.1
2322
github.com/hashicorp/go-version v1.3.0
2423
github.com/henvic/httpretty v0.0.6
25-
github.com/itchyny/gojq v0.12.8
2624
github.com/joho/godotenv v1.4.0
2725
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51
2826
github.com/mattn/go-colorable v0.1.13
2927
github.com/mattn/go-isatty v0.0.16
3028
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d
3129
github.com/muesli/reflow v0.3.0
32-
github.com/muesli/termenv v0.11.1-0.20220204035834-5ac8409525e0
30+
github.com/muesli/termenv v0.12.0
3331
github.com/muhammadmuzzammil1998/jsonc v0.0.0-20201229145248-615b0916ca38
3432
github.com/opentracing/opentracing-go v1.1.0
3533
github.com/shurcooL/githubv4 v0.0.0-20200928013246-d292edc3691b
@@ -48,17 +46,19 @@ require (
4846
require (
4947
github.com/alecthomas/chroma v0.10.0 // indirect
5048
github.com/aymerick/douceur v0.2.0 // indirect
49+
github.com/cli/browser v1.1.0 // indirect
5150
github.com/davecgh/go-spew v1.1.1 // indirect
5251
github.com/dlclark/regexp2 v1.4.0 // indirect
5352
github.com/fatih/color v1.7.0 // indirect
5453
github.com/golang/protobuf v1.5.2 // indirect
5554
github.com/gorilla/css v1.0.0 // indirect
5655
github.com/hashicorp/errwrap v1.0.0 // indirect
5756
github.com/inconshreveable/mousetrap v1.0.0 // indirect
57+
github.com/itchyny/gojq v0.12.8 // indirect
5858
github.com/itchyny/timefmt-go v0.1.3 // indirect
5959
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
6060
github.com/mattn/go-runewidth v0.0.13 // indirect
61-
github.com/microcosm-cc/bluemonday v1.0.17 // indirect
61+
github.com/microcosm-cc/bluemonday v1.0.19 // indirect
6262
github.com/olekukonko/tablewriter v0.0.5 // indirect
6363
github.com/pmezard/go-difflib v1.0.0 // indirect
6464
github.com/rivo/uniseg v0.2.0 // indirect

go.sum

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd3
4646
github.com/briandowns/spinner v1.18.1 h1:yhQmQtM1zsqFsouh09Bk/jCjd50pC3EOGsh28gLVvwY=
4747
github.com/briandowns/spinner v1.18.1/go.mod h1:mQak9GHqbspjC/5iUx3qMlIho8xBS/ppAL/hX5SmPJU=
4848
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
49-
github.com/charmbracelet/glamour v0.4.0 h1:scR+smyB7WdmrlIaff6IVlm48P48JaNM7JypM/VGl4k=
50-
github.com/charmbracelet/glamour v0.4.0/go.mod h1:9ZRtG19AUIzcTm7FGLGbq3D5WKQ5UyZBbQsMQN0XIqc=
49+
github.com/charmbracelet/glamour v0.5.0 h1:wu15ykPdB7X6chxugG/NNfDUbyyrCLV9XBalj5wdu3g=
50+
github.com/charmbracelet/glamour v0.5.0/go.mod h1:9ZRtG19AUIzcTm7FGLGbq3D5WKQ5UyZBbQsMQN0XIqc=
5151
github.com/charmbracelet/lipgloss v0.5.0 h1:lulQHuVeodSgDez+3rGiuxlPVXSnhth442DATR2/8t8=
5252
github.com/charmbracelet/lipgloss v0.5.0/go.mod h1:EZLha/HbzEt7cYqdFPovlqy5FZPj0xFhg5SaqxScmgs=
5353
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
@@ -58,8 +58,8 @@ github.com/cli/browser v1.1.0 h1:xOZBfkfY9L9vMBgqb1YwRirGu6QFaQ5dP/vXt5ENSOY=
5858
github.com/cli/browser v1.1.0/go.mod h1:HKMQAt9t12kov91Mn7RfZxyJQQgWgyS/3SZswlZ5iTI=
5959
github.com/cli/crypto v0.0.0-20210929142629-6be313f59b03 h1:3f4uHLfWx4/WlnMPXGai03eoWAI+oGHJwr+5OXfxCr8=
6060
github.com/cli/crypto v0.0.0-20210929142629-6be313f59b03/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
61-
github.com/cli/go-gh v0.1.0 h1:kMqFmC3ECBrV2UKzlOHjNOTTchExVc5tjNHtCqk/zYk=
62-
github.com/cli/go-gh v0.1.0/go.mod h1:eTGWl99EMZ+3Iau5C6dHyGAJRRia65MtdBtuhWc+84o=
61+
github.com/cli/go-gh v0.1.1-0.20220817122932-3630ab390fe7 h1:yLnT5/sLlUcnr5njBRmf/d7pEKr0Cu2TpeecdlQl8AY=
62+
github.com/cli/go-gh v0.1.1-0.20220817122932-3630ab390fe7/go.mod h1:UKRuMl3ZaitTvO4LPWj5bVw7QwZHnLu0S0lI9WWbdpc=
6363
github.com/cli/oauth v0.9.0 h1:nxBC0Df4tUzMkqffAB+uZvisOwT3/N9FpkfdTDtafxc=
6464
github.com/cli/oauth v0.9.0/go.mod h1:qd/FX8ZBD6n1sVNQO3aIdRxeu5LGw9WhKnYhIIoC2A4=
6565
github.com/cli/safeexec v1.0.0 h1:0VngyaIyqACHdcMNWfo6+KdUYnqEr2Sg+bSP1pdF+dI=
@@ -199,14 +199,16 @@ github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh
199199
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE=
200200
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d h1:5PJl274Y63IEHC+7izoQE9x6ikvDFZS2mDVS3drnohI=
201201
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE=
202-
github.com/microcosm-cc/bluemonday v1.0.17 h1:Z1a//hgsQ4yjC+8zEkV8IWySkXnsxmdSY642CTFQb5Y=
203202
github.com/microcosm-cc/bluemonday v1.0.17/go.mod h1:Z0r70sCuXHig8YpBzCc5eGHAap2K7e/u082ZUpDRRqM=
203+
github.com/microcosm-cc/bluemonday v1.0.19 h1:OI7hoF5FY4pFz2VA//RN8TfM0YJ2dJcl4P4APrCWy6c=
204+
github.com/microcosm-cc/bluemonday v1.0.19/go.mod h1:QNzV2UbLK2/53oIIwTOyLUSABMkjZ4tqiyC1g/DyqxE=
204205
github.com/muesli/reflow v0.2.1-0.20210115123740-9e1d0d53df68/go.mod h1:Xk+z4oIWdQqJzsxyjgl3P22oYZnHdZ8FFTHAQQt5BMQ=
205206
github.com/muesli/reflow v0.3.0 h1:IFsN6K9NfGtjeggFP+68I4chLZV2yIKsXJFNZ+eWh6s=
206207
github.com/muesli/reflow v0.3.0/go.mod h1:pbwTDkVPibjO2kyvBQRBxTWEEGDGq0FlB1BIKtnHY/8=
207208
github.com/muesli/termenv v0.9.0/go.mod h1:R/LzAKf+suGs4IsO95y7+7DpFHO0KABgnZqtlyx2mBw=
208-
github.com/muesli/termenv v0.11.1-0.20220204035834-5ac8409525e0 h1:STjmj0uFfRryL9fzRA/OupNppeAID6QJYPMavTL7jtY=
209209
github.com/muesli/termenv v0.11.1-0.20220204035834-5ac8409525e0/go.mod h1:Bd5NYQ7pd+SrtBSrSNoBBmXlcY8+Xj4BMJgh8qcZrvs=
210+
github.com/muesli/termenv v0.12.0 h1:KuQRUE3PgxRFWhq4gHvZtPSLCGDqM5q/cYr1pZ39ytc=
211+
github.com/muesli/termenv v0.12.0/go.mod h1:WCCv32tusQ/EEZ5S8oUIIrC/nIuBcxCVqlN4Xfkv+7A=
210212
github.com/muhammadmuzzammil1998/jsonc v0.0.0-20201229145248-615b0916ca38 h1:0FrBxrkJ0hVembTb/e4EU5Ml6vLcOusAqymmYISg5Uo=
211213
github.com/muhammadmuzzammil1998/jsonc v0.0.0-20201229145248-615b0916ca38/go.mod h1:saF2fIVw4banK0H4+/EuqfFLpRnoy5S+ECwTOCcRcSU=
212214
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
@@ -368,6 +370,7 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc
368370
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
369371
golang.org/x/sys v0.0.0-20210831042530-f4d43177bf5e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
370372
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
373+
golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
371374
golang.org/x/sys v0.0.0-20220422013727-9388b58f7150/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
372375
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
373376
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab h1:2QkjZIsXupsJbJIdSjjUOgWK3aEtzyuh2mPt3l/CkeU=

internal/authflow/flow.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import (
1111
"strings"
1212

1313
"github.com/cli/cli/v2/api"
14+
"github.com/cli/cli/v2/internal/browser"
1415
"github.com/cli/cli/v2/internal/ghinstance"
15-
"github.com/cli/cli/v2/pkg/cmdutil"
1616
"github.com/cli/cli/v2/pkg/iostreams"
1717
"github.com/cli/cli/v2/utils"
1818
"github.com/cli/oauth"
@@ -106,8 +106,8 @@ func authFlow(oauthHost string, IO *iostreams.IOStreams, notice string, addition
106106
fmt.Fprintf(w, "%s to open %s in your browser... ", cs.Bold("Press Enter"), oauthHost)
107107
_ = waitForEnter(IO.In)
108108

109-
browser := cmdutil.NewBrowser(browserLauncher, IO.Out, IO.ErrOut)
110-
if err := browser.Browse(authURL); err != nil {
109+
b := browser.New(browserLauncher, IO.Out, IO.ErrOut)
110+
if err := b.Browse(authURL); err != nil {
111111
fmt.Fprintf(w, "%s Failed opening a web browser at %s\n", cs.Red("!"), authURL)
112112
fmt.Fprintf(w, " %s\n", err)
113113
fmt.Fprint(w, " Please try entering the URL in your browser manually\n")

internal/browser/browser.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package browser
2+
3+
import (
4+
"io"
5+
6+
ghBrowser "github.com/cli/go-gh/pkg/browser"
7+
)
8+
9+
type Browser interface {
10+
Browse(string) error
11+
}
12+
13+
func New(launcher string, stdout, stderr io.Writer) Browser {
14+
b := ghBrowser.New(launcher, stdout, stderr)
15+
return &b
16+
}

internal/browser/stub.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package browser
2+
3+
type Stub struct {
4+
urls []string
5+
}
6+
7+
func (b *Stub) Browse(url string) error {
8+
b.urls = append(b.urls, url)
9+
return nil
10+
}
11+
12+
func (b *Stub) BrowsedURL() string {
13+
if len(b.urls) > 0 {
14+
return b.urls[0]
15+
}
16+
return ""
17+
}
18+
19+
type _testing interface {
20+
Errorf(string, ...interface{})
21+
Helper()
22+
}
23+
24+
func (b *Stub) Verify(t _testing, url string) {
25+
t.Helper()
26+
if url != "" {
27+
switch len(b.urls) {
28+
case 0:
29+
t.Errorf("expected browser to open URL %q, but it was never invoked", url)
30+
case 1:
31+
if url != b.urls[0] {
32+
t.Errorf("expected browser to open URL %q, got %q", url, b.urls[0])
33+
}
34+
default:
35+
t.Errorf("expected browser to open one URL, but was invoked %d times", len(b.urls))
36+
}
37+
} else if len(b.urls) > 0 {
38+
t.Errorf("expected no browser to open, but was invoked %d times: %v", len(b.urls), b.urls)
39+
}
40+
}

pkg/cmd/api/api.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ import (
2020
"github.com/cli/cli/v2/internal/ghrepo"
2121
"github.com/cli/cli/v2/pkg/cmd/factory"
2222
"github.com/cli/cli/v2/pkg/cmdutil"
23-
"github.com/cli/cli/v2/pkg/export"
2423
"github.com/cli/cli/v2/pkg/iostreams"
2524
"github.com/cli/cli/v2/pkg/jsoncolor"
25+
"github.com/cli/go-gh/pkg/jq"
26+
"github.com/cli/go-gh/pkg/template"
2627
"github.com/spf13/cobra"
2728
)
2829

@@ -297,7 +298,11 @@ func apiRun(opts *ApiOptions) error {
297298
host = opts.Hostname
298299
}
299300

300-
template := export.NewTemplate(opts.IO, opts.Template)
301+
tmpl := template.New(bodyWriter, opts.IO.TerminalWidth(), opts.IO.ColorEnabled())
302+
err = tmpl.Parse(opts.Template)
303+
if err != nil {
304+
return err
305+
}
301306

302307
hasNextPage := true
303308
for hasNextPage {
@@ -306,7 +311,7 @@ func apiRun(opts *ApiOptions) error {
306311
return err
307312
}
308313

309-
endCursor, err := processResponse(resp, opts, bodyWriter, headersWriter, &template)
314+
endCursor, err := processResponse(resp, opts, bodyWriter, headersWriter, &tmpl)
310315
if err != nil {
311316
return err
312317
}
@@ -330,10 +335,10 @@ func apiRun(opts *ApiOptions) error {
330335
}
331336
}
332337

333-
return template.End()
338+
return tmpl.Flush()
334339
}
335340

336-
func processResponse(resp *http.Response, opts *ApiOptions, bodyWriter, headersWriter io.Writer, template *export.Template) (endCursor string, err error) {
341+
func processResponse(resp *http.Response, opts *ApiOptions, bodyWriter, headersWriter io.Writer, template *template.Template) (endCursor string, err error) {
337342
if opts.ShowResponseHeaders {
338343
fmt.Fprintln(headersWriter, resp.Proto, resp.Status)
339344
printHeaders(headersWriter, resp.Header, opts.IO.ColorEnabled())
@@ -365,13 +370,12 @@ func processResponse(resp *http.Response, opts *ApiOptions, bodyWriter, headersW
365370

366371
if opts.FilterOutput != "" && serverError == "" {
367372
// TODO: reuse parsed query across pagination invocations
368-
err = export.FilterJSON(bodyWriter, responseBody, opts.FilterOutput)
373+
err = jq.Evaluate(responseBody, bodyWriter, opts.FilterOutput)
369374
if err != nil {
370375
return
371376
}
372377
} else if opts.Template != "" && serverError == "" {
373-
// TODO: reuse parsed template across pagination invocations
374-
err = template.Execute(bodyWriter, responseBody)
378+
err = template.Execute(responseBody)
375379
if err != nil {
376380
return
377381
}

pkg/cmd/api/api_test.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ import (
1717
"github.com/cli/cli/v2/internal/config"
1818
"github.com/cli/cli/v2/internal/ghrepo"
1919
"github.com/cli/cli/v2/pkg/cmdutil"
20-
"github.com/cli/cli/v2/pkg/export"
2120
"github.com/cli/cli/v2/pkg/iostreams"
21+
"github.com/cli/go-gh/pkg/template"
2222
"github.com/google/shlex"
2323
"github.com/stretchr/testify/assert"
2424
"github.com/stretchr/testify/require"
@@ -1298,11 +1298,13 @@ func Test_processResponse_template(t *testing.T) {
12981298
IO: ios,
12991299
Template: `{{range .}}{{.title}} ({{.labels | pluck "name" | join ", " }}){{"\n"}}{{end}}`,
13001300
}
1301-
template := export.NewTemplate(ios, opts.Template)
1302-
_, err := processResponse(&resp, &opts, ios.Out, io.Discard, &template)
1303-
require.NoError(t, err)
13041301

1305-
err = template.End()
1302+
tmpl := template.New(ios.Out, ios.TerminalWidth(), ios.ColorEnabled())
1303+
err := tmpl.Parse(opts.Template)
1304+
require.NoError(t, err)
1305+
_, err = processResponse(&resp, &opts, ios.Out, io.Discard, &tmpl)
1306+
require.NoError(t, err)
1307+
err = tmpl.Flush()
13061308
require.NoError(t, err)
13071309

13081310
assert.Equal(t, heredoc.Doc(`

pkg/cmd/browse/browse.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,17 @@ import (
1313
"github.com/MakeNowJust/heredoc"
1414
"github.com/cli/cli/v2/api"
1515
"github.com/cli/cli/v2/git"
16+
"github.com/cli/cli/v2/internal/browser"
1617
"github.com/cli/cli/v2/internal/ghrepo"
1718
"github.com/cli/cli/v2/pkg/cmdutil"
1819
"github.com/cli/cli/v2/pkg/iostreams"
1920
"github.com/cli/cli/v2/utils"
2021
"github.com/spf13/cobra"
2122
)
2223

23-
type browser interface {
24-
Browse(string) error
25-
}
26-
2724
type BrowseOptions struct {
2825
BaseRepo func() (ghrepo.Interface, error)
29-
Browser browser
26+
Browser browser.Browser
3027
HttpClient func() (*http.Client, error)
3128
IO *iostreams.IOStreams
3229
PathFromRepoRoot func() string

pkg/cmd/browse/browse_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"testing"
1010

1111
"github.com/cli/cli/v2/git"
12+
"github.com/cli/cli/v2/internal/browser"
1213
"github.com/cli/cli/v2/internal/ghrepo"
1314
"github.com/cli/cli/v2/pkg/cmdutil"
1415
"github.com/cli/cli/v2/pkg/httpmock"
@@ -448,7 +449,7 @@ func Test_runBrowse(t *testing.T) {
448449
for _, tt := range tests {
449450
t.Run(tt.name, func(t *testing.T) {
450451
ios, _, stdout, stderr := iostreams.Test()
451-
browser := cmdutil.TestBrowser{}
452+
browser := browser.Stub{}
452453

453454
reg := httpmock.Registry{}
454455
defer reg.Verify(t)

pkg/cmd/codespace/code_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import (
44
"context"
55
"testing"
66

7+
"github.com/cli/cli/v2/internal/browser"
78
"github.com/cli/cli/v2/internal/codespaces/api"
8-
"github.com/cli/cli/v2/pkg/cmdutil"
99
"github.com/cli/cli/v2/pkg/iostreams"
1010
)
1111

@@ -62,7 +62,7 @@ func TestApp_VSCode(t *testing.T) {
6262
}
6363
for _, tt := range tests {
6464
t.Run(tt.name, func(t *testing.T) {
65-
b := &cmdutil.TestBrowser{}
65+
b := &browser.Stub{}
6666
ios, _, stdout, stderr := iostreams.Test()
6767
a := &App{
6868
browser: b,

pkg/cmd/codespace/common.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313

1414
"github.com/AlecAivazis/survey/v2"
1515
"github.com/AlecAivazis/survey/v2/terminal"
16+
"github.com/cli/cli/v2/internal/browser"
1617
"github.com/cli/cli/v2/internal/codespaces"
1718
"github.com/cli/cli/v2/internal/codespaces/api"
1819
"github.com/cli/cli/v2/pkg/iostreams"
@@ -22,10 +23,6 @@ import (
2223
"golang.org/x/term"
2324
)
2425

25-
type browser interface {
26-
Browse(string) error
27-
}
28-
2926
type executable interface {
3027
Executable() string
3128
}
@@ -35,10 +32,10 @@ type App struct {
3532
apiClient apiClient
3633
errLogger *log.Logger
3734
executable executable
38-
browser browser
35+
browser browser.Browser
3936
}
4037

41-
func NewApp(io *iostreams.IOStreams, exe executable, apiClient apiClient, browser browser) *App {
38+
func NewApp(io *iostreams.IOStreams, exe executable, apiClient apiClient, browser browser.Browser) *App {
4239
errLogger := log.New(io.ErrOut, "", 0)
4340

4441
return &App{

pkg/cmd/factory/default.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"github.com/cli/cli/v2/api"
1111
"github.com/cli/cli/v2/context"
1212
"github.com/cli/cli/v2/git"
13+
"github.com/cli/cli/v2/internal/browser"
1314
"github.com/cli/cli/v2/internal/config"
1415
"github.com/cli/cli/v2/internal/ghrepo"
1516
"github.com/cli/cli/v2/internal/prompter"
@@ -33,7 +34,7 @@ func New(appVersion string) *cmdutil.Factory {
3334
f.Remotes = remotesFunc(f) // Depends on Config
3435
f.BaseRepo = BaseRepoFunc(f) // Depends on Remotes
3536
f.Prompter = newPrompter(f) // Depends on Config and IOStreams
36-
f.Browser = browser(f) // Depends on Config, and IOStreams
37+
f.Browser = newBrowser(f) // Depends on Config, and IOStreams
3738
f.ExtensionManager = extensionManager(f) // Depends on Config, HttpClient, and IOStreams
3839

3940
return f
@@ -105,9 +106,9 @@ func httpClientFunc(f *cmdutil.Factory, appVersion string) func() (*http.Client,
105106
}
106107
}
107108

108-
func browser(f *cmdutil.Factory) cmdutil.Browser {
109+
func newBrowser(f *cmdutil.Factory) browser.Browser {
109110
io := f.IOStreams
110-
return cmdutil.NewBrowser(browserLauncher(f), io.Out, io.ErrOut)
111+
return browser.New(browserLauncher(f), io.Out, io.ErrOut)
111112
}
112113

113114
func newPrompter(f *cmdutil.Factory) prompter.Prompter {

0 commit comments

Comments
 (0)