summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/rebar_git_resource.erl11
-rw-r--r--src/rebar_hooks.erl28
-rw-r--r--src/rebar_prv_path.erl8
-rw-r--r--src/rebar_prv_update.erl12
4 files changed, 35 insertions, 24 deletions
diff --git a/src/rebar_git_resource.erl b/src/rebar_git_resource.erl
index 5a6a5ef..ff43f76 100644
--- a/src/rebar_git_resource.erl
+++ b/src/rebar_git_resource.erl
@@ -18,9 +18,16 @@ lock(AppDir, {git, Url, _}) ->
lock(AppDir, {git, Url});
lock(AppDir, {git, Url}) ->
AbortMsg = io_lib:format("Locking of git dependency failed in ~s", [AppDir]),
+ Dir = rebar_utils:escape_double_quotes(AppDir),
{ok, VsnString} =
- rebar_utils:sh("git --git-dir=\"" ++ rebar_utils:escape_double_quotes(AppDir) ++ "/.git\" rev-parse --verify HEAD",
- [{use_stdout, false}, {debug_abort_on_error, AbortMsg}]),
+ case os:type() of
+ {win32, _} ->
+ rebar_utils:sh("git rev-parse --git-dir=\"" ++ Dir ++ "/.git\" --work-tree=\"" ++ Dir ++ "\" --verify HEAD",
+ [{use_stdout, false}, {debug_abort_on_error, AbortMsg}]);
+ _ ->
+ rebar_utils:sh("git --git-dir=\"" ++ Dir ++ "/.git\" rev-parse --verify HEAD",
+ [{use_stdout, false}, {debug_abort_on_error, AbortMsg}])
+ end,
Ref = string:strip(VsnString, both, $\n),
{git, Url, {ref, Ref}}.
diff --git a/src/rebar_hooks.erl b/src/rebar_hooks.erl
index 3af17ca..d6a0e2b 100644
--- a/src/rebar_hooks.erl
+++ b/src/rebar_hooks.erl
@@ -38,18 +38,22 @@ run_provider_hooks(Dir, Type, Command, Providers, Opts, State) ->
run_provider_hooks_(_Dir, _Type, _Command, _Providers, [], State) ->
State;
run_provider_hooks_(Dir, Type, Command, Providers, TypeHooks, State) ->
- PluginDepsPaths = rebar_state:code_paths(State, all_plugin_deps),
- code:add_pathsa(PluginDepsPaths),
- Providers1 = rebar_state:providers(State),
- State1 = rebar_state:providers(rebar_state:dir(State, Dir), Providers++Providers1),
- HookProviders = proplists:get_all_values(Command, TypeHooks),
- case rebar_core:do(HookProviders, State1) of
- {error, ProviderName} ->
- ?DEBUG(format_error({bad_provider, Type, Command, ProviderName}), []),
- throw(?PRV_ERROR({bad_provider, Type, Command, ProviderName}));
- {ok, State2} ->
- rebar_utils:remove_from_code_path(PluginDepsPaths),
- State2
+ case proplists:get_all_values(Command, TypeHooks) of
+ [] ->
+ State;
+ HookProviders ->
+ PluginDepsPaths = lists:usort(rebar_state:code_paths(State, all_plugin_deps)),
+ code:add_pathsa(PluginDepsPaths),
+ Providers1 = rebar_state:providers(State),
+ State1 = rebar_state:providers(rebar_state:dir(State, Dir), Providers++Providers1),
+ case rebar_core:do(HookProviders, State1) of
+ {error, ProviderName} ->
+ ?DEBUG(format_error({bad_provider, Type, Command, ProviderName}), []),
+ throw(?PRV_ERROR({bad_provider, Type, Command, ProviderName}));
+ {ok, State2} ->
+ rebar_utils:remove_from_code_path(PluginDepsPaths),
+ State2
+ end
end.
format_error({bad_provider, Type, Command, {Name, Namespace}}) ->
diff --git a/src/rebar_prv_path.erl b/src/rebar_prv_path.erl
index 4e88496..4259eec 100644
--- a/src/rebar_prv_path.erl
+++ b/src/rebar_prv_path.erl
@@ -77,15 +77,15 @@ paths([{rel, true}|Rest], Apps, State, Acc) ->
base_dir(State) -> io_lib:format("~s", [rebar_dir:base_dir(State)]).
bin_dir(State) -> io_lib:format("~s/bin", [rebar_dir:base_dir(State)]).
-lib_dir(State) -> io_lib:format("~s/lib", [rebar_dir:base_dir(State)]).
+lib_dir(State) -> io_lib:format("~s", [rebar_dir:deps_dir(State)]).
rel_dir(State) -> io_lib:format("~s/rel", [rebar_dir:base_dir(State)]).
ebin_dirs(Apps, State) ->
- lists:map(fun(App) -> io_lib:format("~s/lib/~s/ebin", [rebar_dir:base_dir(State), App]) end, Apps).
+ lists:map(fun(App) -> io_lib:format("~s/~s/ebin", [rebar_dir:deps_dir(State), App]) end, Apps).
priv_dirs(Apps, State) ->
- lists:map(fun(App) -> io_lib:format("~s/lib/~s/priv", [rebar_dir:base_dir(State), App]) end, Apps).
+ lists:map(fun(App) -> io_lib:format("~s/~s/priv", [rebar_dir:deps_dir(State), App]) end, Apps).
src_dirs(Apps, State) ->
- lists:map(fun(App) -> io_lib:format("~s/lib/~s/src", [rebar_dir:base_dir(State), App]) end, Apps).
+ lists:map(fun(App) -> io_lib:format("~s/~s/src", [rebar_dir:deps_dir(State), App]) end, Apps).
print_paths_if_exist(Paths, State) ->
{RawOpts, _} = rebar_state:command_parsed_args(State),
diff --git a/src/rebar_prv_update.erl b/src/rebar_prv_update.erl
index 5e1e253..54b135e 100644
--- a/src/rebar_prv_update.erl
+++ b/src/rebar_prv_update.erl
@@ -114,14 +114,14 @@ hex_to_index(State) ->
ets:foldl(fun({Pkg, [[]]}, _) when is_binary(Pkg) ->
true;
- ({Pkg, [Vsns=[Vsn | _Rest]]}, _) when is_binary(Pkg) ->
+ ({Pkg, [Vsns=[_Vsn | _Rest]]}, _) when is_binary(Pkg) ->
%% Verify the package is of the right build tool by checking if the first
%% version exists in the table from the foldl above
- case ets:member(?PACKAGE_TABLE, {Pkg, Vsn}) of
- true ->
- ets:insert(?PACKAGE_TABLE, {Pkg, Vsns});
- false ->
- true
+ case [V || V <- Vsns, ets:member(?PACKAGE_TABLE, {Pkg, V})] of
+ [] ->
+ true;
+ Vsns1 ->
+ ets:insert(?PACKAGE_TABLE, {Pkg, Vsns1})
end;
(_, _) ->
true