From 1f780dfa8833a9ddc561afe89df1084dd49eb2c4 Mon Sep 17 00:00:00 2001 From: Albin Hedman Date: Tue, 5 Nov 2024 19:40:48 +0100 Subject: [PATCH 1/2] cargo registry - respect renamed dependencies --- modules/packages/cargo/parser.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/packages/cargo/parser.go b/modules/packages/cargo/parser.go index 36cd44df847aa..e1530cb44239a 100644 --- a/modules/packages/cargo/parser.go +++ b/modules/packages/cargo/parser.go @@ -137,7 +137,7 @@ func parsePackage(r io.Reader) (*Package, error) { dependencies := make([]*Dependency, 0, len(meta.Deps)) for _, dep := range meta.Deps { dependencies = append(dependencies, &Dependency{ - Name: dep.Name, + Name: dep.ExplicitNameInToml, Req: dep.VersionReq, Features: dep.Features, Optional: dep.Optional, @@ -145,6 +145,7 @@ func parsePackage(r io.Reader) (*Package, error) { Target: dep.Target, Kind: dep.Kind, Registry: dep.Registry, + Package: &dep.Name, }) } From b1904aabb67086679bf43e5a4b473c61c8f1116f Mon Sep 17 00:00:00 2001 From: Albin Hedman Date: Tue, 5 Nov 2024 22:28:59 +0100 Subject: [PATCH 2/2] cargo registry - name should default to dep.name when not renamed --- modules/packages/cargo/parser.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/modules/packages/cargo/parser.go b/modules/packages/cargo/parser.go index e1530cb44239a..d397aa96080ff 100644 --- a/modules/packages/cargo/parser.go +++ b/modules/packages/cargo/parser.go @@ -136,8 +136,14 @@ func parsePackage(r io.Reader) (*Package, error) { dependencies := make([]*Dependency, 0, len(meta.Deps)) for _, dep := range meta.Deps { + name := dep.ExplicitNameInToml + pkg := &dep.Name + if len(dep.ExplicitNameInToml) == 0 { + name = dep.Name + pkg = nil + } dependencies = append(dependencies, &Dependency{ - Name: dep.ExplicitNameInToml, + Name: name, Req: dep.VersionReq, Features: dep.Features, Optional: dep.Optional, @@ -145,7 +151,7 @@ func parsePackage(r io.Reader) (*Package, error) { Target: dep.Target, Kind: dep.Kind, Registry: dep.Registry, - Package: &dep.Name, + Package: pkg, }) }