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
x/tools/go/vcs: vcs.go does not support private repositories like GitHub Enterprise & GitLab. It is too restrictive because of regex pattern validation #21465
Comments
Can you please give some sample URLs which do not work (I don't think many
people here have experience with Github enterprise, et al), and what
happened when you tried.
…On Wed, Aug 16, 2017 at 12:58 PM, Tariq Ibrahim ***@***.***> wrote:
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (go version)?
1.8.3
What operating system and processor architecture are you using (go env)?
GOHOSTOS = darwin GOARCH = amd64
What did you do?
If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.
What did you expect to see?
We are unable to use the VCS tool with GitHub Enterprise URLs, GitLab URLs
etc. These are git repositories and they need to be supported
What did you see instead?
GitHub Enterprise, GitLab Enterprise URLs being supported.
I have an idea for this. Instead of regex validation, we can loop through
the various known VCS PingCmds to determine the type of repository. When a
positive result is received, we break out of the loop and continue
repository processing based on the determined repository type. If you're
okay with this idea, I am ready to make a PR.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#21465>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAcA3LsUo59syaE4uTw1NyBy4rLx-kCks5sYlrFgaJpZM4O4XBn>
.
|
Sample URLs are : These URLs will fail the checks enforced by vcs.go. Have a look at this code snippet for instance, To make it work for our GHE we had to patch vcs.go to add our GitHub Enterprise prefix and URL pattern. This is not the best solution IMO |
Please try appending .git to the url. Does that work? |
I tried it. It does not work. I have looked into the code. Our GHE URLs fail the prefix test let alone the URL regex. Here the expected prefix is github.com, while our company's GHE URLs have the following prefix : github.enterprise_name.org. A company I had worked in earlier had github.company_name.com. I am sorry for not disclosing the complete name as I am bound by NDA. But this information should suffice I guess. |
This is pretty common, going through this myself to be honest. But poke a bit further around and you find the workaround that actually does do the needful: #19251 --> https://gist.github.com/shurcooL/6927554 Setting up the recommendation from @shurcooL does work, it's a bit annoying but fine. |
Also, @tariq1890 your code is most likely going to hit this branch of the
For my GHE setup, our URL is git...com and we trigger the last entry in the list. I suspect your site is doing the same, and if that's indeed the case then the links above should do the trick for you. |
When you say
It's really helpful if you can include the command you typed and the output you received. We want to help, but we can't see your screen. |
Alright. More details. So the method that is invoked is RepoRootForImportPath in vcs.go and this is the error emitted
My point is that I am able to get this working by hardcoding my GHE URL prefix and pattern to the vcsPaths array. But this is a bad solution. I am asking that we reconsider the validation method for the repository URLs. Please refer to my first post, I have provided my idea there. I believe with this idea implemented, it wouldn't cause backward compatibility issues either. |
What @dcheney-atlassian said was:
Did you try that? What was the command you ran? Was it something like this?
Can you post the full command and its output from your terminal (you can replace company/org/repo names of course)? |
@shurcooL I am not trying the go get command. In fact, I am not trying any go command here. We have other workarounds for go get issue. I am talking about the vcs.go source file in go tools. vcs.go seems to be intended as a utility library to assist with the interacting with version control repos. The way it is coded right now, we are unable to use it for interacting with our private repositories. |
I see. You're referring to Can you post the code that you used then? The same question applies, what was the import path you used; did it have a ".git" suffix? |
Yes. Correct. Thanks for the Issue edit. Yes i tried with .git suffix as well. I get the same unrecognized import path error |
I can't reproduce. $ goexec 'vcs.RepoRootForImportPath("github.examplecompany.org/org/repo.git", false)'
(*vcs.RepoRoot)(&vcs.RepoRoot{
VCS: (*vcs.Cmd)(&vcs.Cmd{
Name: (string)("Git"),
Cmd: (string)("git"),
CreateCmd: (string)("clone {repo} {dir}"),
DownloadCmd: (string)("pull --ff-only"),
TagCmd: ([]vcs.TagCmd)([]vcs.TagCmd{
(vcs.TagCmd)(vcs.TagCmd{
Cmd: (string)("show-ref"),
Pattern: (string)("(?:tags|origin)/(\\S+)$"),
}),
}),
TagLookupCmd: ([]vcs.TagCmd)([]vcs.TagCmd{
(vcs.TagCmd)(vcs.TagCmd{
Cmd: (string)("show-ref tags/{tag} origin/{tag}"),
Pattern: (string)("((?:tags|origin)/\\S+)$"),
}),
}),
TagSyncCmd: (string)("checkout {tag}"),
TagSyncDefault: (string)("checkout master"),
LogCmd: (string)(""),
Scheme: ([]string)([]string{
(string)("git"),
(string)("https"),
(string)("http"),
(string)("git+ssh"),
}),
PingCmd: (string)("ls-remote {scheme}://{repo}"),
}),
Repo: (string)("github.examplecompany.org/org/repo"),
Root: (string)("github.examplecompany.org/org/repo.git"),
})
(interface{})(nil) Are you using the latest version of |
I am using Go 1.8.3. I guess you're trying with ".git suffix. If we go with that approach, then normal GitHub repos won't work. We get invalid suffix error when we suffix github repository paths with .git. |
Can you try go exec with an existing GitHub repository suffixed with .git ? Try this ?
|
Yes, you don't need .git suffix for normal The .git suffix is needed to tell Go that it's a git repo. It can't know whether a given URL is GitHub Enterprise or not. But "github.com" URLs are well known, that's why they can be treated specially and not require .git suffix. You can read more about this at https://golang.org/cmd/go/#hdr-Remote_import_paths. |
But this would mean suffixing GHE and GitLab URLs with .git . This does kinda fall short (hacky) from an API/Library standpoint. But I do understand now that vcs.go has been written keeping the go get command in mind. Thanks for your time. I'll proceed with writing a custom library. I strongly feel that ping commands should be used for validation here rather than regex. |
The problem with suffixing the URLs with |
I just ran into this issue as well using VSC. Command line is fine. This can be somewhat confusing and a time sink to determine what the problem is... why command line go get works, but VSC is flagging the repository in the import as unreachable. vcs could leverage the GOPRIVATE environment variable or maybe another environment variable that points to a file that contains the additional structures that a user must provide for their private repositories, using the format that is present in vcs.go. Adding the specific changes to vcs.go directly alleviated the error in VSC for me too. go version 1.17.3 windows10/64bit |
I think this issue can now be closed, as it has been solved, for GHE repos at least. |
In which version will this be released?
Thank you.
Sent from Yahoo Mail for iPhone
On Wednesday, November 10, 2021, 11:23, Sean Liao ***@***.***> wrote:
Closed #21465.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.
|
It was fixed back in 2018 in Github Enterprise 2.13 See the end of #17898 |
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?1.8.3
What operating system and processor architecture are you using (
go env
)?GOHOSTOS = darwin GOARCH = amd64
What did you do?
If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.
What did you expect to see?
We are unable to use the VCS tool with GitHub Enterprise URLs, GitLab URLs etc. These are git repositories and they need to be supported
What did you see instead?
GitHub Enterprise, GitLab Enterprise URLs being supported.
I have an idea for this. Instead of regex validation, we can loop through the various known VCS PingCmds to determine the type of repository. When a positive result is received, we break out of the loop and continue repository processing based on the determined repository type. If you're okay with this idea, I am ready to make a PR.
The text was updated successfully, but these errors were encountered: