diff options
-rw-r--r-- | src/rlx_depsolver.erl | 23 | ||||
-rw-r--r-- | test/rlx_depsolver_tester.erl | 20 |
2 files changed, 24 insertions, 19 deletions
diff --git a/src/rlx_depsolver.erl b/src/rlx_depsolver.erl index e054cc9..f9dc73d 100644 --- a/src/rlx_depsolver.erl +++ b/src/rlx_depsolver.erl @@ -214,14 +214,20 @@ add_package_version({?MODULE, Dom0}, RawPkg, RawVsn, RawPkgConstraints) -> Info2 = case gb_trees:lookup(Pkg, Dom0) of {value, Info0} -> - case lists:keytake(Vsn, 1, Info0) of - {value, {Vsn, Constraints}, Info1} -> - [{Vsn, join_constraints(Constraints, - PkgConstraints)} - | Info1]; - false -> - [{Vsn, PkgConstraints} | Info0] - end; + %% Sort Vsns from greatest to lowest + lists:reverse( + lists:sort(fun(X, Y) -> + ec_semver:lte(element(1, X), element(1, Y)) + end, + case lists:keytake(Vsn, 1, Info0) of + {value, {Vsn, Constraints}, Info1} -> + [{Vsn, join_constraints(Constraints, + PkgConstraints)} + | Info1]; + false -> + [{Vsn, PkgConstraints} | Info0] + + end)); none -> [{Vsn, PkgConstraints}] end, @@ -621,7 +627,6 @@ pkgs(DepGraph, Visited, Pkg, Constraints, OtherPkgs, PathInd) -> NewVisited = [{Pkg, Vsn} | Visited], Res = all_pkgs(DepGraph, NewVisited, DepPkgs ++ OtherPkgs, UConstraints, PathInd), Res - end, case constrained_package_versions(DepGraph, Pkg, Constraints) of [] -> diff --git a/test/rlx_depsolver_tester.erl b/test/rlx_depsolver_tester.erl index b441a1e..9b55603 100644 --- a/test/rlx_depsolver_tester.erl +++ b/test/rlx_depsolver_tester.erl @@ -61,12 +61,12 @@ data1_test() -> data2_test() -> ExpectedResult = versionify([{"app18","0.0.1"}, - {"app4","0.0.1"}, + {"app4","0.0.7"}, {"app1","0.0.1"}, {"app6","0.0.1"}, {"dep_pkg13","0.0.2"}, {"app13","0.0.1"}, - {"dep_pkg5","0.0.2"}, + {"dep_pkg5","0.0.3"}, {"dep_pkg1","0.0.2"}, {"dep_pkg2","0.0.5"}, {"dep_pkg7","0.1.2"}, @@ -82,12 +82,12 @@ data3_test() -> {"app38","0.0.1"}, {"app28","0.0.1"}, {"app18","0.0.1"}, - {"app4","0.0.1"}, + {"app4","0.0.7"}, {"app1","0.0.1"}, {"app6","0.0.1"}, {"dep_pkg13","0.0.2"}, {"app13","0.0.1"}, - {"dep_pkg5","0.0.2"}, + {"dep_pkg5","0.0.3"}, {"dep_pkg1","0.0.2"}, {"dep_pkg2","0.0.5"}, {"dep_pkg7","0.1.2"}, @@ -104,12 +104,12 @@ data4_test() -> {"app38","0.0.1"}, {"app28","0.0.1"}, {"app18","0.0.1"}, - {"app4","0.0.1"}, + {"app4","0.0.7"}, {"app1","0.0.1"}, {"app6","0.0.1"}, {"dep_pkg13","0.0.2"}, {"app13","0.0.1"}, - {"dep_pkg5","0.0.2"}, + {"dep_pkg5","0.0.3"}, {"dep_pkg1","0.0.2"}, {"dep_pkg2","0.0.5"}, {"dep_pkg7","0.1.2"}, @@ -129,12 +129,12 @@ data5_test() -> {"app38","0.0.1"}, {"app28","0.0.1"}, {"app18","0.0.1"}, - {"app4","0.0.1"}, + {"app4","0.0.7"}, {"app1","0.0.1"}, {"app6","0.0.1"}, {"dep_pkg13","0.0.2"}, {"app13","0.0.1"}, - {"dep_pkg5","0.0.2"}, + {"dep_pkg5","0.0.3"}, {"dep_pkg1","0.0.2"}, {"dep_pkg2","0.0.5"}, {"dep_pkg7","0.1.2"}, @@ -157,12 +157,12 @@ data6_test() -> {"app38","0.0.1"}, {"app28","0.0.1"}, {"app18","0.0.1"}, - {"app4","0.0.1"}, + {"app4","0.0.7"}, {"app1","0.0.1"}, {"app6","0.0.1"}, {"dep_pkg13","0.0.2"}, {"app13","0.0.1"}, - {"dep_pkg5","0.0.2"}, + {"dep_pkg5","0.0.3"}, {"dep_pkg1","0.0.2"}, {"dep_pkg2","0.0.5"}, {"dep_pkg7","0.1.2"}, |