go-git icon indicating copy to clipboard operation
go-git copied to clipboard

Mapping from a PlainClone to Clone

Open purpleidea opened this issue 5 years ago • 1 comments

Hi,

I currently use a

repo, err := git.PlainClone(dir, isBare, options)

with great, success. Thanks! This uses the local OS filesystem, and I'd like to use one of the Fs interfaces instead. It seems you have your own named billy. I'm using Afero. That's okay, because there's now a wrapper, so I can do:

billyFs := desfacer.New(myAferoFs)

The problem is actually how do I add a billyFs to a clone? I found this:

repo, err := git.Clone(s storage.Storer, billyFs, options)

But I have no idea how to get the storage.Storer... I have a path. So what's the equivalency of PlainClone but using a billyfs?

Thanks!

purpleidea avatar Dec 19 '18 13:12 purpleidea

I'm having same issue. I have tried something like this:

cache := cache.NewObjectLRUDefault()
billyfs := desfacer.NewPath(fs, path)
storer := filesystem.NewStorage(billyfs, cache)
_, err = git.Clone(storer, billyfs, &git.CloneOptions{
	URL:           repoURL,
})

But I'm always having repository already exists error.

arodriguezdlc avatar Dec 09 '19 13:12 arodriguezdlc