chore(topo): move topo to where it's used (#2250)

move topo into dep
This commit is contained in:
Jo 2023-07-23 22:20:05 +02:00 committed by GitHub
parent 04c82b8112
commit 5995e55ddb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 15 additions and 12 deletions

View File

@ -15,7 +15,6 @@ import (
"github.com/Jguer/yay/v12/pkg/settings" "github.com/Jguer/yay/v12/pkg/settings"
"github.com/Jguer/yay/v12/pkg/settings/exe" "github.com/Jguer/yay/v12/pkg/settings/exe"
"github.com/Jguer/yay/v12/pkg/settings/parser" "github.com/Jguer/yay/v12/pkg/settings/parser"
"github.com/Jguer/yay/v12/pkg/topo"
gosrc "github.com/Morganamilo/go-srcinfo" gosrc "github.com/Morganamilo/go-srcinfo"
"github.com/leonelquinteros/gotext" "github.com/leonelquinteros/gotext"
@ -85,7 +84,7 @@ func installLocalPKGBUILD(
grapher := dep.NewGrapher(dbExecutor, aurCache, false, settings.NoConfirm, grapher := dep.NewGrapher(dbExecutor, aurCache, false, settings.NoConfirm,
cmdArgs.ExistsDouble("d", "nodeps"), noCheck, cmdArgs.ExistsArg("needed"), cmdArgs.ExistsDouble("d", "nodeps"), noCheck, cmdArgs.ExistsArg("needed"),
config.Runtime.Logger.Child("grapher")) config.Runtime.Logger.Child("grapher"))
graph := topo.New[string, *dep.InstallInfo]() graph := dep.NewGraph()
graph, err := grapher.GraphFromSrcInfos(ctx, graph, srcInfos) graph, err := grapher.GraphFromSrcInfos(ctx, graph, srcInfos)
if err != nil { if err != nil {
return err return err

View File

@ -12,10 +12,10 @@ import (
"github.com/leonelquinteros/gotext" "github.com/leonelquinteros/gotext"
"github.com/Jguer/yay/v12/pkg/db" "github.com/Jguer/yay/v12/pkg/db"
"github.com/Jguer/yay/v12/pkg/dep/topo"
"github.com/Jguer/yay/v12/pkg/intrange" "github.com/Jguer/yay/v12/pkg/intrange"
aur "github.com/Jguer/yay/v12/pkg/query" aur "github.com/Jguer/yay/v12/pkg/query"
"github.com/Jguer/yay/v12/pkg/text" "github.com/Jguer/yay/v12/pkg/text"
"github.com/Jguer/yay/v12/pkg/topo"
) )
type InstallInfo struct { type InstallInfo struct {
@ -123,11 +123,15 @@ func NewGrapher(dbExecutor db.Executor, aurCache aurc.QueryClient,
} }
} }
func NewGraph() *topo.Graph[string, *InstallInfo] {
return topo.New[string, *InstallInfo]()
}
func (g *Grapher) GraphFromTargets(ctx context.Context, func (g *Grapher) GraphFromTargets(ctx context.Context,
graph *topo.Graph[string, *InstallInfo], targets []string, graph *topo.Graph[string, *InstallInfo], targets []string,
) (*topo.Graph[string, *InstallInfo], error) { ) (*topo.Graph[string, *InstallInfo], error) {
if graph == nil { if graph == nil {
graph = topo.New[string, *InstallInfo]() graph = NewGraph()
} }
aurTargets := make([]string, 0, len(targets)) aurTargets := make([]string, 0, len(targets))
@ -236,7 +240,7 @@ func (g *Grapher) GraphFromSrcInfos(ctx context.Context, graph *topo.Graph[strin
srcInfos map[string]*gosrc.Srcinfo, srcInfos map[string]*gosrc.Srcinfo,
) (*topo.Graph[string, *InstallInfo], error) { ) (*topo.Graph[string, *InstallInfo], error) {
if graph == nil { if graph == nil {
graph = topo.New[string, *InstallInfo]() graph = NewGraph()
} }
aurPkgsAdded := []*aurc.Pkg{} aurPkgsAdded := []*aurc.Pkg{}
@ -314,7 +318,7 @@ func (g *Grapher) GraphSyncPkg(ctx context.Context,
pkg alpm.IPackage, upgradeInfo *db.SyncUpgrade, pkg alpm.IPackage, upgradeInfo *db.SyncUpgrade,
) *topo.Graph[string, *InstallInfo] { ) *topo.Graph[string, *InstallInfo] {
if graph == nil { if graph == nil {
graph = topo.New[string, *InstallInfo]() graph = NewGraph()
} }
graph.AddNode(pkg.Name()) graph.AddNode(pkg.Name())
@ -356,7 +360,7 @@ func (g *Grapher) GraphSyncGroup(ctx context.Context,
groupName, dbName string, groupName, dbName string,
) *topo.Graph[string, *InstallInfo] { ) *topo.Graph[string, *InstallInfo] {
if graph == nil { if graph == nil {
graph = topo.New[string, *InstallInfo]() graph = NewGraph()
} }
graph.AddNode(groupName) graph.AddNode(groupName)
@ -381,7 +385,7 @@ func (g *Grapher) GraphAURTarget(ctx context.Context,
pkg *aurc.Pkg, instalInfo *InstallInfo, pkg *aurc.Pkg, instalInfo *InstallInfo,
) *topo.Graph[string, *InstallInfo] { ) *topo.Graph[string, *InstallInfo] {
if graph == nil { if graph == nil {
graph = topo.New[string, *InstallInfo]() graph = NewGraph()
} }
graph.AddNode(pkg.Name) graph.AddNode(pkg.Name)
@ -402,7 +406,7 @@ func (g *Grapher) GraphFromAUR(ctx context.Context,
targets []string, targets []string,
) (*topo.Graph[string, *InstallInfo], error) { ) (*topo.Graph[string, *InstallInfo], error) {
if graph == nil { if graph == nil {
graph = topo.New[string, *InstallInfo]() graph = NewGraph()
} }
if len(targets) == 0 { if len(targets) == 0 {

View File

@ -14,12 +14,12 @@ import (
"github.com/Jguer/yay/v12/pkg/db" "github.com/Jguer/yay/v12/pkg/db"
"github.com/Jguer/yay/v12/pkg/dep" "github.com/Jguer/yay/v12/pkg/dep"
"github.com/Jguer/yay/v12/pkg/dep/topo"
"github.com/Jguer/yay/v12/pkg/intrange" "github.com/Jguer/yay/v12/pkg/intrange"
"github.com/Jguer/yay/v12/pkg/multierror" "github.com/Jguer/yay/v12/pkg/multierror"
"github.com/Jguer/yay/v12/pkg/query" "github.com/Jguer/yay/v12/pkg/query"
"github.com/Jguer/yay/v12/pkg/settings" "github.com/Jguer/yay/v12/pkg/settings"
"github.com/Jguer/yay/v12/pkg/text" "github.com/Jguer/yay/v12/pkg/text"
"github.com/Jguer/yay/v12/pkg/topo"
"github.com/Jguer/yay/v12/pkg/vcs" "github.com/Jguer/yay/v12/pkg/vcs"
) )
@ -238,7 +238,7 @@ func (u *UpgradeService) GraphUpgrades(ctx context.Context,
enableDowngrade bool, filter Filter, enableDowngrade bool, filter Filter,
) (*topo.Graph[string, *dep.InstallInfo], error) { ) (*topo.Graph[string, *dep.InstallInfo], error) {
if graph == nil { if graph == nil {
graph = topo.New[string, *dep.InstallInfo]() graph = dep.NewGraph()
} }
err := u.upGraph(ctx, graph, enableDowngrade, filter) err := u.upGraph(ctx, graph, enableDowngrade, filter)

View File

@ -18,11 +18,11 @@ import (
"github.com/Jguer/yay/v12/pkg/db" "github.com/Jguer/yay/v12/pkg/db"
"github.com/Jguer/yay/v12/pkg/db/mock" "github.com/Jguer/yay/v12/pkg/db/mock"
"github.com/Jguer/yay/v12/pkg/dep" "github.com/Jguer/yay/v12/pkg/dep"
"github.com/Jguer/yay/v12/pkg/dep/topo"
"github.com/Jguer/yay/v12/pkg/query" "github.com/Jguer/yay/v12/pkg/query"
"github.com/Jguer/yay/v12/pkg/settings" "github.com/Jguer/yay/v12/pkg/settings"
"github.com/Jguer/yay/v12/pkg/settings/parser" "github.com/Jguer/yay/v12/pkg/settings/parser"
"github.com/Jguer/yay/v12/pkg/text" "github.com/Jguer/yay/v12/pkg/text"
"github.com/Jguer/yay/v12/pkg/topo"
"github.com/Jguer/yay/v12/pkg/vcs" "github.com/Jguer/yay/v12/pkg/vcs"
mockaur "github.com/Jguer/yay/v12/pkg/dep/mock" mockaur "github.com/Jguer/yay/v12/pkg/dep/mock"