Skip to content
This repository has been archived by the owner on Feb 3, 2018. It is now read-only.

Commit

Permalink
Don't try to pop dep when it's the root
Browse files Browse the repository at this point in the history
Project-level cycles are fine, but we can't apply the same logic to
the root project as non-root projects when cleaning up the selection
while backtracking. Fixes #176.
  • Loading branch information
sdboyer committed Mar 4, 2017
1 parent 287edec commit eba751a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
27 changes: 27 additions & 0 deletions solve_bimodal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,33 @@ var bimodalFixtures = map[string]bimodalFixture{
"a 1.0.0",
),
},
"project cycle involving root with backtracking": {
ds: []depspec{
dsp(mkDepspec("root 0.0.0", "a ~1.0.0"),
pkg("root", "a", "b"),
pkg("root/foo"),
),
dsp(mkDepspec("a 1.0.0"),
pkg("a", "root/foo"),
),
dsp(mkDepspec("a 1.0.1"),
pkg("a", "root/foo"),
),
dsp(mkDepspec("b 1.0.0", "a 1.0.0"),
pkg("b", "a"),
),
dsp(mkDepspec("b 1.0.1", "a 1.0.0"),
pkg("b", "a"),
),
dsp(mkDepspec("b 1.0.2", "a 1.0.0"),
pkg("b", "a"),
),
},
r: mksolution(
"a 1.0.0",
"b 1.0.2",
),
},
"project cycle not involving root": {
ds: []depspec{
dsp(mkDepspec("root 0.0.0", "a ~1.0.0"),
Expand Down
6 changes: 6 additions & 0 deletions solver.go
Original file line number Diff line number Diff line change
Expand Up @@ -1152,6 +1152,12 @@ func (s *solver) unselectLast() (atomWithPackages, bool) {
}

for _, dep := range deps {
// Skip popping if the dep is the root project, which can occur if
// there's a project-level import cycle. (This occurs frequently with
// e.g. kubernetes and docker)
if s.rd.isRoot(dep.Ident.ProjectRoot) {
continue
}
s.sel.popDep(dep.Ident)

// if no parents/importers, remove from unselected queue
Expand Down

0 comments on commit eba751a

Please sign in to comment.