Skip to content
Merged
Show file tree
Hide file tree
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
12 changes: 10 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,22 @@ All notable changes to `src-cli` are documented in this file.

### Changed

### Fixed

- The src login command now also properly respects the `-insecure-skip-verify` flag.

### Removed

## 3.25.2

### Changed

Comment on lines +18 to +27
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, shit. Thanks.

- The volume workspace Docker image is now only pulled if the volume workspace mode is in use. [#477](https://github.com/sourcegraph/src-cli/pull/477)

### Fixed

- Using volume workspace mode could result in Git errors when used with Docker containers that do not run as root. These have been fixed. [#478](https://github.com/sourcegraph/src-cli/issues/478)

### Removed

## 3.25.1

### Added
Expand Down
18 changes: 13 additions & 5 deletions cmd/src/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"io/ioutil"
"os"
"strings"

"github.com/sourcegraph/src-cli/internal/api"
)

func init() {
Expand All @@ -32,21 +34,28 @@ Examples:
flagSet := flag.NewFlagSet("login", flag.ExitOnError)
usageFunc := func() {
fmt.Fprintln(flag.CommandLine.Output(), usage)
flagSet.PrintDefaults()
}

var (
apiFlags = api.NewFlags(flagSet)
)

handler := func(args []string) error {
if err := flagSet.Parse(args); err != nil {
return err
}
endpoint := cfg.Endpoint
if len(args) == 1 {
endpoint = args[0]
if flagSet.NArg() >= 1 {
endpoint = flagSet.Arg(0)
}
if endpoint == "" {
return &usageError{errors.New("expected exactly one argument: the Sourcegraph URL, or SRC_ENDPOINT to be set")}
}

return loginCmd(context.Background(), cfg, endpoint, os.Stdout)
client := cfg.apiClient(apiFlags, ioutil.Discard)

return loginCmd(context.Background(), cfg, client, endpoint, os.Stdout)
}

commands = append(commands, &command{
Expand All @@ -58,7 +67,7 @@ Examples:

var exitCode1 = &exitCodeError{exitCode: 1}

func loginCmd(ctx context.Context, cfg *config, endpointArg string, out io.Writer) error {
func loginCmd(ctx context.Context, cfg *config, client api.Client, endpointArg string, out io.Writer) error {
endpointArg = cleanEndpoint(endpointArg)

printProblem := func(problem string) {
Expand Down Expand Up @@ -97,7 +106,6 @@ func loginCmd(ctx context.Context, cfg *config, endpointArg string, out io.Write
var result struct {
CurrentUser *struct{ Username string }
}
client := cfg.apiClient(nil, ioutil.Discard)
if _, err := client.NewRequest(query, nil).Do(ctx, &result); err != nil {
if strings.HasPrefix(err.Error(), "error: 401 Unauthorized") || strings.HasPrefix(err.Error(), "error: 403 Forbidden") {
printProblem("Invalid access token.")
Expand Down
3 changes: 2 additions & 1 deletion cmd/src/login_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"context"
"fmt"
"io/ioutil"
"net/http"
"net/http/httptest"
"strings"
Expand All @@ -15,7 +16,7 @@ func TestLogin(t *testing.T) {
t.Helper()

var out bytes.Buffer
err = loginCmd(context.Background(), cfg, endpointArg, &out)
err = loginCmd(context.Background(), cfg, cfg.apiClient(nil, ioutil.Discard), endpointArg, &out)
return strings.TrimSpace(out.String()), err
}

Expand Down