diff options
author | Fred Hebert <mononcqc@ferd.ca> | 2015-03-15 04:47:13 +0000 |
---|---|---|
committer | Fred Hebert <mononcqc@ferd.ca> | 2015-03-15 04:47:13 +0000 |
commit | bc98ea22aa15406e4cb05e460b72772d40871f4e (patch) | |
tree | 5bef86eb992e3203dc17da7cfa687edc82cb71be | |
parent | 6e337e022c3c4521ee84121845305b494127aaf2 (diff) |
Avoid duplicating deps in discover phase
The deps are sorted and merged, but the merge function merges lists, not
elements. This yields deps that are duplicated and ran for multiple
times.
We first add proper sorts so the keymerge is guaranteed to be fine, and
then do a dedup run to get rid of duplicates if they happen to be.
-rw-r--r-- | src/rebar_app_discover.erl | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/rebar_app_discover.erl b/src/rebar_app_discover.erl index 63cf703..0799313 100644 --- a/src/rebar_app_discover.erl +++ b/src/rebar_app_discover.erl @@ -48,7 +48,9 @@ merge_deps(AppInfo, State) -> State1 = lists:foldl(fun(Profile, StateAcc) -> AppProfDeps = rebar_state:get(AppState, {deps, Profile}, []), TopLevelProfDeps = rebar_state:get(StateAcc, {deps, Profile}, []), - ProfDeps2 = lists:keymerge(1, TopLevelProfDeps, AppProfDeps), + ProfDeps2 = dedup(lists:keymerge(1, + lists:keysort(1, TopLevelProfDeps), + lists:keysort(1, AppProfDeps))), rebar_state:set(StateAcc, {deps, Profile}, ProfDeps2) end, State, lists:reverse(CurrentProfiles)), @@ -166,3 +168,8 @@ create_app_info(AppDir, AppFile) -> _ -> error end. + +dedup([]) -> []; +dedup([A]) -> [A]; +dedup([H,H|T]) -> dedup([H|T]); +dedup([H|T]) -> [H|dedup(T)]. |