Skip to content
Draft
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
1 change: 1 addition & 0 deletions builds.json

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion cmd/src/code_intel_upload_vendored.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ func uploadMultipartIndexParts(ctx context.Context, httpClient upload.Client, op
}

for i, reader := range readers {
i, reader := i, reader

pool.Go(func(ctx context.Context) error {
// Determine size of this reader. If we're not the last reader in the slice,
Expand Down
2 changes: 0 additions & 2 deletions cmd/src/snapshot_upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,6 @@ func uploadFilesToBucket(client *gcsClient, args *uploadArgs, openedFiles []uplo
// Upload each file in parallel
for fileIndex, openedFile := range openedFiles {

openedFile := openedFile

uploadPool.Go(func(ctx context.Context) error {
progressFn := func(bytesWritten int64) { progress.SetValue(fileIndex, float64(bytesWritten)) }

Expand Down
14 changes: 8 additions & 6 deletions internal/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"net/url"
"os"
"runtime"
"strings"

ioaux "github.com/jig/teereadcloser"
"github.com/kballard/go-shellquote"
Expand Down Expand Up @@ -371,18 +372,19 @@
return "", err
}

s := "curl \\\n"
var s strings.Builder
s.WriteString("curl \\\n")
if r.client.opts.AccessToken != "" {
s += fmt.Sprintf(" %s \\\n", shellquote.Join("-H", "Authorization: token "+r.client.opts.AccessToken))
s.WriteString(fmt.Sprintf(" %s \\\n", shellquote.Join("-H", "Authorization: token "+r.client.opts.AccessToken)))

Check failure on line 378 in internal/api/api.go

View workflow job for this annotation

GitHub Actions / go-lint

QF1012: Use fmt.Fprintf(...) instead of WriteString(fmt.Sprintf(...)) (staticcheck)
}
// Preserve overrides if Content-Type is set
if r.client.opts.AdditionalHeaders["Content-Type"] == "" {
r.client.opts.AdditionalHeaders["Content-Type"] = "application/json"
}
for k, v := range r.client.opts.AdditionalHeaders {
s += fmt.Sprintf(" %s \\\n", shellquote.Join("-H", k+": "+v))
s.WriteString(fmt.Sprintf(" %s \\\n", shellquote.Join("-H", k+": "+v)))

Check failure on line 385 in internal/api/api.go

View workflow job for this annotation

GitHub Actions / go-lint

QF1012: Use fmt.Fprintf(...) instead of WriteString(fmt.Sprintf(...)) (staticcheck)
}
s += fmt.Sprintf(" %s \\\n", shellquote.Join("-d", string(data)))
s += fmt.Sprintf(" %s", shellquote.Join(r.client.opts.EndpointURL.JoinPath(".api/graphql").String()))
return s, nil
s.WriteString(fmt.Sprintf(" %s \\\n", shellquote.Join("-d", string(data))))

Check failure on line 387 in internal/api/api.go

View workflow job for this annotation

GitHub Actions / go-lint

QF1012: Use fmt.Fprintf(...) instead of WriteString(fmt.Sprintf(...)) (staticcheck)
s.WriteString(fmt.Sprintf(" %s", shellquote.Join(r.client.opts.EndpointURL.JoinPath(".api/graphql").String())))
return s.String(), nil
}
43 changes: 22 additions & 21 deletions internal/api/proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,10 +266,10 @@
insecure := true
flags := &Flags{
insecureSkipVerify: &insecure,
dump: boolPtr(false),
getCurl: boolPtr(false),
trace: boolPtr(false),
userAgentTelemetry: boolPtr(false),
dump: new(false),
getCurl: new(false),
trace: new(false),
userAgentTelemetry: new(false),
}
opts := ClientOpts{
ProxyURL: proxyURL,
Expand All @@ -296,10 +296,10 @@
insecure := true
flags := &Flags{
insecureSkipVerify: &insecure,
dump: boolPtr(false),
getCurl: boolPtr(false),
trace: boolPtr(false),
userAgentTelemetry: boolPtr(false),
dump: new(false),
getCurl: new(false),
trace: new(false),
userAgentTelemetry: new(false),
}
opts := ClientOpts{
ProxyPath: socketPath,
Expand All @@ -324,10 +324,10 @@
insecure := true
flags := &Flags{
insecureSkipVerify: &insecure,
dump: boolPtr(false),
getCurl: boolPtr(false),
trace: boolPtr(false),
userAgentTelemetry: boolPtr(false),
dump: new(false),
getCurl: new(false),
trace: new(false),
userAgentTelemetry: new(false),
}
opts := ClientOpts{} // no ProxyURL or ProxyPath

Expand All @@ -353,10 +353,10 @@
insecure := true
flags := &Flags{
insecureSkipVerify: &insecure,
dump: boolPtr(false),
getCurl: boolPtr(false),
trace: boolPtr(false),
userAgentTelemetry: boolPtr(false),
dump: new(false),
getCurl: new(false),
trace: new(false),
userAgentTelemetry: new(false),
}
opts := ClientOpts{} // no ProxyURL or ProxyPath

Expand Down Expand Up @@ -386,10 +386,10 @@
insecure := true
flags := &Flags{
insecureSkipVerify: &insecure,
dump: boolPtr(false),
getCurl: boolPtr(false),
trace: boolPtr(false),
userAgentTelemetry: boolPtr(false),
dump: new(false),
getCurl: new(false),
trace: new(false),
userAgentTelemetry: new(false),
}
opts := ClientOpts{
ProxyURL: proxyURL,
Expand All @@ -404,4 +404,5 @@
}
}

func boolPtr(b bool) *bool { return &b }
//go:fix inline
func boolPtr(b bool) *bool { return new(b) }

Check failure on line 408 in internal/api/proxy_test.go

View workflow job for this annotation

GitHub Actions / go-lint

func boolPtr is unused (unused)
6 changes: 2 additions & 4 deletions internal/api/test_unix_socket_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ func StartUnixSocketServer(socketPath string) (*Server, error) {
StopChan: make(chan struct{}),
}

server.Wg.Add(1)
go func() {
defer server.Wg.Done()
server.Wg.Go(func() {
for {
conn, err := server.Listener.Accept()
if err != nil {
Expand Down Expand Up @@ -96,7 +94,7 @@ func StartUnixSocketServer(socketPath string) (*Server, error) {
}
}(conn)
}
}()
})

return server, nil
}
Expand Down
6 changes: 2 additions & 4 deletions internal/batches/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,9 +337,7 @@ func (svc *Service) EnsureDockerImages(
}
var wg sync.WaitGroup
for i := 0; i < parallelism; i++ {
wg.Add(1)
go func() {
defer wg.Done()
wg.Go(func() {
for {
select {
case <-workerCtx.Done():
Expand All @@ -363,7 +361,7 @@ func (svc *Service) EnsureDockerImages(
}
}
}
}()
})
}

go func() {
Expand Down
14 changes: 7 additions & 7 deletions internal/streaming/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ func (rr Decoder) ReadAll(r io.Reader) error {
// event: $event\n
// data: json($data)\n\n
data := scanner.Bytes()
nl := bytes.Index(data, []byte("\n"))
if nl < 0 {
before, after, ok := bytes.Cut(data, []byte("\n"))
if !ok {
return fmt.Errorf("malformed event, no newline: %s", data)
}

eventK, event := splitColon(data[:nl])
dataK, data := splitColon(data[nl+1:])
eventK, event := splitColon(before)
dataK, data := splitColon(after)

if !bytes.Equal(eventK, []byte("event")) {
return fmt.Errorf("malformed event, expected event: %s", eventK)
Expand Down Expand Up @@ -137,11 +137,11 @@ func (rr Decoder) ReadAll(r io.Reader) error {
}

func splitColon(data []byte) ([]byte, []byte) {
i := bytes.Index(data, []byte(":"))
if i < 0 {
before, after, ok := bytes.Cut(data, []byte(":"))
if !ok {
return bytes.TrimSpace(data), nil
}
return bytes.TrimSpace(data[:i]), bytes.TrimSpace(data[i+1:])
return bytes.TrimSpace(before), bytes.TrimSpace(after)
}

type eventMatchUnmarshaller struct {
Expand Down
Loading