From 0e30e6a1adbcd8c12793df8483701d2881d38463 Mon Sep 17 00:00:00 2001 From: Ettore Di Giacinto Date: Fri, 31 Jan 2020 20:50:55 +0100 Subject: [PATCH] Treat single conflict cases as well when building conflict formula --- pkg/package/package.go | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/pkg/package/package.go b/pkg/package/package.go index 24811622..3f454307 100644 --- a/pkg/package/package.go +++ b/pkg/package/package.go @@ -536,20 +536,25 @@ func (pack *DefaultPackage) BuildFormula(definitiondb PackageDatabase, db Packag if err != nil || len(packages) == 0 { required = requiredDef } else { - for _, p := range packages { - encodedB, err := p.Encode(db) - if err != nil { - return nil, err - } - B := bf.Var(encodedB) - formulas = append(formulas, bf.Or(bf.Not(A), - bf.Not(B))) + if len(packages) == 1 { + required = packages[0] + } else { + for _, p := range packages { + encodedB, err := p.Encode(db) + if err != nil { + return nil, err + } + B := bf.Var(encodedB) + formulas = append(formulas, bf.Or(bf.Not(A), + bf.Not(B))) - f, err := p.BuildFormula(definitiondb, db) - if err != nil { - return nil, err + f, err := p.BuildFormula(definitiondb, db) + if err != nil { + return nil, err + } + formulas = append(formulas, f...) } - formulas = append(formulas, f...) + continue } } }