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

cmd/go: 'go get' appears to have no way to specify a branch in it that contains a / #36902

Closed
CyrusNajmabadi opened this issue Jan 30, 2020 · 8 comments
Labels
FrozenDueToAge modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@CyrusNajmabadi
Copy link

Extracting this bug out of the doc conversation that happened here #30851

Currently go get claims to be able to allow you to get a module hosted at a location with a given branch name. i.e. go get github.com/pulumi/pulumi@some_branch. However, there seems to be no way to make this work if the branch has a / in it. i.e. neither go get github.com/pulumi/pulumi@cyrusn/somefix nor go get github.com/pulumi/pulumi@features/2.0 work.

This effectively makes go get and modules non-viable for projects that use a very common and legal naming strategy for branches. Note that both git and github are fine with this sort of naming, and it's encouraged in many repos (as it helps keep the list of branches from getting very cluttered).

go get should not arbitrarily restrict the set of branch names it accepts.

Workarounds:
You can write go get ...@deadbeef. however this only gives you a point-in-time version of the module. There does not seem to be a way to get all the functionality normaly present with a branch-link if the branch contains a /.

@hausdorff
Copy link

It's worth noting that there are a lot of people on that issue complaining about this. The skepticism expressed by maintainers that no one does this in the world is completely unwarranted. I've seen people do this at every company I've ever been in, and it is trivially easy to find Go projects on GitHub that actively use this strategy currently. For starters: basically any project that has to keep secrets back from PRs will use this strategy.

How can we help to fix this?

@CyrusNajmabadi
Copy link
Author

agreed. The original was closed with this comment:

Technically you could have a branch name with slashes in it. I sincerely doubt that many, if any, repositories containing Go code will have such branches.

Which was responded to with several dozen downvotes.

Even if this is a current heuristic for go get, there can certainly be fixes made here to deal with the issue. For example, allowing someone a way to just explicit specify a branch name with no restrictions from the go tool as to what it should be.

Heuristics (as stated by @bcmills here) are a bad thing. When it comes to this sort of decision, there should be a clear and easy way for people to specify the things they have that are otherwise entirely legal and normal today.

@bcmills
Copy link
Contributor

bcmills commented Jan 31, 2020

i.e. neither go get github.com/pulumi/pulumi@cyrusn/somefix nor go get github.com/pulumi/pulumi@features/2.0 work.

When you say they don't work — what is the failure mode today?

(I would expect those to successfully resolve to a pseudo-version when fetching directly from source control, but not when fetching from a proxy.)

@bcmills bcmills changed the title 'go get' appears to have no way to specify a branch in it that contains a / cmd/go: 'go get' appears to have no way to specify a branch in it that contains a / Jan 31, 2020
@bcmills bcmills added modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. labels Jan 31, 2020
@bcmills bcmills added this to the Backlog milestone Jan 31, 2020
@gopherbot
Copy link

Timed out in state WaitingForInfo. Closing.

(I am just a bot, though. Please speak up if this is a mistake or you have the requested information.)

@grellyd
Copy link

grellyd commented May 4, 2020

This issue presents itself as:

go get github.com/org/repo@namespace/branch: github.com/org/repo@namespace/branch: invalid version: version "branch" invalid: disallowed version string

A workaround at this time is to git log the sha of the HEAD of the namespaced branch and then go get using that sha.

EG: go get github.com/org/repo@sha

@grellyd
Copy link

grellyd commented May 4, 2020

What further information is needed? Happy to help provide more details to move past the WaitingForInfo stage.

@bcmills
Copy link
Contributor

bcmills commented May 4, 2020

@grellyd, please file a new issue. (The issue template has headings and descriptions for all of the needed information.)

It would be especially helpful to see how the behavior varies with different settings for GOPROXY (default vs. direct) and GOPRIVATE (unset vs. something that matches the module in question).

@grellyd
Copy link

grellyd commented May 4, 2020

@bcmills I had a vain hope that commenting would automatically re-open the existing issue. 😂 Oh well. New issue incoming.

@golang golang locked and limited conversation to collaborators May 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

5 participants