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

go get could not understand the right git path. it only support one level namespace #21859

Closed
ghost opened this issue Sep 13, 2017 · 8 comments
Closed

Comments

@ghost
Copy link

ghost commented Sep 13, 2017

I am try to using go get tool to download golang packages.

 go get -u -v www.gitexample.com/comnap/public_service/short_url    
Fetching https://www.gitexample.com/comnap/public_service/short_url?go-get=1
Parsing meta tags from https://www.gitexample.com/comnap/public_service/short_url?go-get=1 (status code 200)
get "www.gitexample.com/comnap/public_service/short_url": found meta tag get.metaImport{Prefix:"www.gitexample.com/comnap/public_service", VCS:"git", RepoRoot:"https://www.gitexample.com/comnap/public_service.git"} at https://www.gitexample.com/comnap/public_service/short_url?go-get=1
get "www.gitexample.com/comnap/public_service/short_url": verifying non-authoritative meta tag
Fetching https://www.gitexample.com/comnap/public_service?go-get=1
Parsing meta tags from https://www.gitexample.com/comnap/public_service?go-get=1 (status code 200)
www.gitexample.com/comnap/public_service (download)
# cd .; git clone https://www.gitexample.com/comnap/public_service.git /home/huzhifeng/go/src/www.gitexample.com/comnap/public_service
Cloning into '/home/huzhifeng/go/src/www.gitexample.com/comnap/public_service'...
Warning: Permanently added 'www.gitexample.com,192.168.13.123' (ECDSA) to the list of known hosts.
GitLab: The project you were looking for could not be found.
fatal: Could not read from remote repository.

the prefix was /compnap/public_service . And the short_url was the real project name.
But golang try to located comnap/public_service as git repository. It really not good for us.

Why go get can only support one level path?

@ghost ghost changed the title go get could not understand the right git path go get could not understand the right git path. it only support one level namespace Sep 13, 2017
@ghost
Copy link
Author

ghost commented Sep 13, 2017

In our real production environment, we have thousands repositories. we need to organize them in 3 or 4 level.
Such as

gitexample.com/comap/graph/composite
gitexample.com/comap/compress/xmodzip

They are standalone git repository, and maintained by different department.

@Merovius
Copy link
Contributor

AIUI, the repository you are trying to clone is at https://www.gitexample.com/comnap/public_service/short_url.git? In that case, the meta-tag served at https://www.gitexample.com/comnap/public_service/short_url should be:

<meta name="go-import" content="www.gitexample.com/comnap/public_service/short_url git https://www.gitexample.com/comnap/public_service/short_url.git">

But it seems to be

<meta name="go-import" content="www.gitexample.com/comnap/public_service git https://www.gitexample.com/comnap/public_service.git">

leading go get to make the extra request for https://www.gitexample.com/comnap/public_service?go-get=1, which serves the meta-tag

<meta name="go-import" content="www.gitexample.com/comnap/public_service git https://www.gitexample.com/comnap/public_service.git">

so go-get tries to clone that.

Whatever is serving https://www.gitexample.com/ needs to fix the meta-tags it is serving to point to the correct repository. See here for the protocol used. In particular, if you want to make a sub-directory of a repository go-gettable, vcs-prefix needs to be the import-path of the repository root and repo-root should be where to clone the repository from. So, you want to set up the server to serve the meta tag

<meta name="go-import" content="www.gitexample.com/comnap/public_service/short_url git https://www.gitexample.com/comnap/public_service/short_url.git">

on all urls starting with https://gitexample.com/comnap/public_service/short_url.

Does that help?

@ghost
Copy link
Author

ghost commented Sep 13, 2017

I checked the <meta, There is no <meta name="go-import" section.

@Merovius
Copy link
Contributor

Have you tried including the ?go-get=1? Because the log claims it found a meta-tag. (I would help verifying, but the domain does not resolve for me, apparently)

@Merovius
Copy link
Contributor

Try curl https://www.gitexample.com/comnap/public_service/short_url?go-get=1 | grep go-import (that's the url the log says it fetches). When I try to use go-get with a path that does not serve a meta-tag, it reports correctly that there is no meta-tag.

@ianlancetaylor
Copy link
Contributor

I'm going to close this issue because I don't see any fixable bug here. Please comment if you disagree. If you don't understand the meta-tag protocol that @Merovius mentions, please ask a on a forum; see https://golang.org/wiki/Questions. Thanks.

@arizonahanson
Copy link

arizonahanson commented Jan 21, 2018

I am having this exact issue. pretty critical for me right now:
(company dns/folder/project name changed)
my meta tag: <meta name="go-import" content="my.gitlab.com/top/sub/project git https://my.gitlab.com/top/sub/project.git" />

but it doesn't like the extra level it seems:

found meta tag get.metaImport{Prefix:"my.gitlab.com/top/sub", VCS:"git", RepoRoot:"https://my.gitlab.com/top/sub.git"} at https://my.gitlab.com/top/sub/project?go-get=1

I realize a real fix would have to wait for the next release, but if I could get a workaround for it, it would be a huge help.

@arizonahanson
Copy link

Ignore me. Gitlab issue.

@golang golang locked and limited conversation to collaborators Jan 22, 2019
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

4 participants