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: remote import path meta tag format should accept multiple paths #9532

Closed
dsymonds opened this issue Jan 8, 2015 · 17 comments
Closed

Comments

@dsymonds
Copy link
Contributor

dsymonds commented Jan 8, 2015

The meta tag has this format: (from http://golang.org/cmd/go/#hdr-Remote_import_paths)

<meta name="go-import" content="import-prefix vcs repo-root">

Unfortunately, this doesn't permit multiple equivalent roots, where the repo is the same but has multiple access methods. For instance, https://github.com/robpike/filter is canonically robpike.io/filter, and is accessible via at least two methods:

  • https://github.com/robpike/filter.git (no auth required to fetch)
  • git@github.com:robpike/filter.git (will use your SSH keys for push auth)

However, his meta tag has to look like

<meta name="go-import" content="robpike.io/filter git https://github.com/robpike/filter.git">

so that Joe Random can run go get robpike.io/filter.

It would be ideal if, say, @robpike could interact wholly with the repo via git@github.com:robpike/filter.git (since his SSH keys will be used when pushing), but he can still use go get -u robpike.io/filter too.

One obvious fix is to expand the meta tag format to have multiple repo roots. The first is semantically the default, but all are considered equivalent and permitted by the go tool's vanity URL enforcement mechanism. Then @robpike can have a meta tag like

<meta name="go-import" content="robpike.io/filter git https://github.com/robpike/filter.git git@github.com:robpike/filter.git">
@dsymonds
Copy link
Contributor Author

dsymonds commented Jan 8, 2015

Also, forgot to mention that we used Git's pushInsteadOf feature to work around this for Rob's specific cases (see the gitconfig and git-push man pages), but it seems like a more general fix would be useful for other people since pushInsteadOf is fairly simple and won't work in general for this problem.

@dsymonds
Copy link
Contributor Author

dsymonds commented Jan 8, 2015

@adg, @bradfitz and @rsc are sure to have opinions on this.

@bradfitz
Copy link
Contributor

bradfitz commented Jan 8, 2015

Doesn't seem worth the complexity.

I don't know that git think you mentioned, but you could also just write a program to scan your $GOPATH and convert any origins from their public to auth-required URLs. At least that program would stay out of cmd/go.

@dsymonds
Copy link
Contributor Author

dsymonds commented Jan 8, 2015

It's not just a one-shot problem. It's an ongoing thing. Once you've got this kind of package in your $GOPATH, go get -u forces you to use the canonical remote, which needs to be the public one, which makes it worse for the developer wanting to push. I guess you could tell them that they can't use go get -u on packages they develop, but that seems lame.

It's not a lot of complexity. The implementation would be a trivial bit more parsing (strings.Split on spaces, then do a containment check instead of using ==), and it has zero impact on import tags that don't care about it.

@minux
Copy link
Member

minux commented Jan 8, 2015

The git url.pushInsteadOf configuration is to solve this kind of problems.

@dsymonds
Copy link
Contributor Author

dsymonds commented Jan 8, 2015

@minux: Please read what I wrote on #9532 (comment). That's an incomplete solution.

@minux
Copy link
Member

minux commented Jan 8, 2015

Why it's incomplete? Only the author of the package need to set up
pushInsteadOf and then use the canonical clone URL.

@dsymonds
Copy link
Contributor Author

dsymonds commented Jan 8, 2015

Everyone who wants push access to a repo needs to do it, and it needs to be done on every machine that has a checkout. That's M*N instead of 1 (a single change in the meta tag). In the simplest case, yes, it'll be a fine workaround when M=N=1, but it's kinda clunky to do that to work around a deficiency in the go tool.

@bradfitz
Copy link
Contributor

bradfitz commented Jan 8, 2015

David, even with your proposal, each author needs to independently configure the git origin from http to ssh once, no? I guess you're fine with that, but just want the tool to stop complaining thereafter? But if you're already fine with the user having to configure the repo to commit elsewhere, maybe instead we add a mechanism to shut up the warning... some sort of "yes-i-know-you-don't-like-this-location-but-it's-cool-trust-me" flag. Then if the upstream URL for authors is secret (e.g. some internal corp URL), you don't have to leak it publicly too.

@dsymonds
Copy link
Contributor Author

dsymonds commented Jan 8, 2015

That would be fine with me too.

@minux
Copy link
Member

minux commented Jan 9, 2015

I'm concerned that relaxing the check will make vanity import
checking useless. (A check that can be disabled is equivalent to
no check at all, people will disable it. That's why we don't offer
flags to disable "annoying" unused variable/import errors.)

The author of a package always need to do something special for
the git repo to be able to push anyway: be it another go get
flag (and he also needs to clone from another location) or
git config (remote.origin.pushurl, or branch._.pushremote), so I
don't think the extra cmd/go flag or extra remotes in meta tag
could solve the O(M_N) problem. (unless we make go get somehow
clone from the git: URL by default.)

I just checked that the author can simply set
git config remote.origin.pushurl git@github.com/robpike/filter.git

and then he can push without problem, and go get -u won't bark,
this is a per-repo setting, so i think it's better than the pushInsteadOf
workaround (unless you have multiple clones of the same repo.)

@dsymonds
Copy link
Contributor Author

dsymonds commented Jan 9, 2015

On 9 January 2015 at 11:32, Minux Ma notifications@github.com wrote:

I just checked that the author can simply set
git config remote.origin.pushurl git@github.com/robpike/filter.git

and then he can push without problem, and go get -u won't bark,
this is a per-repo setting, so i think it's better than the pushInsteadOf
workaround (unless you have multiple clones of the same repo.)

That did not work for @robpike yesterday, which is what started all this.
If it's meant to work then there's a bug in the go tool, because it was
definitely failing for him.

@adg adg changed the title Remote import path meta tag format should accept multiple paths cmd/go: remote import path meta tag format should accept multiple paths Jan 9, 2015
@adg
Copy link
Contributor

adg commented Jan 9, 2015

maybe instead we add a mechanism to shut up the warning

It exists. "go get -u -f"

@minux
Copy link
Member

minux commented Jan 9, 2015

I just created a clone of the filter repo, and tried this:
git config remote.origin.pushurl git@github.com:minux/filter.git

And git push worked for me.
(Note the colon, not slash, after github.com)

@dsymonds
Copy link
Contributor Author

dsymonds commented Jan 9, 2015

Oh, I missed you were setting .pushurl instead of .url. Yeah, that's an equivalent workaround to the pushInsteadOf config, except that now you need to do it for each repo instead of potentially just once in your $HOME/.gitconfig.

@minux
Copy link
Member

minux commented Jan 9, 2015

Right, but as I said earlier, the author always need some
special handling to be able to push, so each workaround
is as good as others.

This is similar to #9300 and all the other issues requesting
support for git ssh remote URLs.

Unless go get supports cloning form the ssh URLs, I don't
think we can get rid of the special handling for package
authors.

@rsc
Copy link
Contributor

rsc commented Apr 10, 2015

Not worth the complexity.

@rsc rsc closed this as completed Apr 10, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants