Skip to content

Commit c911f7d

Browse files
committed
fix merge issues
1 parent e413ad0 commit c911f7d

2 files changed

Lines changed: 7 additions & 41 deletions

File tree

cmd/src/login.go

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66
"io"
77
"net/url"
8+
"os"
89

910
"github.com/sourcegraph/src-cli/internal/api"
1011
"github.com/sourcegraph/src-cli/internal/clicompat"
@@ -42,10 +43,14 @@ var loginCommand = clicompat.Wrap(&cli.Command{
4243
HideVersion: true,
4344
Flags: clicompat.WithAPIFlags(),
4445
Action: func(ctx context.Context, cmd *cli.Command) error {
45-
var loginEndpointURL *url.URL
46+
if cfg.configFilePath != "" {
47+
fmt.Fprintln(os.Stderr)
48+
fmt.Fprintf(os.Stderr, "⚠️ Warning: Configuring src with a JSON file is deprecated. Please migrate to using the env vars SRC_ENDPOINT, SRC_ACCESS_TOKEN, and SRC_PROXY instead, and then remove %s. See https://github.com/sourcegraph/src-cli#readme for more information.\n", cfg.configFilePath)
49+
}
50+
4651
if cmd.Args().Present() {
4752
arg := cmd.Args().First()
48-
u, err := parseEndpoint(arg)
53+
loginEndpointURL, err := parseEndpoint(arg)
4954
if err != nil {
5055
return cmderrors.Usage(fmt.Sprintf("invalid endpoint URL: %s", arg))
5156
}
@@ -76,13 +81,6 @@ var loginCommand = clicompat.Wrap(&cli.Command{
7681
out: os.Stdout,
7782
apiFlags: apiFlags,
7883
oauthClient: oauth.NewClient(oauth.DefaultClientID),
79-
return loginCmd(context.Background(), loginParams{
80-
cfg: cfg,
81-
client: client,
82-
out: os.Stdout,
83-
apiFlags: apiFlags,
84-
oauthClient: oauth.NewClient(oauth.DefaultClientID),
85-
loginEndpointURL: loginEndpointURL,
8684
})
8785
},
8886
})

cmd/src/login_test.go

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import (
1414

1515
"github.com/sourcegraph/src-cli/internal/cmderrors"
1616
"github.com/sourcegraph/src-cli/internal/oauth"
17-
"github.com/urfave/cli/v3"
1817
)
1918

2019
func mustParseURL(t *testing.T, raw string) *url.URL {
@@ -140,37 +139,6 @@ func TestLogin(t *testing.T) {
140139
})
141140
}
142141

143-
func TestLoginCommand(t *testing.T) {
144-
prevCfg := cfg
145-
defer func() { cfg = prevCfg }()
146-
147-
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
148-
fmt.Fprintln(w, `{"data":{"currentUser":{"username":"alice"}}}`)
149-
}))
150-
defer s.Close()
151-
152-
cfg = &config{
153-
endpointURL: mustParseURL(t, s.URL),
154-
accessToken: "x",
155-
}
156-
157-
var out bytes.Buffer
158-
cmd := *loginCommand
159-
cmd.Writer = &out
160-
cmd.ErrWriter = &out
161-
cmd.ExitErrHandler = func(context.Context, *cli.Command, error) {}
162-
163-
err := cmd.Run(context.Background(), []string{"login", s.URL})
164-
if err != nil {
165-
t.Fatal(err)
166-
}
167-
168-
want := "\n✔︎ Authenticated as alice on " + s.URL + "\n\n\n💡 Tip: To use this endpoint in your shell, run:\n\n export SRC_ENDPOINT=" + s.URL + "\n\n"
169-
if out.String() != want {
170-
t.Fatalf("output = %q, want %q", out.String(), want)
171-
}
172-
}
173-
174142
type fakeOAuthClient struct {
175143
startErr error
176144
startCalled *bool

0 commit comments

Comments
 (0)