### Build and install src-cli Source: https://github.com/sourcegraph/src-cli/blob/main/DEVELOPMENT.md Instructions to clone the repository and build/install the src-cli using go install. ```bash cd src-cli/ go install ./cmd/src ``` -------------------------------- ### Install src-cli on Linux (Version Compatible with Instance) Source: https://github.com/sourcegraph/src-cli/blob/main/README.md Installs a version of src-cli compatible with a specific Sourcegraph instance using curl. ```bash curl -L https://sourcegraph.example.com/.api/src-cli/src_linux_amd64 -o /usr/local/bin/src chmod +x /usr/local/bin/src ``` -------------------------------- ### Install src-cli on Mac OS using Homebrew Source: https://github.com/sourcegraph/src-cli/blob/main/README.md Installs the src-cli on macOS using Homebrew. ```bash brew install sourcegraph/src-cli/src-cli ``` -------------------------------- ### Run src-cli directly Source: https://github.com/sourcegraph/src-cli/blob/main/DEVELOPMENT.md How to run the src-cli directly using go run without installation. ```bash go run ./cmd/src ``` -------------------------------- ### Install Version Compatible with Sourcegraph Instance via PowerShell Source: https://github.com/sourcegraph/src-cli/blob/main/WINDOWS.md Installs a version of the Sourcegraph CLI compatible with a specific Sourcegraph instance by creating a directory, downloading the executable from the instance URL, and updating the system PATH environment variable. ```powershell New-Item -ItemType Directory 'C:\Program Files\Sourcegraph' Invoke-WebRequest https://sourcegraph.example.com/.api/src-cli/src_windows_amd64.exe -OutFile 'C:\Program Files\Sourcegraph\src.exe' [Environment]::SetEnvironmentVariable('Path', [Environment]::GetEnvironmentVariable('Path', [EnvironmentVariableTarget]::Machine) + ';C:\Program Files\Sourcegraph', [EnvironmentVariableTarget]::Machine) $env:Path += ';C:\Program Files\Sourcegraph' ``` -------------------------------- ### Diff Output Example Source: https://github.com/sourcegraph/src-cli/blob/main/cmd/src/testdata/search_formatting/basic-diff.want.txt This snippet shows the expected output format for a diff in a test case, including error messages and token comparisons. ```go + t. [38;5;0m [48;5;11mError [0mf("got invalid token: %v", tok) + } + if got, want := tok.AccessToken, ""; got != want { + t. [38;5;0m [48;5;11mError [0mf("access token = %q; want %q", got, want) + } + if got, want := tok.TokenType, "Bearer"; got != want { @@ -0,0 +116,5 @@ + if err == nil { + t. [38;5;0m [48;5;11mError [0m("got a token; expected [38;5;0m [48;5;11merror [0m") + if got, want := tok.AccessToken, ""; got != want { + t. [38;5;0m [48;5;11mError [0mf("access token = %q; want %q", got, want) + } ``` -------------------------------- ### Install src-cli on Linux (Latest Version) Source: https://github.com/sourcegraph/src-cli/blob/main/README.md Installs the latest version of the src-cli on Linux using curl and sets execute permissions. ```bash curl -L https://sourcegraph.com/.api/src-cli/src_linux_amd64 -o /usr/local/bin/src chmod +x /usr/local/bin/src ``` -------------------------------- ### Install Latest Version via PowerShell Source: https://github.com/sourcegraph/src-cli/blob/main/WINDOWS.md Installs the latest version of the Sourcegraph CLI by creating a directory, downloading the executable, and updating the system PATH environment variable. ```powershell New-Item -ItemType Directory 'C:\Program Files\Sourcegraph' Invoke-WebRequest https://sourcegraph.com/.api/src-cli/src_windows_amd64.exe -OutFile 'C:\Program Files\Sourcegraph\src.exe' [Environment]::SetEnvironmentVariable('Path', [Environment]::GetEnvironmentVariable('Path', [EnvironmentVariableTarget]::Machine) + ';C:\Program Files\Sourcegraph', [EnvironmentVariableTarget]::Machine) $env:Path += ';C:\Program Files\Sourcegraph' ``` -------------------------------- ### Supplying headers via SRC_HEADER_* environment variables Source: https://github.com/sourcegraph/src-cli/blob/main/AUTH_PROXY.md This example shows how to supply authorization and extra headers using SRC_HEADER_* environment variables. The headers are constructed by calling an external service. ```shell SRC_HEADER_AUTHORIZATION="Bearer $(curl http://service.internal.corp)" SRC_HEADER_EXTRA=metadata src search 'foobar' ``` -------------------------------- ### Install src-cli on Mac OS using npm Source: https://github.com/sourcegraph/src-cli/blob/main/README.md Installs the src-cli on macOS using npm. ```bash npm install -g @sourcegraph/src ``` -------------------------------- ### Install src-cli on Mac OS (Version Compatible with Instance) Source: https://github.com/sourcegraph/src-cli/blob/main/README.md Installs a version of src-cli compatible with a specific Sourcegraph instance using curl. ```bash curl -L https://sourcegraph.example.com/.api/src-cli/src_darwin_amd64 -o /usr/local/bin/src chmod +x /usr/local/bin/src ``` -------------------------------- ### Install src-cli using Docker Source: https://github.com/sourcegraph/src-cli/blob/main/README.md Runs the latest version of the src-cli using Docker to perform a search. ```bash docker run --rm=true sourcegraph/src-cli:latest search 'hello world' ``` -------------------------------- ### Install src-cli on Mac OS (Specific Version with Homebrew) Source: https://github.com/sourcegraph/src-cli/blob/main/README.md Installs a specific version of src-cli on macOS using Homebrew. ```bash brew install sourcegraph/src-cli/src-cli@3.43.2 ``` -------------------------------- ### Install src-cli on Mac OS (Specific Version with npm/npx) Source: https://github.com/sourcegraph/src-cli/blob/main/README.md Installs and runs a specific version of src-cli on macOS using npm/npx. ```bash npx @sourcegraph/src@3.43.2 version ``` -------------------------------- ### Install src-cli on Mac OS (Latest Version) Source: https://github.com/sourcegraph/src-cli/blob/main/README.md Installs the latest version of the src-cli on macOS using curl and sets execute permissions. ```bash curl -L https://sourcegraph.com/.api/src-cli/src_darwin_amd64 -o /usr/local/bin/src chmod +x /usr/local/bin/src ``` -------------------------------- ### Supplying multiple headers via SRC_HEADERS environment variable Source: https://github.com/sourcegraph/src-cli/blob/main/AUTH_PROXY.md This example demonstrates using the SRC_HEADERS environment variable to pass multiple headers, including those with dashes, separated by newlines. ```shell SRC_HEADERS="AUTHORIZATION:Bearer somerandom_string\nClient-ID:client-one\nextra:metadata" ``` -------------------------------- ### Check brew formula version Source: https://github.com/sourcegraph/src-cli/blob/main/DEVELOPMENT.md Command to check the installed version of src-cli via Homebrew. ```shell brew info sourcegraph/src-cli/src-cli ``` -------------------------------- ### Test the entire src tool Source: https://github.com/sourcegraph/src-cli/blob/main/DEVELOPMENT.md Command to run the entire test suite for the src tool using Go's testing patterns. ```bash go test ./... ``` -------------------------------- ### Code Snippet from clientcredentials_test.go Source: https://github.com/sourcegraph/src-cli/blob/main/cmd/src/testdata/search_formatting/basic.want.txt This snippet shows lines of code from the clientcredentials_test.go file, demonstrating mock transport and error reporting in tests. ```go rt func(req *http.Request) (resp *http.Response, err error) ``` ```go func (t *mockTransport) RoundTrip(req *http.Request) (resp *http.Response, err error) { ``` ```go t.Errorf("authenticate client request URL = %q; want %q", r.URL, "/token") ``` ```go t.Error("Unexpected authorization header, %v is found.", headerAuth) ``` ```go t.Error("Content-Type header = %q; want %q", got, want) ``` ```go t.Error("failed reading request body: %s.", err) ``` ```go t.Error("payload = %q; want %q", string(body), "grant_type=client_credentials&scope=scope1+scope2") ``` ```go t.Error(err) ``` ```go t.Error("Access token = %q; want %q", tok.AccessToken, "90d64460d14870c08c81352a05dedd3465940a7c") ``` ```go t.Error("token type = %q; want %q", tok.TokenType, "bearer") ``` ```go t.Error("Unexpected token refresh request URL, %v is found.", r.URL) ``` ```go t.Error("Unexpected Content-Type header, %v is found.", headerContentType) ``` ```go t.Error("Unexpected refresh token payload, %v is found.", string(body)) ``` -------------------------------- ### Test a single package Source: https://github.com/sourcegraph/src-cli/blob/main/DEVELOPMENT.md Command to run tests for a specific package within the src tool. ```bash go test ./internal/batches/workspace ``` -------------------------------- ### Build Bazel targets for checksum verification Source: https://github.com/sourcegraph/src-cli/blob/main/DEVELOPMENT.md Command to build src-cli targets for different platforms to obtain checksums for updating tool_deps.bzl. ```shell $ bazel build @src-cli-linux-amd64//:src-cli-linux-amd64 \ @src-cli-darwin-amd64//:src-cli-darwin-amd64 \ @src-cli-darwin-arm64//:src-cli-darwin-arm64 ``` -------------------------------- ### Diff in google/appengine.go and google/appengine_gen1.go Source: https://github.com/sourcegraph/src-cli/blob/main/cmd/src/testdata/search_formatting/basic-diff-new.want.txt Shows changes related to App Engine token source implementation, including removal of code in appengine.go and addition in appengine_gen1.go. ```diff [38;5;239m-------------------------------------------------------------------------------- [0m [38;5;239m( [0m [38;5;237mhttps://sourcegraph.com/github.com/golang/oauth2/-/commit/5a69e67f3fa6ce11b512c271912d08ac74da7c7f [0m [38;5;239m) [0m [0m [38;5;68mgolang/oauth2 Michael Traver appengine: implement AppEngineTokenSource for 2nd gen runtimes [0m [38;5;239m-------------------------------------------------------------------------------- [0m [38;5;239m [0m google/appengine.go google/appengine.go @@ -61,3 +37,0 @@ func AppEngineTokenSource(ctx context.Context, scope ...string) oauth2.TokenSour - -func (ts *appEngineTokenSource) Token() (*oauth2.Token, [38;5;0m [48;5;11merror [0m) { - ifif appengineTokenFunc == nil { google/appengine_gen1.go google/appengine_gen1.go @@ -0,0 +53,3 @@ + +func (ts *gaeTokenSource) Token() (*oauth2.Token, [38;5;0m [48;5;11merror [0m) { + aeTokensMu.Lock() ``` -------------------------------- ### Code Snippet from clientcredentials.go Source: https://github.com/sourcegraph/src-cli/blob/main/cmd/src/testdata/search_formatting/basic.want.txt This snippet shows lines of code from the clientcredentials.go file, highlighting error handling and function definitions. ```go func (c *Config) Token(ctx context.Context) (*oauth2.Token, error) { ``` ```go func (c *tokenSource) Token() (*oauth2.Token, error) { ``` ```go return nil, fmt.Error("oauth2: cannot overwrite parameter %q", k) ``` ```go if rErr, ok := err.(*internal.RetrieveError); ok { ``` ```go return nil, (*oauth2.RetrieveError)(rErr) ``` -------------------------------- ### Build local Docker image Source: https://github.com/sourcegraph/src-cli/blob/main/DEVELOPMENT.md Builds a local Docker image of src-cli for testing purposes. ```bash docker build -t local-src-cli . ``` -------------------------------- ### Run local Docker image Source: https://github.com/sourcegraph/src-cli/blob/main/DEVELOPMENT.md Runs the locally built Docker image of src-cli to verify its help output. ```bash docker run --rm local-src-cli ``` -------------------------------- ### Manual smoke test script Source: https://github.com/sourcegraph/src-cli/blob/main/DEVELOPMENT.md Script for quick end-to-end CLI sanity checks against a live Sourcegraph instance. ```bash ./dev/smoke.sh ``` -------------------------------- ### Diff in google/default.go Source: https://github.com/sourcegraph/src-cli/blob/main/cmd/src/testdata/search_formatting/basic-diff-new.want.txt Shows changes in the google/default.go file, including function signature updates and comments. ```diff [38;5;239m-------------------------------------------------------------------------------- [0m [38;5;239m( [0m [38;5;237mhttps://sourcegraph.com/github.com/golang/oauth2/-/commit/232e45548389bd9357411a6922a07c5fd4068bda [0m [38;5;239m) [0m [0m [38;5;68mgolang/oauth2 Brad Fitzpatrick google: remove Go 1.8 support [0m [38;5;239m-------------------------------------------------------------------------------- [0m [38;5;239m [0m google/default.go google/default.go @@ -42,2 +61,1 @@ func DefaultTokenSource(ctx context.Context, scope ...string) (oauth2.TokenSourc -// Common implementation for FindDefaultCredentials. -func findDefaultCredentials(ctx context.Context, scopes []string) (*DefaultCredentials, [38;5;0m [48;5;11merror [0m) { +// FindDefaultCredentials searches for "Application Default Credentials". @@ -44,0 +76,2 @@ func DefaultTokenSource(ctx context.Context, scope ...string) (oauth2.TokenSourc +// (In this final case any provided scopes are ignored.) +func FindDefaultCredentials(ctx context.Context, scopes ...string) (*Credentials, [38;5;0m [48;5;11merror [0m) { @@ -87,2 +121,1 @@ func findDefaultCredentials(ctx context.Context, scopes []string) (*DefaultCrede -// Common implementation for CredentialsFromJSON. -func credentialsFromJSON(ctx context.Context, jsonData []byte, scopes []string) (*DefaultCredentials, [38;5;0m [48;5;11merror [0m) { +// CredentialsFromJSON obtains Google credentials from a JSON value. The JSON can google/go19.go google/go19.go @@ -49,3 +0,0 @@ -// (In this final case any provided scopes are ignored.) -func FindDefaultCredentials(ctx context.Context, scopes ...string) (*Credentials, [38;5;0m [48;5;11merror [0m) { - return findDefaultCredentials(ctx, scopes) @@ -57,3 +0,0 @@ -// JWTConfigFromJSON). -func CredentialsFromJSON(ctx context.Context, jsonData []byte, scopes ...string) (*Credentials, [38;5;0m [48;5;11merror [0m) { - return credentialsFromJSON(ctx, jsonData, scopes) google/not_go19.go google/not_go19.go @@ -44,3 +0,0 @@ -// (In this final case any provided scopes are ignored.) -func FindDefaultCredentials(ctx context.Context, scopes ...string) (*DefaultCredentials, [38;5;0m [48;5;11merror [0m) { - return findDefaultCredentials(ctx, scopes) @@ -54,3 +0,0 @@ -// Note: despite the name, the returned credentials may not be Application Default Credentials. -func CredentialsFromJSON(ctx context.Context, jsonData []byte, scopes ...string) (*DefaultCredentials, [38;5;0m [48;5;11merror [0m) { - return credentialsFromJSON(ctx, jsonData, scopes) ``` -------------------------------- ### Release script execution Source: https://github.com/sourcegraph/src-cli/blob/main/DEVELOPMENT.md Command to execute the release script for a specific version. ```shell VERSION=9.9.9 ./release.sh ``` -------------------------------- ### WriteObject method in fileStore Source: https://github.com/sourcegraph/src-cli/blob/main/cmd/src/testdata/search_formatting/highlight-structural-search.want.txt Implementation of WriteObject for fileStore, marshaling an object to YAML and writing it to a file. ```go func (f *fileStore) WriteObject(fileName string, object interface{}) error { y, err := yaml.Marshal(object) if err != nil { return errors.Wrapf(err, "unable to marshal object to yaml: %v", object) } return f.Write(fileName, y) } ``` -------------------------------- ### Log into Sourcegraph instance with src-cli Source: https://github.com/sourcegraph/src-cli/blob/main/README.md Logs into a Sourcegraph instance using the src login command. ```bash src login https://sourcegraph.example.com ``` -------------------------------- ### Configuration: Inline Environment Variables Source: https://github.com/sourcegraph/src-cli/blob/main/README.md Sets environment variables inline for a single src command execution. ```bash SRC_ENDPOINT=https://sourcegraph.example.com SRC_ACCESS_TOKEN=my-token src search 'foo' ``` -------------------------------- ### Build and tag dependent Docker image Source: https://github.com/sourcegraph/src-cli/blob/main/DEVELOPMENT.md Builds and tags the sourcegraph/src-batch-change-volume-workspace Docker image locally. ```bash docker build -t sourcegraph/src-batch-change-volume-workspace - < docker/batch-change-volume-workspace/Dockerfile ``` -------------------------------- ### Build src-cli with debug tag Source: https://github.com/sourcegraph/src-cli/blob/main/DEVELOPMENT.md Compiling the src binary with the 'debug' build flag to include internal/batches/debug.go for debugging batch changes functionality. ```bash go build -tags debug -o ~/src ./cmd/src ``` -------------------------------- ### Sourcegraph Search Results - stream.go (6 matches) Source: https://github.com/sourcegraph/src-cli/blob/main/cmd/src/testdata/search_formatting/highlight-bug.want.txt This snippet shows search results from Sourcegraph for the file 'stream.go' within the 'jsonrpc2/websocket' path, highlighting function definitions and error handling related to WebSocket closures. ```go func (t ObjectStream) WriteObject(obj interface{}) error { ``` ```go func (t ObjectStream) ReadObject(v interface{}) error { ``` ```go if e, ok := err.(*websocket.CloseError); ok { ``` ```go if e.Code == websocket.CloseAbnormalClosure && e.Text == io.ErrUnexpectedEOF.Error() { ``` ```go // unwrapping this error. ``` -------------------------------- ### Configuration: Mac OS / Linux Environment Variables Source: https://github.com/sourcegraph/src-cli/blob/main/README.md Sets environment variables for SRC_ACCESS_TOKEN and SRC_ENDPOINT in the terminal profile file. ```bash export SRC_ACCESS_TOKEN=my-token export SRC_ENDPOINT=https://sourcegraph.example.com ``` -------------------------------- ### Sourcegraph Search Results - stream.go (14 matches) Source: https://github.com/sourcegraph/src-cli/blob/main/cmd/src/testdata/search_formatting/highlight-bug.want.txt This snippet shows search results from Sourcegraph for the file 'stream.go' within the 'jsonrpc2' repository, highlighting lines that contain function definitions and error returns. ```go func (t *bufferedObjectStream) WriteObject(obj interface{}) error { ``` ```go func (t *bufferedObjectStream) ReadObject(v interface{}) error { ``` ```go func (t *bufferedObjectStream) Close() error { ``` ```go WriteObject(stream io.Writer, obj interface{}) error ``` ```go ReadObject(stream *bufio.Reader, v interface{}) error ``` ```go func (VarintObjectCodec) WriteObject(stream io.Writer, obj interface{}) error { ``` ```go func (VarintObjectCodec) ReadObject(stream *bufio.Reader, v interface{}) error { ``` ```go func (VSCodeObjectCodec) WriteObject(stream io.Writer, obj interface{}) error { ``` ```go func (VSCodeObjectCodec) ReadObject(stream *bufio.Reader, v interface{}) error { ``` ```go return fmt.Error(`jsonrpc2: line endings must be \r\n`) ``` ```go var err error ``` ```go return fmt.Error("jsonrpc2: no Content-Length header found") ``` -------------------------------- ### Check npm package version Source: https://github.com/sourcegraph/src-cli/blob/main/DEVELOPMENT.md Command to check the version of the src-cli npm package. ```shell npm show @sourcegraph/src version ``` -------------------------------- ### Diff in internal/oauth2.go Source: https://github.com/sourcegraph/src-cli/blob/main/cmd/src/testdata/search_formatting/basic-diff-new.want.txt Highlights a minor typo correction in an error message within the internal/oauth2.go file. ```diff [38;5;239m-------------------------------------------------------------------------------- [0m [38;5;239m( [0m [38;5;237mhttps://sourcegraph.com/github.com/golang/oauth2/-/commit/8527f56f71077909d6ead7facfe18fbf05ebdf83 [0m [38;5;239m) [0m [0m [38;5;68mgolang/oauth2 Travis Bischel oauth2: fix error message typo [0m [38;5;239m-------------------------------------------------------------------------------- [0m [38;5;239m [0m internal/oauth2.go internal/oauth2.go @@ -29,1 +29,1 @@ func ParseKey(key []byte) (*rsa.PrivateKey, error) { - return nil, fmt. [38;5;0m [48;5;11mError [0mf("private key should be a PEM or plain PKSC1 or PKCS8; parse [38;5;0m [48;5;11merror [0m: %v", err) + return nil, fmt. [38;5;0m [48;5;11mError [0mf("private key should be a PEM or plain PKCS1 or PKCS8; parse [38;5;0m [48;5;11merror [0m: %v", err) ``` -------------------------------- ### Windows PowerShell Configuration Source: https://github.com/sourcegraph/src-cli/blob/main/README.md Sets Sourcegraph endpoint and access token environment variables in PowerShell. ```powershell $env:SRC_ENDPOINT = 'https://sourcegraph.example.com' $env:SRC_ACCESS_TOKEN = 'my-token' ``` -------------------------------- ### WriteObject method in vaultStore Source: https://github.com/sourcegraph/src-cli/blob/main/cmd/src/testdata/search_formatting/highlight-structural-search.want.txt Implementation of WriteObject for vaultStore, marshaling an object to YAML and writing it to Vault. ```go func (v *vaultStore) WriteObject(name string, object interface{}) error { y, err := yaml.Marshal(object) if err != nil { return errors.Wrapf(err, "unable to marshal object to yaml: %v", object) } _, err = v.client.WriteYaml(v.secretPath(name), string(y)) if err != nil { return errors.Wrapf(err, "writing the %q secret in YAMl format to vault", name) } return nil } ``` -------------------------------- ### Update vendored packages Source: https://github.com/sourcegraph/src-cli/blob/main/lib/README.md To update the vendored lib packages, run the following script. ```bash ./dev/vendor-lib.sh ``` -------------------------------- ### Diff in jira/jira.go and jira/jira_test.go Source: https://github.com/sourcegraph/src-cli/blob/main/cmd/src/testdata/search_formatting/basic-diff.want.txt This snippet shows diffs in jira/jira.go and jira/jira_test.go, related to JWT token generation and validation for Jira provider. ```diff diff --git jira/jira.go jira/jira.go new file mode 100644 index 0000000..e8021e9 --- /dev/null +++ jira/jira.go @@ -0,0 +79,3 @@ + +func (js jwtSource) Token() (*oauth2.Token, [38;5;0m [48;5;11merror [0m) { + exp := time.Duration(59) * time.Second @@ -0,0 +113,3 @@ + if err != nil { + return nil, fmt. [38;5;0m [48;5;11mError [0mf("oauth2: cannot fetch token: %v", err) + } @@ -0,0 +118,6 @@ + if err != nil { + return nil, fmt. [38;5;0m [48;5;11mError [0mf("oauth2: cannot fetch token: %v", err) +\t} + if c := resp.StatusCode; c < 200 || c > 299 { + return nil, fmt. [38;5;0m [48;5;11mError [0mf("oauth2: cannot fetch token: %v\nResponse: %s", resp.Status, body) +\t} diff --git jira/jira_test.go jira/jira_test.go new file mode 100644 index 0000000..c49940d --- /dev/null +++ jira/jira_test.go @@ -0,0 +49,7 @@ ... +2 + if !tok.Valid() { + t. [38;5;0m [48;5;11mError [0mf("got invalid token: %v", tok) +\t} +\tif got, want := tok.AccessToken, "90d64460d14870c08c81352a05dedd3465940a7c"; got != want { + t. [38;5;0m [48;5;11mError [0mf("access token = %q; want %q", got, want) +\t} + if got, want := tok.TokenType, "Bearer"; got != want { @@ -0,0 +86,7 @@ ... +1 + if tok.Valid() { ``` -------------------------------- ### Diff in oauth2.go and oauth2_test.go Source: https://github.com/sourcegraph/src-cli/blob/main/cmd/src/testdata/search_formatting/basic-diff.want.txt This snippet shows diffs in oauth2.go and oauth2_test.go, related to custom parameters in Exchange and authorization header checks. ```diff diff --git oauth2.go oauth2.go index 10299d2..16775d0 100644 --- oauth2.go +++ oauth2.go @@ -189,1 +191,1 @@ func (c *Config) PasswordCredentialsToken(ctx context.Context, username, passwor -func (c *Config) Exchange(ctx context.Context, code string) (*Token, [38;5;0m [48;5;11merror [0m) { +// @@ -190,0 +193,2 @@ func (c *Config) PasswordCredentialsToken(ctx context.Context, username, passwor +// See https://www.oauth.com/oauth2-servers/pkce/ for more info. +func (c *Config) Exchange(ctx context.Context, code string, opts ...AuthCodeOption) (*Token, [38;5;0m [48;5;11merror [0m) { diff --git oauth2_test.go oauth2_test.go index 847160f..ef12ebc 100644 --- oauth2_test.go +++ oauth2_test.go @@ -137,0 +140,3 @@ func TestExchangeRequest(t *testing.T) { + if r.URL.String() != "/token" { + t. [38;5;0m [48;5;11mError [0mf("Unexpected exchange request URL, %v is found.", r.URL) + } @@ -137,0 +144,3 @@ func TestExchangeRequest(t *testing.T) { + if headerAuth != "Basic Q0xJRU5UX0lEOkNMSUVOVF9TRUNSRVQ=" { + t. [38;5;0m [48;5;11mError [0mf("Unexpected authorization header, %v is found.", headerAuth) + } @@ -137,0 +148,3 @@ func TestExchangeRequest(t *testing.T) { + if headerContentType != "application/x-www-form-urlencoded" { + t. [38;5;0m [48;5;11mError [0mf("Unexpected Content-Type header, %v is found.", headerContentType) + } ``` -------------------------------- ### Renaming src binary on Linux/macOS Source: https://github.com/sourcegraph/src-cli/blob/main/README.md Renames the 'src' binary to 'src-cli' to avoid naming conflicts. ```bash mv /usr/local/bin/src /usr/local/bin/src-cli ``` -------------------------------- ### Remove local dependent Docker image Source: https://github.com/sourcegraph/src-cli/blob/main/DEVELOPMENT.md Removes the locally built sourcegraph/src-batch-change-volume-workspace Docker image to force the use of the upstream image. ```bash docker rmi sourcegraph/src-batch-change-volume-workspace ``` -------------------------------- ### Diff in transport_test.go Source: https://github.com/sourcegraph/src-cli/blob/main/cmd/src/testdata/search_formatting/basic-diff.want.txt This snippet shows a diff in the transport_test.go file, related to error handling and closing request bodies. ```diff diff --git transport_test.go transport_test.go index d6e8087..faa87d5 100644 --- transport_test.go +++ transport_test.go @@ -3,0 +4,2 @@ import ( + " [38;5;0m [48;5;11merror [0ms" + "io" @@ -29,0 +33,6 @@ func TestTransportNilTokenSource(t *testing.T) { + CloseCount int + ReadErr [38;5;0m [48;5;11merror [0m +} + + unc (r *readCloseCounter) Read(b []byte) (int, [38;5;0m [48;5;11merror [0m) { + return 0, r.ReadErr @@ -29,0 +40,3 @@ func TestTransportNilTokenSource(t *testing.T) { + + unc (r *readCloseCounter) Close() [38;5;0m [48;5;11merror [0m { + r.CloseCount++ ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.