Skip to content

Conversation

@aymanbagabas
Copy link
Member

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.

@aymanbagabas aymanbagabas requested review from Copilot and pjbgf October 30, 2025 20:26
@aymanbagabas aymanbagabas force-pushed the refactor-transport-endpoint branch from c89055f to b9b3969 Compare October 30, 2025 20:28
Copy link
Contributor

Copilot AI left a 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 Endpoint fields with embedded url.URL struct
  • Updated all references from Protocol to Scheme and adapted field access patterns throughout the codebase
  • Removed custom String() method and helper functions (getPort, getPath) in favor of standard url.URL methods

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.

@aymanbagabas aymanbagabas force-pushed the refactor-transport-endpoint branch 5 times, most recently from 962e5a4 to db555c6 Compare October 30, 2025 20:44
Copy link
Member

@pjbgf pjbgf left a 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.
@pjbgf pjbgf force-pushed the refactor-transport-endpoint branch from db555c6 to 9c98ad7 Compare November 3, 2025 20:00
@pjbgf pjbgf merged commit 47b1ed2 into go-git:main Nov 3, 2025
13 checks passed
@aymanbagabas aymanbagabas deleted the refactor-transport-endpoint branch November 3, 2025 20:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants