Skip to content
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

Refactor pktline #1082

Open
wants to merge 33 commits into
base: v6-exp
Choose a base branch
from

Conversation

aymanbagabas
Copy link
Contributor

Taken from aymanbagabas#1

aymanbagabas and others added 29 commits December 5, 2023 15:21
Git file, git, and ssh transports use a full-duplex transport protocol.
This is now located under `plumbing/transport`.
The server transport along with its `Serve*` methods are now located
under `plumbing/server`.
Co-authored-by: Paulo Gomes <paulo.gomes.uk@gmail.com>
Co-authored-by: Paulo Gomes <paulo.gomes.uk@gmail.com>
Co-authored-by: Paulo Gomes <paulo.gomes.uk@gmail.com>
Co-authored-by: Paulo Gomes <paulo.gomes.uk@gmail.com>
Co-authored-by: Paulo Gomes <paulo.gomes.uk@gmail.com>
Pktline is already implied in the package name, no need to have "Packet"
in the method names.
Co-authored-by: Paulo Gomes <paulo.gomes.uk@gmail.com>
@aymanbagabas aymanbagabas changed the base branch from master to v6-exp April 30, 2024 14:50
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.

Small nits, otherwise LGTM.


// Make sure you close the server after the test.
func SetupProxyServer(c *C, handler http.Handler, isTls, schemaAddr bool) (string, *http.Server, net.Listener) {
httpListener, err := net.Listen("tcp", ":0")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to wide, we want to restrict the listening to the loopback interface.

Suggested change
httpListener, err := net.Listen("tcp", ":0")
httpListener, err := net.Listen("tcp", "127.0.0.1:0")

}

return true
s.n, s.err = Read(s.r, s.buf[:])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a nil check for s.r.

return d.Decode(req)
}

type updReqDecoder struct {
r io.ReadCloser
s *pktline.Scanner
s io.Reader
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The field s sounds confusing now that this is no longer a scanner.

Suggested change
s io.Reader
pr io.Reader

mtx sync.Mutex
)

// Register adds or modifies an existing protocol.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where the API changed substantially, I think we should either add comments to clarify that, or find another place to amass all the API changes, so it is easier for users to migrate to V6.

Suggested change
// Register adds or modifies an existing protocol.
// Register adds or modifies an existing protocol.
// Equivalent to client.InstallProtocol in go-git before V6.

Comment on lines +17 to +18
defer mtx.Unlock()
registry[protocol] = c
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the code is this simple it is not worth the additional costs of a defer.

Suggested change
defer mtx.Unlock()
registry[protocol] = c
registry[protocol] = c
mtx.Unlock()

Comment on lines +24 to +25
defer mtx.Unlock()
delete(registry, scheme)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
defer mtx.Unlock()
delete(registry, scheme)
delete(registry, scheme)
defer mtx.Unlock()

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.

None yet

2 participants