Add support for alternate dependency urls

This change adds the ability to use alternate urls for downloading
dependencies. To make use of alternate urls run:
rebar get-deps alt_urls=true
This commit is contained in:
Adam Schepis 2012-02-10 09:55:36 -05:00 committed by Tuncer Ayaz
parent 3469039201
commit 03a026f38f
3 changed files with 22 additions and 3 deletions

View file

@ -12,7 +12,8 @@ _rebar()
ct doc delete-deps eunit get-deps generate generate-upgrade \ ct doc delete-deps eunit get-deps generate generate-upgrade \
help list-deps list-templates update-deps version xref overlay \ help list-deps list-templates update-deps version xref overlay \
apps= case= force=1 jobs= suites= verbose=1 appid= previous_release= \ apps= case= force=1 jobs= suites= verbose=1 appid= previous_release= \
nodeid= root_dir= skip_deps=true skip_apps= template= template_dir=" nodeid= root_dir= skip_deps=true skip_apps= template= template_dir= \
alt_urls=true"
if [[ ${cur} == --* ]] ; then if [[ ${cur} == --* ]] ; then
COMPREPLY=( $(compgen -W "${lopts}" -- ${cur}) ) COMPREPLY=( $(compgen -W "${lopts}" -- ${cur}) )

View file

@ -113,7 +113,10 @@
{deps, [application_name, {deps, [application_name,
{application_name, "1.0.*"}, {application_name, "1.0.*"},
{application_name, "1.0.*", {application_name, "1.0.*",
{git, "git://github.com/basho/rebar.git", {branch, "master"}}}]}. {git, "git://github.com/basho/rebar.git", {branch, "master"}}},
{application_name, "1.0.*",
{git, "git://github.com/basho/rebar.git", {branch, "master"}},
[{alt_url, "https://github.com/basho/rebar.git"}]}]}.
%% == Subdirectories == %% == Subdirectories ==

View file

@ -223,15 +223,30 @@ find_deps(Mode, [App | Rest], Acc) when is_atom(App) ->
find_deps(Mode, [{App, VsnRegex} | Rest], Acc) when is_atom(App) -> find_deps(Mode, [{App, VsnRegex} | Rest], Acc) when is_atom(App) ->
find_deps(Mode, [{App, VsnRegex, undefined} | Rest], Acc); find_deps(Mode, [{App, VsnRegex, undefined} | Rest], Acc);
find_deps(Mode, [{App, VsnRegex, Source} | Rest], Acc) -> find_deps(Mode, [{App, VsnRegex, Source} | Rest], Acc) ->
find_deps(Mode, [{App, VsnRegex, Source, []} | Rest], Acc);
find_deps(Mode, [{App, VsnRegex, Source, Opts} | Rest], Acc) ->
Dep = #dep { app = App, Dep = #dep { app = App,
vsn_regex = VsnRegex, vsn_regex = VsnRegex,
source = Source }, source = get_source(Source, Opts) },
{Availability, FoundDir} = find_dep(Dep), {Availability, FoundDir} = find_dep(Dep),
find_deps(Mode, Rest, acc_deps(Mode, Availability, Dep, FoundDir, Acc)); find_deps(Mode, Rest, acc_deps(Mode, Availability, Dep, FoundDir, Acc));
find_deps(_Mode, [Other | _Rest], _Acc) -> find_deps(_Mode, [Other | _Rest], _Acc) ->
?ABORT("Invalid dependency specification ~p in ~s\n", ?ABORT("Invalid dependency specification ~p in ~s\n",
[Other, rebar_utils:get_cwd()]). [Other, rebar_utils:get_cwd()]).
get_source(undefined, _Opts) ->
undefined;
get_source(Source, Opts) ->
setelement(2, Source, dep_url(element(2, Source), Opts)).
dep_url(Url, Opts) ->
case rebar_config:get_global(alt_urls, "false") of
"true" ->
proplists:get_value(alt_url, Opts, Url);
"false" ->
Url
end.
find_dep(Dep) -> find_dep(Dep) ->
%% Find a dep based on its source, %% Find a dep based on its source,
%% e.g. {git, "https://github.com/mochi/mochiweb.git", "HEAD"} %% e.g. {git, "https://github.com/mochi/mochiweb.git", "HEAD"}