GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — `plumbing/transport` API Refactoring by pjbgf · Pull Request #1983 · go-git/go-git Conversation
Member
Refactoring of the More info on the original PR #1972.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactionsReplace the alpha plumbing/transport API with the new x/transport API. Copy all core files from x/transport/ to plumbing/transport/ with import path rewrites. Delete old files that have no equivalent in the new API (registry.go, mocks.go, pack.go). See rfcs/0002-replace-plumbing-transport.md for design rationale. Replace the old upload_pack.go and receive_pack.go test suites in internal/transport/test/ with the new versions from x/transport/test/. These new suites test against the new plumbing/transport API. Replace the old plumbing/transport/ssh package with the new version from x/transport/ssh. This includes the new auth, handshake, knownhosts, and sshagent implementations. Replace the old plumbing/transport/http package with the new version from x/transport/http. This includes new auth, handshake, dumb HTTP, TLS, redirect, and proxy implementations. Replace the old plumbing/transport/git package with the new version from x/transport/git. Includes new handshake implementation. Replace the old plumbing/transport/file package with the new version from x/transport/file. Includes new handshake implementation. Add plumbing/client from x/client. This package provides scheme-based transport resolution, replacing the old registry.go functionality. Replace old transport API usage in remote.go, repository.go, submodule.go, and options.go with the new plumbing/transport and plumbing/client APIs. Key changes: - Replace Auth, InsecureSkipTLS, CABundle, ProxyOptions fields with ClientOptions []client.Option on all option structs - Replace newClient() to use client.New() + transport.ParseURL() - Collapse Transport.NewSession + Session.Handshake into client.Handshake - Pass storer to Session.Fetch/Push (new signature) - Replace transport.NewEndpoint with transport.ParseURL (*url.URL) Update server and backend packages for the new plumbing/transport API: - Replace transport.Service type with plain string - Replace transport.NewEndpoint with transport.ParseURL (*url.URL) - Replace svc.Name()/service.Name() with transport.ServiceName() - Update Loader.Load signature from *Endpoint to *url.URL Update all examples that use authentication or custom HTTP clients to use the new client.Option pattern instead of the old Auth field and transport.Register. Fix all remaining build, test, and lint errors after the transport API migration so the full stack compiles, passes go vet, and all tests pass. Highlights: - Remove NewConn helper; each transport now implements transport.Conn directly (sshConn, gitConn, fileConn) - Surface remote stderr at Push/Fetch via Stderr() io.Reader interface instead of at Close() time — the idiomatic Go pattern for subprocess error reporting - Replace UploadPackOptions/ReceivePackOptions with UploadPackRequest/ ReceivePackRequest in backend packages - Fix missing closing paren and stale variable references in remote.go - Update worktree.go to use ClientOptions instead of old fields - Consolidate duplicate internal/transport/test imports across all sub-transport test files - Refactor duplicated test code into table-driven tests and shared setup helpers (file, git, ssh) - Fix TestHostKeyCallbackHelper_NilFallback to account for /etc/ssh/ssh_known_hosts - Fix gci import ordering across all modified files Verified: go build, go vet, go test ./..., and example tests all pass. The go.mod requires v6 but test files still imported v5. Merge backend/git and backend/http into a single backend package with a unified API: - Backend.Serve(ctx, r, w, *Request) — core dispatch for all transports - Backend.ServeConn(ctx, rwc, *Request) — convenience for full-duplex connections (TCP, SSH, pipes) - Backend.ServeHTTP(w, r) — HTTP adapter (smart + dumb protocols) - RequestFromProto(*packp.GitProtoRequest) — helper for TCP git daemon The shared logic (loader resolution, service dispatch, UploadPack/ ReceivePack invocation) lives in Serve. HTTP-specific concerns (routing, gzip, content-type, dumb file serving) stay in ServeHTTP. Error handling is the caller's responsibility — Serve returns errors instead of writing them to the wire. Delete backend/git/ and backend/http/ subpackages. Update internal/server/http to import backend directly. Co-authored-by: Paulo Gomes <[email protected]> Co-authored-by: Ayman Bagabas <[email protected]> Co-authored-by: Copilot Autofix powered by AI <[email protected]> plumbing: transport, replace transport API with new design
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pull request overviewThis PR completes a breaking refactor of the Changes:
Reviewed changesCopilot reviewed 103 out of 103 changed files in this pull request and generated 5 comments. Show a summary per file
Comments suppressed due to low confidence (2)backend/writer.go:36
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Comment on lines
+141
to
+143
|
| for _, tc := range []struct { | ||
| name string | ||
| command string | ||
| }{ | ||
| {"UploadPack", "git-upload-pack"}, | ||
| {"ReceivePack", "git-upload-pack"}, | ||
| } { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
In TestGitTransport_Connect, the "ReceivePack" test case is using git-upload-pack as the command, so the receive-pack connect path is never tested. Change the command for that case to git-receive-pack.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| func (r *testProxyRule) Allow(_ context.Context, _ *socks5.Request) (context.Context, bool) { | ||
| *r.proxiedRequests++ | ||
| return context.Background(), true |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This increment is a compile error in Go (++ is a statement, not an expression). Use an increment statement on the dereferenced pointer (e.g., (*r.proxiedRequests)++) or store the counter as an atomic.Int32/int64 and increment it safely.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
| func WithCABundle(pem []byte) Option { | ||
| return func(o *options) { | ||
| pool := x509.NewCertPool() | ||
| pool.AppendCertsFromPEM(pem) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
WithCABundle ignores the boolean return from CertPool.AppendCertsFromPEM. If the input PEM is invalid/empty, this silently installs an empty RootCAs pool and will make all HTTPS handshakes fail in a non-obvious way. Consider checking the return value and either leaving RootCAs unchanged when parsing fails or providing a way to surface an error to the caller.
| pool.AppendCertsFromPEM(pem) | |
| if !pool.AppendCertsFromPEM(pem) { | |
| return | |
| } |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.