diff --git a/internal/github/api.go b/internal/github/api.go index 13d385e..5ba9582 100644 --- a/internal/github/api.go +++ b/internal/github/api.go @@ -18,15 +18,24 @@ const ( ProtoPortDir = "ProtoPort" ) -func GithubGetContent(url string, subpath string, pat string, publicRepo bool) ([]types.GithubContentApi, error) { - var contents []types.GithubContentApi +func GithubUrlParser(url string, subpath string) string { + + url = strings.Replace(url, "/tree/main", "/contents", 1) if subpath != "" { - url = strings.Replace(url, "https://github.com/", "https://api.github.com/repos/", 1) + "/contents/" + subpath + url = strings.Replace(url, "https://github.com/", "https://api.github.com/repos/", 1) + subpath } else { - url = strings.Replace(url, "https://github.com/", "https://api.github.com/repos/", 1) + "/contents" + url = strings.Replace(url, "https://github.com/", "https://api.github.com/repos/", 1) } + return url +} + +func GithubGetContent(url string, subpath string, pat string, publicRepo bool) ([]types.GithubContentApi, error) { + var contents []types.GithubContentApi + + url = GithubUrlParser(url, subpath) + req, err := http.NewRequest("GET", url, nil) if err != nil { diff --git a/internal/protoc/build.go b/internal/protoc/build.go index df963a1..6fca743 100644 --- a/internal/protoc/build.go +++ b/internal/protoc/build.go @@ -4,6 +4,7 @@ import ( "bytes" "errors" "fmt" + "log" "os" "os/exec" "path/filepath" @@ -94,6 +95,7 @@ func BuildProto(protoPath, output, protoFile string, lang string) error { command.Stderr = &stderr err := command.Run() if err != nil { + log.Println(fmt.Sprint(err) + ": " + stderr.String()) return fmt.Errorf("error building proto file") }