如何将Go Dep与GitLab子组一起使用 [英] How to use Go dep with GitLab subgroups
问题描述
我有一个Go项目,该项目需要来自git.mydomain.com/myteam/category/subcategory/project.git之类的私有GitLab存储库的某些依赖项. 但是我遇到了这个错误.
I have a Go project that requires some dependencies from a private GitLab repository like git.mydomain.com/myteam/category/subcategory/project.git. But I'm getting this error.
ensure Solve(): remote repository at https://git.mydomain.com/myteam/category.git does not exist or is inaccessible: : exit status 128
推荐答案
此问题在 GitLab支持跟踪器.
TL; DR; (故意)为私人存储库破坏:
TL;DR; It's (intentionally) broken for private repos:
[您的群组]是私人的吗?如果是这样,这是预期的行为,我建议您阅读 #1337(评论36293613)起.在这种情况下,我们决定以牺牲可用性为代价来最大化安全性/隐私性.推荐的解决方法是将.git专门添加到您的URL中.
Is [your group] private? If so, this is expected behavior, and I would recommend reading the discussion from #1337 (comment 36293613) onwards. In this case, we have decided to maximize security/privacy at the slight expense of usability. The recommended workaround is to specifically add .git to your URL.
The only solution I've found is to use dep
's support for .netrc
.
-
在具有 api 范围的GitLab上创建个人访问令牌:
Create a Personal Access token on GitLab with api scope:
创建一个~/.netrc
文件:
machine gitlab.com
login <your gitlab username>
password <the token created in step 1>
稍微保护您的.netrc
文件:
chmod 600 ~/.netrc
利润
Profit
这现在应该可以工作:
dep ensure -add gitlab.com/<company>/<subgroup>/<project>
如果您使用的是私人GitLab安装,我相信您会在适用的情况下用适当的主机名替换gitlab.com
.
If you're using a private GitLab installation, I trust you to replace gitlab.com
with the appropriate hostname where applicable.
这篇关于如何将Go Dep与GitLab子组一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!