fix GraphFromTarget bug where empty DB would be used as identifier

This commit is contained in:
jguer 2022-11-16 01:03:57 +01:00
parent 481c63db91
commit 2805252365
No known key found for this signature in database
GPG Key ID: 6D6CC9BEA8556B35

View File

@ -126,16 +126,17 @@ func (g *Grapher) GraphFromTargets(ctx context.Context,
switch target.DB { switch target.DB {
case "": // unspecified db case "": // unspecified db
if g.dbExecutor.SyncPackage(target.Name) != nil { if pkg := g.dbExecutor.SyncPackage(target.Name); pkg != nil {
graph.AddNode(target.Name) dbName := pkg.DB().Name()
graph.AddNode(pkg.Name())
g.ValidateAndSetNodeInfo(graph, target.Name, &topo.NodeInfo[*InstallInfo]{ g.ValidateAndSetNodeInfo(graph, target.Name, &topo.NodeInfo[*InstallInfo]{
Color: colorMap[Explicit], Color: colorMap[Explicit],
Background: bgColorMap[AUR], Background: bgColorMap[Sync],
Value: &InstallInfo{ Value: &InstallInfo{
Source: Sync, Source: Sync,
Reason: Explicit, Reason: Explicit,
Version: target.Version, Version: pkg.Version(),
SyncDBName: &target.DB, SyncDBName: &dbName,
}, },
}) })
@ -149,7 +150,7 @@ func (g *Grapher) GraphFromTargets(ctx context.Context,
graph.AddNode(target.Name) graph.AddNode(target.Name)
g.ValidateAndSetNodeInfo(graph, target.Name, &topo.NodeInfo[*InstallInfo]{ g.ValidateAndSetNodeInfo(graph, target.Name, &topo.NodeInfo[*InstallInfo]{
Color: colorMap[Explicit], Color: colorMap[Explicit],
Background: bgColorMap[AUR], Background: bgColorMap[Sync],
Value: &InstallInfo{ Value: &InstallInfo{
Source: Sync, Source: Sync,
Reason: Explicit, Reason: Explicit,