lint: fix transport linter findings · Entire

lint: fix transport linter findings

542ea38→main·
Soph·2mo ago·3 files·+42 added/-24 removed

Sessions

4dd13848aefcView transcript

[?
yes, start implementing, make a new branch, make meaningful commits, and add tests as you go, when it makes sense create tests firstCodex·GPT-5.4·1 step](/content/gh/entireio/git-sync/session/019e260b-71e8-73a1-9e68-5857379ffab6#timeline-4dd13848aefc/index.html)

Changes

3

151 unmodified lines

// RequestInfoRefs fetches /info/refs for the given service.
func RequestInfoRefs(ctx context.Context, conn Conn, service string, gitProtocol string) ([]byte, error) {
    return conn.RequestInfoRefs(ctx, service, gitProtocol)

data, err := conn.RequestInfoRefs(ctx, service, gitProtocol)
    if err != nil {
        return nil, fmt.Errorf("request info refs: %w", err)
    }
    return data, nil
}

// RequestInfoRefs fetches /info/refs for the given service.
func (conn *HTTPConn) RequestInfoRefs(ctx context.Context, service string, gitProtocol string) ([]byte, error) {
    reqURL := fmt.Sprintf("%s/info/refs?service=%s", conn.EndpointURL.String(), service)

func (c *HTTPConn) RequestInfoRefs(ctx context.Context, service string, gitProtocol string) ([]byte, error) {
    reqURL := fmt.Sprintf("%s/info/refs?service=%s", c.EndpointURL.String(), service)
    req, err := http.NewRequestWithContext(ctx, http.MethodGet, reqURL, nil)
    if err != nil {
        return nil, fmt.Errorf("create info-refs request: %w", err)
    }

if gitProtocol != "" {
        req.Header.Set("Git-Protocol", gitProtocol)
    }
    ApplyAuth(req, conn.Auth)
    ApplyAuth(req, c.Auth)

res, err := conn.HTTP.Do(req)
    res, err := c.HTTP.Do(req)
    if err != nil {
        return nil, fmt.Errorf("request info-refs: %w", err)
    }

Minternal/gitproto/smarthttp.go+22/-14


// PostRPCStreamBody sends a POST to the given service using a streaming request body.
// Caller must close the returned ReadCloser.
func PostRPCStreamBody(ctx context.Context, conn Conn, service string, body io.Reader, v2 bool, phase string) (io.ReadCloser, error) {
    return conn.PostRPCStreamBody(ctx, service, body, v2, phase)
    reader, err := conn.PostRPCStreamBody(ctx, service, body, v2, phase)
    if err != nil {
        return nil, fmt.Errorf("post RPC stream body: %w", err)
    }
    return reader, nil
}

// PostRPCStreamBody sends a POST to the given service using a streaming request body.
// Caller must close the returned ReadCloser.
func (conn *HTTPConn) PostRPCStreamBody(ctx context.Context, service string, body io.Reader, v2 bool, phase string) (io.ReadCloser, error) {
    reqURL := fmt.Sprintf("%s/%s", conn.EndpointURL.String(), service)

func (c *HTTPConn) PostRPCStreamBody(ctx context.Context, service string, body io.Reader, v2 bool, phase string) (io.ReadCloser, error) {
    reqURL := fmt.Sprintf("%s/%s", c.EndpointURL.String(), service)
    req, err := http.NewRequestWithContext(ctx, http.MethodPost, reqURL, body)
    if err != nil {
        return nil, fmt.Errorf("create RPC request: %w", err)
    }

if v2 {
        req.Header.Set("Git-Protocol", "version=2")
    }
    ApplyAuth(req, conn.Auth)
    ApplyAuth(req, c.Auth)

res, err := conn.HTTP.Do(req)
    res, err := c.HTTP.Do(req)
    if err != nil {
        return nil, fmt.Errorf("post RPC: %w", err)
    }

Minternal/gitproto/ssh.go+14/-8

348 unmodified lines

// --- Session setup ---

func newConn(raw Endpoint, label string, stats *statsCollector, httpClient *http.Client) (gitproto.Conn, error) {
    func newConn(raw Endpoint, label string, stats *statsCollector, httpClient *http.Client) (gitproto.Conn, error) { //nolint:ireturn // transport selection intentionally returns the shared connection interface
        ep, err := transport.ParseURL(raw.URL)
        if err != nil {
            return nil, fmt.Errorf("parse endpoint: %w", err)
        }

Minternal/syncer/syncer.go+6/-2