From 3030e66d4cb5ab565bfbb0fe4edeac7250e765b9 Mon Sep 17 00:00:00 2001 From: Andrey Smirnov Date: Tue, 26 Aug 2014 19:25:02 +0400 Subject: [PATCH] Fix -with-deps searching. #81 --- cmd/snapshot_search.go | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/cmd/snapshot_search.go b/cmd/snapshot_search.go index 853d2c15..5768d65e 100644 --- a/cmd/snapshot_search.go +++ b/cmd/snapshot_search.go @@ -6,6 +6,7 @@ import ( "github.com/smira/aptly/query" "github.com/smira/commander" "github.com/smira/flag" + "sort" ) func aptlySnapshotMirrorRepoSearch(cmd *commander.Command, args []string) error { @@ -72,8 +73,25 @@ func aptlySnapshotMirrorRepoSearch(cmd *commander.Command, args []string) error return fmt.Errorf("unable to search: %s", err) } - result, err := list.Filter([]deb.PackageQuery{q}, context.flags.Lookup("with-deps").Value.Get().(bool), - nil, context.DependencyOptions(), context.ArchitecturesList()) + withDeps := context.flags.Lookup("with-deps").Value.Get().(bool) + architecturesList := []string{} + + if withDeps { + if len(context.ArchitecturesList()) > 0 { + architecturesList = context.ArchitecturesList() + } else { + architecturesList = list.Architectures(false) + } + + sort.Strings(architecturesList) + + if len(architecturesList) == 0 { + return fmt.Errorf("unable to determine list of architectures, please specify explicitly") + } + } + + result, err := list.Filter([]deb.PackageQuery{q}, withDeps, + nil, context.DependencyOptions(), architecturesList) if err != nil { return fmt.Errorf("unable to search: %s", err) }