Cut out versioning from dependency name if it was found in last element of path.
E.g. "github.com/user/repo/v2" will became "github.com/user/repo". This is needed for getting go-import/go-source data.
This commit is contained in:
parent
47ba507e05
commit
3e4df90945
@ -83,6 +83,14 @@ func (gp *golangParser) getDependenciesFromDep(pkgPath string) []*structs.Depend
|
|||||||
Version: dep.Version,
|
Version: dep.Version,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Name is used in URLs composing, so we should get rid of
|
||||||
|
// possible versioning from it, which will occur if dependency
|
||||||
|
// supports both go modules and other dependency managers.
|
||||||
|
depName := strings.Split(dependency.Name, "/")
|
||||||
|
if strings.HasPrefix(depName[len(depName)-1], "v") && len(depName[len(depName)-1]) == 2 {
|
||||||
|
dependency.Name = strings.Join(depName[:len(depName)-1], "/")
|
||||||
|
}
|
||||||
|
|
||||||
// If branch is empty - assume master.
|
// If branch is empty - assume master.
|
||||||
if dependency.VCS.Branch == "" {
|
if dependency.VCS.Branch == "" {
|
||||||
dependency.VCS.Branch = "master"
|
dependency.VCS.Branch = "master"
|
||||||
|
@ -93,6 +93,14 @@ func (gp *golangParser) getDependenciesFromModules(pkgPath string) []*structs.De
|
|||||||
Version: version,
|
Version: version,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Name is used in URLs composing, so we should get rid of
|
||||||
|
// possible versioning from it, which will occur if dependency
|
||||||
|
// supports both go modules and other dependency managers.
|
||||||
|
depName := strings.Split(dependency.Name, "/")
|
||||||
|
if strings.HasPrefix(depName[len(depName)-1], "v") && len(depName[len(depName)-1]) == 2 {
|
||||||
|
dependency.Name = strings.Join(depName[:len(depName)-1], "/")
|
||||||
|
}
|
||||||
|
|
||||||
deps = append(deps, dependency)
|
deps = append(deps, dependency)
|
||||||
|
|
||||||
// Mark dependency as processed.
|
// Mark dependency as processed.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user