summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/rebar_app_utils.erl3
-rw-r--r--src/rebar_git_resource.erl40
-rw-r--r--src/rebar_prv_alias.erl15
-rw-r--r--src/rebar_prv_do.erl24
-rw-r--r--src/rebar_prv_plugins.erl3
5 files changed, 66 insertions, 19 deletions
diff --git a/src/rebar_app_utils.erl b/src/rebar_app_utils.erl
index 605944e..19ed4dd 100644
--- a/src/rebar_app_utils.erl
+++ b/src/rebar_app_utils.erl
@@ -259,8 +259,7 @@ update_source(AppInfo, {pkg, PkgName, PkgVsn, Hash}, State) ->
maybe_warn_retired(PkgName, PkgVsn1, Hash, Retired),
PkgVsn2 = list_to_binary(lists:flatten(ec_semver:format(PkgVsn1))),
AppInfo1 = rebar_app_info:source(AppInfo, {pkg, PkgName, PkgVsn2, Hash1, RepoConfig}),
- AppInfo2 = rebar_app_info:update_opts_deps(AppInfo1, Deps),
- rebar_app_info:original_vsn(AppInfo2, PkgVsn2);
+ rebar_app_info:update_opts_deps(AppInfo1, Deps);
not_found ->
throw(?PRV_ERROR({missing_package, PkgName, PkgVsn}));
{error, {invalid_vsn, InvalidVsn}} ->
diff --git a/src/rebar_git_resource.erl b/src/rebar_git_resource.erl
index 03aa6d8..0ca6627 100644
--- a/src/rebar_git_resource.erl
+++ b/src/rebar_git_resource.erl
@@ -159,38 +159,44 @@ maybe_warn_local_url(Url) ->
%% Use different git clone commands depending on git --version
git_clone(branch,Vsn,Url,Dir,Branch) when Vsn >= {1,7,10}; Vsn =:= undefined ->
- rebar_utils:sh(?FMT("git clone ~ts ~ts -b ~ts --single-branch",
- [rebar_utils:escape_chars(Url),
+ rebar_utils:sh(?FMT("git clone ~ts ~ts ~ts -b ~ts --single-branch",
+ [git_clone_options(),
+ rebar_utils:escape_chars(Url),
rebar_utils:escape_chars(filename:basename(Dir)),
rebar_utils:escape_chars(Branch)]),
[{cd, filename:dirname(Dir)}]);
git_clone(branch,_Vsn,Url,Dir,Branch) ->
- rebar_utils:sh(?FMT("git clone ~ts ~ts -b ~ts",
- [rebar_utils:escape_chars(Url),
+ rebar_utils:sh(?FMT("git clone ~ts ~ts ~ts -b ~ts",
+ [git_clone_options(),
+ rebar_utils:escape_chars(Url),
rebar_utils:escape_chars(filename:basename(Dir)),
rebar_utils:escape_chars(Branch)]),
[{cd, filename:dirname(Dir)}]);
git_clone(tag,Vsn,Url,Dir,Tag) when Vsn >= {1,7,10}; Vsn =:= undefined ->
- rebar_utils:sh(?FMT("git clone ~ts ~ts -b ~ts --single-branch",
- [rebar_utils:escape_chars(Url),
+ rebar_utils:sh(?FMT("git clone ~ts ~ts ~ts -b ~ts --single-branch",
+ [git_clone_options(),
+ rebar_utils:escape_chars(Url),
rebar_utils:escape_chars(filename:basename(Dir)),
rebar_utils:escape_chars(Tag)]),
[{cd, filename:dirname(Dir)}]);
git_clone(tag,_Vsn,Url,Dir,Tag) ->
- rebar_utils:sh(?FMT("git clone ~ts ~ts -b ~ts",
- [rebar_utils:escape_chars(Url),
+ rebar_utils:sh(?FMT("git clone ~ts ~ts ~ts -b ~ts",
+ [git_clone_options(),
+ rebar_utils:escape_chars(Url),
rebar_utils:escape_chars(filename:basename(Dir)),
rebar_utils:escape_chars(Tag)]),
[{cd, filename:dirname(Dir)}]);
git_clone(ref,_Vsn,Url,Dir,Ref) ->
- rebar_utils:sh(?FMT("git clone -n ~ts ~ts",
- [rebar_utils:escape_chars(Url),
+ rebar_utils:sh(?FMT("git clone ~ts -n ~ts ~ts",
+ [git_clone_options(),
+ rebar_utils:escape_chars(Url),
rebar_utils:escape_chars(filename:basename(Dir))]),
[{cd, filename:dirname(Dir)}]),
rebar_utils:sh(?FMT("git checkout -q ~ts", [Ref]), [{cd, Dir}]);
git_clone(rev,_Vsn,Url,Dir,Rev) ->
- rebar_utils:sh(?FMT("git clone -n ~ts ~ts",
- [rebar_utils:escape_chars(Url),
+ rebar_utils:sh(?FMT("git clone ~ts -n ~ts ~ts",
+ [git_clone_options(),
+ rebar_utils:escape_chars(Url),
rebar_utils:escape_chars(filename:basename(Dir))]),
[{cd, filename:dirname(Dir)}]),
rebar_utils:sh(?FMT("git checkout -q ~ts", [rebar_utils:escape_chars(Rev)]),
@@ -311,6 +317,16 @@ parse_tags(Dir) ->
end
end.
+git_clone_options() ->
+ Option = case os:getenv("REBAR_GIT_CLONE_OPTIONS") of
+ false -> "" ; %% env var not set
+ Opt -> %% env var set to empty or others
+ Opt
+ end,
+
+ ?DEBUG("Git clone Option = ~p",[Option]),
+ Option.
+
check_type_support() ->
case get({is_supported, ?MODULE}) of
true ->
diff --git a/src/rebar_prv_alias.erl b/src/rebar_prv_alias.erl
index 736417b..ce56f29 100644
--- a/src/rebar_prv_alias.erl
+++ b/src/rebar_prv_alias.erl
@@ -73,8 +73,12 @@ desc(Cmds) ->
"Equivalent to running: rebar3 do "
++ rebar_string:join(lists:map(fun to_desc/1, Cmds), ",").
-to_desc({Cmd, Args}) ->
+to_desc({Cmd, Args}) when is_list(Args) ->
atom_to_list(Cmd) ++ " " ++ Args;
+to_desc({Namespace, Cmd}) ->
+ atom_to_list(Namespace) ++ " " ++ atom_to_list(Cmd);
+to_desc({Namespace, Cmd, Args}) ->
+ atom_to_list(Namespace) ++ " " ++ atom_to_list(Cmd) ++ " " ++ Args;
to_desc(Cmd) ->
atom_to_list(Cmd).
@@ -98,6 +102,12 @@ make_args(Cmds) ->
lists:map(fun make_tuple/1,
lists:map(fun make_arg/1, Cmds))).
+make_arg({Namespace, Command, Args}) when is_atom(Namespace), is_atom(Command) ->
+ {make_atom(Namespace),
+ make_atom(Command),
+ make_list([make_string(A) || A <- split_args(Args)])};
+make_arg({Namespace, Command}) when is_atom(Namespace), is_atom(Command) ->
+ {make_atom(Namespace), make_atom(Command)};
make_arg({Cmd, Args}) ->
{make_string(Cmd), make_list([make_string(A) || A <- split_args(Args)])};
make_arg(Cmd) ->
@@ -117,6 +127,9 @@ make_string(Atom) when is_atom(Atom) ->
make_string(String) when is_list(String) ->
{string, 1, String}.
+make_atom(Atom) when is_atom(Atom) ->
+ {atom, 1, Atom}.
+
%% In case someone used the long option format, the option needs to get
%% separated from its value.
split_args(Args) ->
diff --git a/src/rebar_prv_do.erl b/src/rebar_prv_do.erl
index f850135..5f7aa12 100644
--- a/src/rebar_prv_do.erl
+++ b/src/rebar_prv_do.erl
@@ -44,13 +44,31 @@ do(State) ->
do_tasks(Tasks, State)
end.
+-spec do_tasks(list(Task), State) -> Res when
+ Task :: {string(), string()} |
+ {string(), atom()} |
+ {atom(), atom(), string()},
+ State :: rebar_state:t(),
+ Res :: {ok, rebar_state:t()} |
+ {error, term()}.
do_tasks([], State) ->
{ok, State};
-do_tasks([{TaskStr, Args}|Tail], State) ->
+do_tasks([{TaskStr, Args} | Tail], State) when is_list(Args) ->
Task = list_to_atom(TaskStr),
State1 = rebar_state:set(State, task, Task),
State2 = rebar_state:command_args(State1, Args),
Namespace = rebar_state:namespace(State2),
+ do_task(TaskStr, Args, Tail, State, Namespace);
+do_tasks([{Namespace, Task} | Tail], State) ->
+ do_task(atom_to_list(Task), [], Tail, State, Namespace);
+do_tasks([{Namespace, Task, Args} | Tail], State)
+ when is_atom(Namespace), is_atom(Task) ->
+ do_task(atom_to_list(Task), Args, Tail, State, Namespace).
+
+do_task(TaskStr, Args, Tail, State, Namespace) ->
+ Task = list_to_atom(TaskStr),
+ State1 = rebar_state:set(State, task, Task),
+ State2 = rebar_state:command_args(State1, Args),
case Namespace of
default ->
%% The first task we hit might be a namespace!
@@ -65,7 +83,8 @@ do_tasks([{TaskStr, Args}|Tail], State) ->
_ ->
%% We're already in a non-default namespace, check the
%% task directly.
- case rebar_core:process_command(State2, Task) of
+ State3 = rebar_state:namespace(State2, Namespace),
+ case rebar_core:process_command(State3, Task) of
{ok, FinalState} when Tail =:= [] ->
{ok, FinalState};
{ok, _} ->
@@ -75,7 +94,6 @@ do_tasks([{TaskStr, Args}|Tail], State) ->
end
end.
-
-spec format_error(any()) -> iolist().
format_error(Reason) ->
io_lib:format("~p", [Reason]).
diff --git a/src/rebar_prv_plugins.erl b/src/rebar_prv_plugins.erl
index d66b645..fba5da0 100644
--- a/src/rebar_prv_plugins.erl
+++ b/src/rebar_prv_plugins.erl
@@ -42,10 +42,11 @@ do(State) ->
RebarOpts = rebar_state:opts(State),
SrcDirs = rebar_dir:src_dirs(RebarOpts, ["src"]),
Plugins = rebar_state:get(State, plugins, []),
+ ProjectPlugins = rebar_state:get(State, project_plugins, []),
PluginsDirs = filelib:wildcard(filename:join(rebar_dir:plugins_dir(State), "*")),
CheckoutsDirs = filelib:wildcard(filename:join(rebar_dir:checkouts_dir(State), "*")),
Apps = rebar_app_discover:find_apps(CheckoutsDirs++PluginsDirs, SrcDirs, all, State),
- display_plugins("Local plugins", Apps, Plugins),
+ display_plugins("Local plugins", Apps, Plugins ++ ProjectPlugins),
{ok, State}.
-spec format_error(any()) -> iolist().