This repository was archived by the owner on Sep 11, 2020. It is now read-only.
This repository was archived by the owner on Sep 11, 2020. It is now read-only.
Unable to clone from local repository #837
Open
Description
Host: Windows 10
Go Version: 1.10.1 windows/amd64
I am trying a simple flow
- Init a new repository in a local folder
- Clone that local repository to another location
However I seem to be unable to do so
Here's a reproducer
package main
import (
"fmt"
"io/ioutil"
"log"
"net/url"
"os"
git "gopkg.in/src-d/go-git.v4"
)
func main() {
srcPathName := "srcRepo"
dstPathName := "dstRepo"
// Create a local folder to store a temporary repository
srcPath, err := ioutil.TempDir("", srcPathName)
if err != nil {
log.Fatalf("Unable to create source folder: %s", err)
}
defer os.RemoveAll(srcPath)
// Init a new repo in the src folder
_, err = git.PlainInit(srcPath, false)
if err != nil {
log.Fatalf("Unable to init source repository: %s\n", err)
}
// Create destination clone directory
dstPath, err := ioutil.TempDir("", dstPathName)
if err != nil {
log.Fatalf("Unable to create destination repository: %s\n", err)
}
defer os.RemoveAll(dstPath)
// Get srcPath as a file: url to clone it
srcURL, _ := url.Parse(srcPath)
srcURL.Scheme = "file"
if err != nil {
log.Fatalf("Unable to parse source repo path: %s\n", err)
}
fmt.Printf("Attempting to clone from %s\n", srcURL.String())
// Attempt to clone local repo
_, err = git.PlainClone(dstPath, false, &git.CloneOptions{
URL: srcURL.String(),
RecurseSubmodules: git.DefaultSubmoduleRecursionDepth,
})
if err != nil {
log.Fatalf("Unable to clone repo: %s", err)
}
}
When I run this I get
Attempting to clone from file:\Users\USERNA~1\AppData\Local\Temp\dstRepo768183330
2018/05/17 23:33:39 Unable to clone repo: repository not found
I have also tried the following variations of the code to make sure I am not doing something wrong
- Init as bare
- Making the url in the format of
file:///C:\Users\USERNA~1\AppData\Local\Temp\dstRepo768183330
It is my understanding from looking at the compatibility matrix that the file:
protocol is supported.
Am I doing something wrong here, is this a bug or just not supported?