Skip to content

Consistently construct Endpoint from urls the same way#403

Merged
technoweenie merged 1 commit intogit-lfs:masterfrom
sinbad:endpoint_consistency
Jun 17, 2015
Merged

Consistently construct Endpoint from urls the same way#403
technoweenie merged 1 commit intogit-lfs:masterfrom
sinbad:endpoint_consistency

Conversation

@sinbad
Copy link
Contributor

@sinbad sinbad commented Jun 17, 2015

There are 2 ways to construct LFS urls - from explicit URLs and from the
clone URL (which gets info/lfs appended). Previously there were multiple
paths where the Endpoint could be constructed in a short-circuit manner
which prevents future expansion in common functions. This standardises
the Endpoint construction so it always happens via NewEndpoint, and
NewEndpointFromCloneURL performs the extra step of appending info/lfs.

This has a current effect of supporting SSH urls in all config settings,
and not just the remote clone URL as before. But mostly this is to enable
future expansion (improved SSH support)

There are 2 ways to construct LFS urls - from explicit URLs and from the
clone URL (which gets info/lfs appended). Previously there were multiple
paths where the Endpoint could be constructed in a short-circuit manner
which prevents future expansion in common functions. This standardises
the Endpoint construction so it always happens via NewEndpoint, and
NewEndpointFromCloneURL performs the extra step of appending info/lfs.

This has a current effect of supporting SSH urls in all config settings,
and not just the remote clone URL as before. But mostly this is to enable
future expansion (improved SSH support)
@michael-k
Copy link
Contributor

Is it necessary to export the two functions?

@sinbad
Copy link
Contributor Author

sinbad commented Jun 17, 2015

Is it necessary to export the two functions?

They're both safe for external use and conceptually robust, and Endpoint is already exported so really safe construction should be too.

@michael-k
Copy link
Contributor

I don't see it as a question of “safe for external use” but as a design decision. Exported functions are the API of a package. A narrow API provides guidance on how to use a package. (Very helpful for people new to a project.)

Exposed functions are also restricting programmers in terms of signature changes. Changing the signature of an exposed function, means changing the API. For now, this is not really an issue as the packages are only used internally. But in the future this might change.

@sinbad
Copy link
Contributor Author

sinbad commented Jun 17, 2015

If that's the case then Endpoint shouldn't be exposed either. IMO you either expose the type AND the construction functions or neither.

@michael-k
Copy link
Contributor

We need to export the type Endpoint to generate documentation for its members (which is not yet written).

I considered Endpoint() and RemoteEndpoint() being the construction functions.

Maybe my views are just to misguided by my OOP background. So, I'm totally open to new insights and opinions here. (Which doesn't mean that I'll give up my position without a fight. ;) )

@sinbad
Copy link
Contributor Author

sinbad commented Jun 17, 2015

Fair point about Endpoint() & RemoteEndpoint() although that's specific to creating from other instances. NewFoo() is the idiom in Go for publicly constructible types since you can't have protected constructors like C++/Java to tell people they shouldn't just construct themselves.

I don't feel super-strong about it though, if Rick wants this internalised before accepting I'll do it.

@technoweenie
Copy link
Contributor

👍 on the change.

I think if we want to move towards this being a package for other Go libraries, we should start moving to github.com/github/git-lfs, as opposed to github.com/github/git-lfs/lfs as it is today. I think that should be done deliberately when someone's ready to think about the design. I'm cool with the current exported constructors for now.

@technoweenie
Copy link
Contributor

I'm going to merge this so it can be used in #362, unless anyone has any objections.

Copy link
Contributor

Choose a reason for hiding this comment

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

In the future I think method comments should follow standard godoc conventions.

Obviously this project isn't strict about docs. But I think if someone takes the time to write something, it should follow the conventions. It's easy enough that I may just make the change live before merging this, or applying it in a quick PR.

@technoweenie
Copy link
Contributor

I reorganized the code a bit in #407 based on the assumption that this PR will be merged as is. Now that Endpoint is more than just a struct declaration, I moved it all to a separate go file.

2a6af23 is the actual commit.

technoweenie added a commit that referenced this pull request Jun 17, 2015
Consistently construct Endpoint from urls the same way
@technoweenie technoweenie merged commit 29643c4 into git-lfs:master Jun 17, 2015
@sinbad sinbad deleted the endpoint_consistency branch June 18, 2015 09: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.

3 participants