-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/go: very difficult to work with private Github repositories #9697
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
Comments
It sounds to me like the go1.4 import path checking feature is looking at the git repository to determine where it was cloned from. I wonder if a viable alternative would be to have it instead:
This would still have it block people from doing I don't know enough about this to know if this is a good solution, or why testing against the git repo's remote URL was chosen (assuming I am correct on this). |
Just use |
I'm aware I can bypass the check, and I've done so a great many times. It doesn't make the behavior any less frustrating, and it only helps when I'm running I think at least part of the problem is that I expect |
@adg it is really not practical (and I guess also not desirable) to fix all automation around Would a fix for this accepted, if provided? Please consider that github.com private repositories are a major use-case. Actually so major, that this is basically Githubs business model in a nutshell. |
What would the fix look like? On 27 January 2015 at 22:30, Ingo Oeser notifications@github.com wrote:
|
@adg just use diff --git a/src/cmd/go/vcs.go b/src/cmd/go/vcs.go
index 1cac613..302c990 100644
--- a/src/cmd/go/vcs.go
+++ b/src/cmd/go/vcs.go
@@ -122,32 +122,21 @@ var vcsGit = &vcsCmd{
}
func gitRemoteRepo(vcsGit *vcsCmd, rootDir string) (remoteRepo string, err error) {
- outb, err := vcsGit.runOutput(rootDir, "remote -v")
+ cmd := "config remote.origin.url"
+ errParse := errors.New("unable to parse output of git " + cmd)
+
+ outb, err := vcsGit.runOutput(rootDir, cmd)
if err != nil {
return "", err
}
- out := string(outb)
-
- // Expect:
- // origin https://github.com/rsc/pdf (fetch)
- // origin https://github.com/rsc/pdf (push)
- // use first line only.
-
- if !strings.HasPrefix(out, "origin\t") {
- return "", fmt.Errorf("unable to parse output of git remote -v")
- }
- out = strings.TrimPrefix(out, "origin\t")
- i := strings.Index(out, "\n")
- if i < 0 {
- return "", fmt.Errorf("unable to parse output of git remote -v")
- }
- out = out[:i]
- i = strings.LastIndex(out, " ")
- if i < 0 {
- return "", fmt.Errorf("unable to parse output of git remote -v")
+ repoUrl := strings.TrimSpace(string(outb))
+ for _, s := range vcsGit.scheme {
+ if strings.HasPrefix(repoUrl, s) {
+ return repoUrl, nil
+ }
}
- out = out[:i]
- return strings.TrimSpace(string(out)), nil
+ return "", errParse
+
}
|
@zenazn I'm confused by this:
Are you saying that you can run "go get importpath" and then "go get -u importpath" and receive that error message? That shouldn't happen. I don't understand how it could happen. Or are you saying that if you run the first command with a pre-Go 1.4 go tool, and the latter with the Go 1.4 go tool, you receive the error? @nightlyone that seems like a reasonable fix. What say you @rsc? |
@adg—yeah. Run the |
@nightlyone want to send that change as a CL? |
@adg mailed out https://golang.org/cl/3504 for review |
I believe that this fix is incomplete. With a
This creates challenges when, for example, running |
Please, just make it work like it did before 1.4. The change in CLI behavior breaks a lot of scripts. |
@christophercurrie @ungerik Please open a new issue to discuss the specific issue you want addressed. This issue has been fixed and closed. Thanks. |
@ianlancetaylor The current fix is incomplete, which is why I continued the thread here, to retain that context. However, per your request I have created #10791 to track this continuing issue. |
The new custom import path checking behavior introduced in Go 1.4 makes it extremely difficult to work with private Github repositories.
Before Go 1.4, the traditional way to work with a private Github repository was to run something similar the following:
This would allow
go get
and friends to transparently work as expected, automatically rewritinghttps
URLs to use SSH for auth. This worked both when pushing and pulling.However, in Go 1.4 this setting causes fun things like this to happen:
(while I've chosen a public repository as my example here, this occurs on private repos as well, meaning that it's not sufficient to use a non-
--global
setting)I've been loosely following some discussion (on go-nuts, I believe) that advocates for
pushInsteadOf
: while this works well for contributors for open-source repositories, it doesn't help in situations in which both push and pull access to a repository need authentication.Is there a suggested course of action here?
The text was updated successfully, but these errors were encountered: