From 3146a285fb1c9e0028a9c09977c6da11df76d6e6 Mon Sep 17 00:00:00 2001 From: Pierre Fenoll Date: Sat, 10 Feb 2018 23:02:32 +0100 Subject: sort-as: force an order on multiple profiles --- src/rebar_dir.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/rebar_dir.erl b/src/rebar_dir.erl index d7be423..ee4d3d4 100644 --- a/src/rebar_dir.erl +++ b/src/rebar_dir.erl @@ -49,7 +49,7 @@ profile_dir(Opts, Profiles) -> %% of profiles to match order passed to `as` ["default"|Rest] -> {rebar_opts:get(Opts, base_dir, ?DEFAULT_BASE_DIR), Rest} end, - ProfilesDir = rebar_string:join(ProfilesStrings, "+"), + ProfilesDir = rebar_string:join(lists:sort(ProfilesStrings), "+"), filename:join(BaseDir, ProfilesDir). %% @doc returns the directory where dependencies should be placed -- cgit v1.1 From 9f0e3a2e5b6ea3eccda14660bc64570738ee7796 Mon Sep 17 00:00:00 2001 From: Pierre Fenoll Date: Fri, 16 Feb 2018 17:48:17 +0100 Subject: Revert "sort-as: force an order on multiple profiles" This reverts commit 3f8dd5eacebb913144f3615fdf44658b6223a791. --- src/rebar_dir.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/rebar_dir.erl b/src/rebar_dir.erl index ee4d3d4..d7be423 100644 --- a/src/rebar_dir.erl +++ b/src/rebar_dir.erl @@ -49,7 +49,7 @@ profile_dir(Opts, Profiles) -> %% of profiles to match order passed to `as` ["default"|Rest] -> {rebar_opts:get(Opts, base_dir, ?DEFAULT_BASE_DIR), Rest} end, - ProfilesDir = rebar_string:join(lists:sort(ProfilesStrings), "+"), + ProfilesDir = rebar_string:join(ProfilesStrings, "+"), filename:join(BaseDir, ProfilesDir). %% @doc returns the directory where dependencies should be placed -- cgit v1.1 From e504ba71e152a1e47719269f0108ad47c8f3f8b9 Mon Sep 17 00:00:00 2001 From: Pierre Fenoll Date: Sat, 17 Feb 2018 01:20:29 +0100 Subject: sort-as: found the issue. Will look into tests now --- src/rebar_state.erl | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/rebar_state.erl b/src/rebar_state.erl index 577ed23..7ebe6da 100644 --- a/src/rebar_state.erl +++ b/src/rebar_state.erl @@ -87,8 +87,8 @@ new(Config) when is_list(Config) -> opts = Opts }. -spec new(t() | atom(), list()) -> t(). -new(Profile, Config) when is_atom(Profile) - , is_list(Config) -> +new(Profile, Config) when is_atom(Profile), + is_list(Config) -> BaseState = base_state(), Opts = base_opts(Config), BaseState#state_t { dir = rebar_dir:get_cwd(), @@ -283,11 +283,12 @@ apply_profiles(State=#state_t{default = Defaults, current_profiles=CurrentProfil end, Defaults, AppliedProfiles), State#state_t{current_profiles = AppliedProfiles, opts=NewOpts}. +%% @doc A stable deduplicator. deduplicate(Profiles) -> - do_deduplicate(lists:reverse(Profiles), []). + do_deduplicate(Profiles, []). do_deduplicate([], Acc) -> - Acc; + lists:reverse(Acc); do_deduplicate([Head | Rest], Acc) -> case lists:member(Head, Acc) of true -> do_deduplicate(Rest, Acc); -- cgit v1.1 From abad0e14bb5a6ea5df21f2732bd72bf6efb0ca1e Mon Sep 17 00:00:00 2001 From: Pierre Fenoll Date: Fri, 23 Feb 2018 04:07:24 +0100 Subject: sort-as: show issue more clearly --- src/rebar_state.erl | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/rebar_state.erl b/src/rebar_state.erl index 7ebe6da..8c100aa 100644 --- a/src/rebar_state.erl +++ b/src/rebar_state.erl @@ -43,6 +43,10 @@ allow_provider_overrides/1, allow_provider_overrides/2 ]). +-ifdef(TEST). +-export([deduplicate/1]). +-endif. + -include("rebar.hrl"). -include_lib("providers/include/providers.hrl"). -- cgit v1.1 From 6aeff6300bf8986079ac6e8f83fa37150e239810 Mon Sep 17 00:00:00 2001 From: Pierre Fenoll Date: Fri, 23 Feb 2018 12:50:29 +0100 Subject: Revert "sort-as: show issue more clearly" This reverts commit 4ad1db97336a3ac070880876ada07d4c7b769327. --- src/rebar_state.erl | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src') diff --git a/src/rebar_state.erl b/src/rebar_state.erl index 8c100aa..7ebe6da 100644 --- a/src/rebar_state.erl +++ b/src/rebar_state.erl @@ -43,10 +43,6 @@ allow_provider_overrides/1, allow_provider_overrides/2 ]). --ifdef(TEST). --export([deduplicate/1]). --endif. - -include("rebar.hrl"). -include_lib("providers/include/providers.hrl"). -- cgit v1.1 From 1d2aa24ef0d0bc6d1177cce361d7718f887eb03e Mon Sep 17 00:00:00 2001 From: Pierre Fenoll Date: Fri, 23 Feb 2018 12:50:38 +0100 Subject: Revert "sort-as: found the issue. Will look into tests now" This reverts commit 0f7e6c31e97c238649e7ae0a1b7087e342174ecc. --- src/rebar_state.erl | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/rebar_state.erl b/src/rebar_state.erl index 7ebe6da..577ed23 100644 --- a/src/rebar_state.erl +++ b/src/rebar_state.erl @@ -87,8 +87,8 @@ new(Config) when is_list(Config) -> opts = Opts }. -spec new(t() | atom(), list()) -> t(). -new(Profile, Config) when is_atom(Profile), - is_list(Config) -> +new(Profile, Config) when is_atom(Profile) + , is_list(Config) -> BaseState = base_state(), Opts = base_opts(Config), BaseState#state_t { dir = rebar_dir:get_cwd(), @@ -283,12 +283,11 @@ apply_profiles(State=#state_t{default = Defaults, current_profiles=CurrentProfil end, Defaults, AppliedProfiles), State#state_t{current_profiles = AppliedProfiles, opts=NewOpts}. -%% @doc A stable deduplicator. deduplicate(Profiles) -> - do_deduplicate(Profiles, []). + do_deduplicate(lists:reverse(Profiles), []). do_deduplicate([], Acc) -> - lists:reverse(Acc); + Acc; do_deduplicate([Head | Rest], Acc) -> case lists:member(Head, Acc) of true -> do_deduplicate(Rest, Acc); -- cgit v1.1 From 0d88ff8891d1545721b7b61bc866713a13d0905a Mon Sep 17 00:00:00 2001 From: Pierre Fenoll Date: Fri, 23 Feb 2018 13:06:39 +0100 Subject: do not append test profile if already there. Note that it comes from the prv list passed to providers:create/1 --- src/rebar_state.erl | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/rebar_state.erl b/src/rebar_state.erl index 577ed23..ac77325 100644 --- a/src/rebar_state.erl +++ b/src/rebar_state.erl @@ -257,12 +257,15 @@ apply_profiles(State, Profile) when not is_list(Profile) -> apply_profiles(State, [default]) -> State; apply_profiles(State=#state_t{default = Defaults, current_profiles=CurrentProfiles}, Profiles) -> + IsTesting = lists:member(test, CurrentProfiles), AppliedProfiles = case Profiles of %% Head of list global profile is special, only for use by rebar3 %% It does not clash if a user does `rebar3 as global...` but when %% it is the head we must make sure not to prepend `default` [global | _] -> Profiles; + [test] when IsTesting -> + deduplicate(CurrentProfiles); _ -> deduplicate(CurrentProfiles ++ Profiles) end, -- cgit v1.1 From 1271458c511100a5402a7aec94e48904ad792ac7 Mon Sep 17 00:00:00 2001 From: Pierre Fenoll Date: Sun, 25 Feb 2018 13:39:45 +0100 Subject: sort-as: a more general pattern --- src/rebar_state.erl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/rebar_state.erl b/src/rebar_state.erl index ac77325..dd1f43f 100644 --- a/src/rebar_state.erl +++ b/src/rebar_state.erl @@ -257,14 +257,14 @@ apply_profiles(State, Profile) when not is_list(Profile) -> apply_profiles(State, [default]) -> State; apply_profiles(State=#state_t{default = Defaults, current_profiles=CurrentProfiles}, Profiles) -> - IsTesting = lists:member(test, CurrentProfiles), + ProvidedProfiles = lists:prefix([default|Profiles], CurrentProfiles), AppliedProfiles = case Profiles of %% Head of list global profile is special, only for use by rebar3 %% It does not clash if a user does `rebar3 as global...` but when %% it is the head we must make sure not to prepend `default` [global | _] -> Profiles; - [test] when IsTesting -> + _ when ProvidedProfiles -> deduplicate(CurrentProfiles); _ -> deduplicate(CurrentProfiles ++ Profiles) -- cgit v1.1