allow cloning http(s) URL's
This commit is contained in:
parent
21dd714514
commit
529eb104d5
17
clone.go
17
clone.go
|
@ -5,6 +5,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"go.wit.com/lib/protobuf/gitpb"
|
"go.wit.com/lib/protobuf/gitpb"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
|
@ -42,6 +43,21 @@ git bug user
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// CleanRepoURL removes http://, https://, and .git suffix from the given URL if present.
|
||||||
|
func CleanRepoURL(url string) string {
|
||||||
|
// Trim protocol prefix
|
||||||
|
if strings.HasPrefix(url, "http://") {
|
||||||
|
url = strings.TrimPrefix(url, "http://")
|
||||||
|
} else if strings.HasPrefix(url, "https://") {
|
||||||
|
url = strings.TrimPrefix(url, "https://")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Trim trailing .git
|
||||||
|
url = strings.TrimSuffix(url, ".git")
|
||||||
|
|
||||||
|
return url
|
||||||
|
}
|
||||||
|
|
||||||
func clone(gopath string) (*gitpb.Repo, error) {
|
func clone(gopath string) (*gitpb.Repo, error) {
|
||||||
// if the user defined a repo, attempt to download it now
|
// if the user defined a repo, attempt to download it now
|
||||||
if gopath == "" {
|
if gopath == "" {
|
||||||
|
@ -49,6 +65,7 @@ func clone(gopath string) (*gitpb.Repo, error) {
|
||||||
// user probably wants to --recursive on current working dir
|
// user probably wants to --recursive on current working dir
|
||||||
return nil, errors.New("gopath was blank")
|
return nil, errors.New("gopath was blank")
|
||||||
}
|
}
|
||||||
|
gopath = CleanRepoURL(gopath)
|
||||||
os.Setenv("REPO_AUTO_CLONE", "true")
|
os.Setenv("REPO_AUTO_CLONE", "true")
|
||||||
// pb, _ := forge.NewGoPath(gopath)
|
// pb, _ := forge.NewGoPath(gopath)
|
||||||
check := forge.FindAnyPath(filepath.Join(forge.GetGoSrc(), gopath))
|
check := forge.FindAnyPath(filepath.Join(forge.GetGoSrc(), gopath))
|
||||||
|
|
Loading…
Reference in New Issue