From c3a1c5ebe907819a95fe8eff20f71f3b77db1d28 Mon Sep 17 00:00:00 2001 From: yxxhero Date: Mon, 12 Feb 2024 08:49:12 +0800 Subject: [PATCH] fix issues Signed-off-by: yxxhero --- pkg/remote/remote.go | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/pkg/remote/remote.go b/pkg/remote/remote.go index ab475517..cddd2bd2 100644 --- a/pkg/remote/remote.go +++ b/pkg/remote/remote.go @@ -127,16 +127,21 @@ func Parse(goGetterSrc string) (*Source, error) { var sourceDir, sourceFile string pathComponents := strings.Split(u.Path, "@") - switch len(pathComponents) { - case 1: - sourceDir = pathComponents[0] - case 2: - sourceDir = pathComponents[0] - sourceFile = pathComponents[1] - default: - return nil, InvalidURLError{err: fmt.Sprintf("parse url: invalid path %s", u.Path)} + if len(pathComponents) != 2 { + if strings.HasSuffix(u.Path, ".git") { + pathComponents = []string{u.Path, ""} + } else { + dir := filepath.Dir(u.Path) + if len(dir) > 0 { + dir = dir[1:] + } + pathComponents = []string{dir, filepath.Base(u.Path)} + } } + sourceDir = pathComponents[0] + sourceFile = pathComponents[1] + return &Source{ Getter: getter, User: u.User.String(),