[英]Using git2go clone on CloudRun
I'm trying to use https://github.com/libgit2/git2go for cloning repository from GCP Source repository我正在尝试使用https://github.com/libgit2/git2go从 GCP 源存储库克隆存储库
But, I'm getting failed to resolve path '/tmp/repo/.git/': No such file or directory"
但是,我
failed to resolve path '/tmp/repo/.git/': No such file or directory"
By using gcloud source repo clone, it works.通过使用 gcloud source repo clone,它可以工作。
func initRepo(url, path, auth string) (*git.Repository, error) {
var repo *git.Repository
var err error
osPath := "/tmp/" + path
repo, err = git.OpenRepository(osPath)
if err != nil {
repo, err = git.Clone(url, osPath, &git.CloneOptions{
FetchOptions: &git.FetchOptions{
Headers: []string{auth},
},
})
}
return repo, err
}
func main() {
ctx := context.Background()
ts, err := google.DefaultTokenSource(ctx, sourcerepo.SourceFullControlScope)
if err != nil {
panic(err)
}
token, err := ts.Token()
if err != nil {
panic(err)
}
auth := "Authorization: " + token.Type() + " " + token.AccessToken
gitRepo, err := initRepo("https://source.developers.google.com/p/project/r/repo", "repo", auth)
if err != nil {
panic(err)
}
What can cause this error?什么会导致此错误? Running on local machine it works, even in my docker container.
即使在我的 docker 容器中,它也可以在本地机器上运行。
I'm betting my buck on the git2go library you're using not being capable of creating a directory at /tmp/repo/.git/
.我将赌注押在您正在使用的 git2go 库上,该库无法在
/tmp/repo/.git/
创建目录。 Make sure to mkdir the /tmp/repo
first yourself maybe?确保自己先 mkdir
/tmp/repo
? Maybe /tmp
doesn't exist?也许
/tmp
不存在?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.