summaryrefslogtreecommitdiff
path: root/clone.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-06-29 17:49:52 -0500
committerJeff Carr <[email protected]>2025-06-29 17:49:52 -0500
commit529eb104d505b0f93b2be7157a179c80a1668499 (patch)
tree0d1aa091785260f286f0034004ab980d27adabdd /clone.go
parent21dd7145146498182eaf977e00219ea3261bcaac (diff)
allow cloning http(s) URL'sv0.7.68v0.7.67v0.7.66v0.7.65
Diffstat (limited to 'clone.go')
-rw-r--r--clone.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/clone.go b/clone.go
index 5d80002..6c0fecc 100644
--- a/clone.go
+++ b/clone.go
@@ -5,6 +5,7 @@ import (
"fmt"
"os"
"path/filepath"
+ "strings"
"go.wit.com/lib/protobuf/gitpb"
"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) {
// if the user defined a repo, attempt to download it now
if gopath == "" {
@@ -49,6 +65,7 @@ func clone(gopath string) (*gitpb.Repo, error) {
// user probably wants to --recursive on current working dir
return nil, errors.New("gopath was blank")
}
+ gopath = CleanRepoURL(gopath)
os.Setenv("REPO_AUTO_CLONE", "true")
// pb, _ := forge.NewGoPath(gopath)
check := forge.FindAnyPath(filepath.Join(forge.GetGoSrc(), gopath))