hashicorp / go-getter

Package for downloading things from a string URL using a variety of protocols.
Mozilla Public License 2.0
1.65k stars 232 forks source link

Getting git: 'remote-git' is not a git command on gitGetter.Get() #423

Open ahsan-n opened 1 year ago

ahsan-n commented 1 year ago

Hi, trying to download dir from git with following code:

    detector := getter.GitHubDetector{}

    detect, b, err := detector.Detect("github.com/user/modules.git//onboarding?ref=32.1.0", "")

    if err != nil{
        log.Printf("unable to download %v", detect)
    }
    fmt.Println(detect, b)

    parse, err := url.Parse(detect)
    if err != nil {
        log.Printf("asd %v", err)
    }
    fmt.Println(parse.Host)

    gitGetter := getter.GitGetter{Timeout: time.Duration(0)}

    err = gitGetter.Get("./service-onboarding", parse)
    if err != nil {
        log.Printf("issue %v", err)
    }

but getting the error:

2023/03/03 16:11:41 issue /opt/homebrew/bin/git exited with 128: Cloning into './service-onboarding'...
git: 'remote-git' is not a git command. See 'git --help'.

The most similar command is
        remote-ext

Wondering what I am missing, running in Mac os

ljluestc commented 1 year ago

package main

import ( "fmt" "log" "net/url" "time"

"github.com/hashicorp/go-getter"

)

func main() { detector := getter.GitHubDetector{}

detect, b, err := detector.Detect("github.com/user/modules.git//onboarding?ref=32.1.0", "")
if err != nil {
    log.Printf("unable to download %v", detect)
}
fmt.Println(detect, b)

parse, err := url.Parse(detect)
if err != nil {
    log.Printf("asd %v", err)
}
fmt.Println(parse.Host)

gitGetter := getter.GitGetter{Timeout: time.Duration(0)}

// Update the Git URL to the correct one without any reference to remote-git
gitURL := "https://" + parse.Host + parse.Path
err = gitGetter.Get("./service-onboarding", gitURL)
if err != nil {
    log.Printf("issue %v", err)
}

}