|
@@ -21,39 +21,49 @@ func init() {
|
|
buildme.RegisterFetcher("git", &Git{})
|
|
buildme.RegisterFetcher("git", &Git{})
|
|
}
|
|
}
|
|
|
|
|
|
-type Git struct {
|
|
|
|
-}
|
|
|
|
|
|
+type Git struct{}
|
|
|
|
|
|
// Fetcher return a project
|
|
// Fetcher return a project
|
|
func (g *Git) Fetch(fpath string) (*buildme.Project, error) {
|
|
func (g *Git) Fetch(fpath string) (*buildme.Project, error) {
|
|
log.Println("Building git repo:", fpath)
|
|
log.Println("Building git repo:", fpath)
|
|
|
|
|
|
- projName := filepath.Base(fpath)
|
|
|
|
|
|
+ // File possibilities, does not cover the folder/subfolder
|
|
|
|
+ if fpath == "." || fpath[0:2] == "./" || fpath[0] == '/' {
|
|
|
|
+ absPath, err := filepath.Abs(fpath)
|
|
|
|
+ if err != nil {
|
|
|
|
+ return nil, err
|
|
|
|
+ }
|
|
|
|
+ fpath = "file://" + absPath
|
|
|
|
+ }
|
|
|
|
|
|
- tmpdir, err := ioutil.TempDir("/tmp", "buildme.")
|
|
|
|
|
|
+ // Create tmpdir to clone project
|
|
|
|
+ tmpdirname, err := ioutil.TempDir("/tmp", "buildme.")
|
|
if err != nil {
|
|
if err != nil {
|
|
return nil, err
|
|
return nil, err
|
|
}
|
|
}
|
|
|
|
|
|
- log.Println("Cloning to:", tmpdir)
|
|
|
|
- git.PlainClone(tmpdir, false, &git.CloneOptions{
|
|
|
|
- URL: fpath,
|
|
|
|
- Progress: os.Stdout,
|
|
|
|
- })
|
|
|
|
|
|
+ log.Println("Cloning to:", tmpdirname)
|
|
|
|
+ _, err = git.PlainClone(tmpdirname, false, &git.CloneOptions{URL: fpath, Progress: os.Stdout})
|
|
|
|
+ if err != nil {
|
|
|
|
+ log.Println("Err:", err)
|
|
|
|
+ return nil, err
|
|
|
|
+ }
|
|
|
|
+ projName := filepath.Base(fpath)
|
|
|
|
+ //git.
|
|
|
|
|
|
log.Println("Taring content")
|
|
log.Println("Taring content")
|
|
|
|
|
|
/*tarfile, err := ioutil.TempFile("/tmp", "tarbuildme.")
|
|
/*tarfile, err := ioutil.TempFile("/tmp", "tarbuildme.")
|
|
reader, err := utils.TarDir(tmpdir, tarfile)*/
|
|
reader, err := utils.TarDir(tmpdir, tarfile)*/
|
|
-
|
|
|
|
- tarFile, err := utils.TempTar(tmpdir, os.TempDir(), "buildme.tar")
|
|
|
|
|
|
+ // Create a temporary tar file from tmpdirname
|
|
|
|
+ tarFile, err := utils.TempTar(tmpdirname, os.TempDir(), "buildme.tar")
|
|
log.Println("Tar file:", tarFile.Name())
|
|
log.Println("Tar file:", tarFile.Name())
|
|
|
|
|
|
- log.Println("Removing dir", tmpdir)
|
|
|
|
- os.RemoveAll(tmpdir)
|
|
|
|
|
|
+ log.Println("Removing dir", tmpdirname)
|
|
|
|
+ os.RemoveAll(tmpdirname)
|
|
|
|
|
|
proj := buildme.NewProject(projName)
|
|
proj := buildme.NewProject(projName)
|
|
- proj.SetTarFile(tarFile.Name(), true)
|
|
|
|
|
|
+ proj.SetTarFile(tarFile.Name(), true) // Set as temporary will delete as soon as project closes
|
|
|
|
|
|
return proj, nil
|
|
return proj, nil
|
|
}
|
|
}
|