-
Notifications
You must be signed in to change notification settings - Fork 845
plumbing: transport, refactor transport Endpoint to use url.URL #1706
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
c89055f to
b9b3969
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the Endpoint struct to embed url.URL instead of maintaining separate fields for protocol, user, password, host, port, and path. This simplifies the codebase by leveraging Go's standard library URL handling.
Key changes:
- Replaced custom
Endpointfields with embeddedurl.URLstruct - Updated all references from
ProtocoltoSchemeand adapted field access patterns throughout the codebase - Removed custom
String()method and helper functions (getPort,getPath) in favor of standardurl.URLmethods
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| plumbing/transport/transport.go | Core refactoring: Endpoint now embeds url.URL; removed custom String(), getPort(), getPath() functions |
| submodule.go | Updated field access from Protocol to Scheme |
| remote.go | Updated field access from Protocol to Scheme |
| plumbing/transport/registry_test.go | Updated test assertions from Protocol to Scheme |
| plumbing/transport/ssh/common.go | Adapted to use url.URL methods for Host/Port/User access |
| plumbing/transport/ssh/common_test.go | Updated test expectations for host-port formatting |
| plumbing/transport/git/common.go | Adapted to use url.URL Port() method and updated host handling |
| plumbing/transport/http/common.go | Updated redirect handling and auth extraction to use url.URL fields |
| plumbing/transport/http/common_test.go | Removed obsolete ModifyEndpointIfRedirect test |
| plumbing/transport/transport_test.go | Restructured tests, updated assertions to validate url.URL fields |
Comments suppressed due to low confidence (2)
plumbing/transport/http/common.go:75
- Debug logging statement left in production code. This log.Printf call should be removed or placed behind a debug flag to avoid excessive logging in production environments.
res, err := client.Do(req)
plumbing/transport/http/common.go:562
- Debug logging statement left in production code. This log.Printf call should be removed or placed behind a debug flag to avoid excessive logging in production environments.
return err
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
962e5a4 to
db555c6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aymanbagabas thanks for working on this. 🙇
There's no need to duplicate the logic already present in url.URL and the standard library to parse and handle URLs. This refactor simplifies the codebase by removing redundant fields and methods, and leverages the existing functionality of url.URL. This also remove unused code in transport/http ModifyEndpointIfRedirect and its related tests.
db555c6 to
9c98ad7
Compare
There's no need to duplicate the logic already present in url.URL and the standard library to parse and handle URLs. This refactor simplifies the codebase by removing redundant fields and methods, and leverages the existing functionality of url.URL.
This also remove unused code in transport/http ModifyEndpointIfRedirect and its related tests.