parent
7696c03c25
commit
c3a1c5ebe9
|
|
@ -127,16 +127,21 @@ func Parse(goGetterSrc string) (*Source, error) {
|
||||||
var sourceDir, sourceFile string
|
var sourceDir, sourceFile string
|
||||||
pathComponents := strings.Split(u.Path, "@")
|
pathComponents := strings.Split(u.Path, "@")
|
||||||
|
|
||||||
switch len(pathComponents) {
|
if len(pathComponents) != 2 {
|
||||||
case 1:
|
if strings.HasSuffix(u.Path, ".git") {
|
||||||
sourceDir = pathComponents[0]
|
pathComponents = []string{u.Path, ""}
|
||||||
case 2:
|
} else {
|
||||||
sourceDir = pathComponents[0]
|
dir := filepath.Dir(u.Path)
|
||||||
sourceFile = pathComponents[1]
|
if len(dir) > 0 {
|
||||||
default:
|
dir = dir[1:]
|
||||||
return nil, InvalidURLError{err: fmt.Sprintf("parse url: invalid path %s", u.Path)}
|
}
|
||||||
|
pathComponents = []string{dir, filepath.Base(u.Path)}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sourceDir = pathComponents[0]
|
||||||
|
sourceFile = pathComponents[1]
|
||||||
|
|
||||||
return &Source{
|
return &Source{
|
||||||
Getter: getter,
|
Getter: getter,
|
||||||
User: u.User.String(),
|
User: u.User.String(),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue