From 8874e414a80f7f29e3a8c8f00b3887399a7a6cbc Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Thu, 19 Feb 2015 08:13:56 -0600 Subject: sort project apps before merging deps --- src/rebar_utils.erl | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/rebar_utils.erl') diff --git a/src/rebar_utils.erl b/src/rebar_utils.erl index 85f59d6..943c0d7 100644 --- a/src/rebar_utils.erl +++ b/src/rebar_utils.erl @@ -26,7 +26,8 @@ %% ------------------------------------------------------------------- -module(rebar_utils). --export([droplast/1, +-export([sort_deps/1, + droplast/1, filtermap/2, is_arch/1, sh/2, @@ -56,11 +57,20 @@ -include("rebar.hrl"). -define(ONE_LEVEL_INDENT, " "). +-define(APP_NAME_INDEX, 2). %% ==================================================================== %% Public API %% ==================================================================== +sort_deps(Deps) -> + %% We need a sort stable, based on the name. So that for multiple deps on + %% the same level with the same name, we keep the order the parents had. + %% `lists:keysort/2' is documented as stable in the stdlib. + %% The list of deps is revered when we get it. For the proper stable + %% result, re-reverse it. + lists:keysort(?APP_NAME_INDEX, lists:reverse(Deps)). + droplast(L) -> lists:reverse(tl(lists:reverse(L))). -- cgit v1.1