-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrebar.config.script
51 lines (45 loc) · 1.6 KB
/
rebar.config.script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
%%%-------------------------------------------------------------------
%%% @author Michal Wrona
%%% @copyright (C) 2016 ACK CYFRONET AGH
%%% This software is released under the MIT license
%%% cited in 'LICENSE.txt'.
%%% @end
%%%-------------------------------------------------------------------
%%% @doc
%%% Dynamic configuration script for rebar.config. Replaces all
%%% occurrences of "ssh://git@git.onedata.org:7999/vfs" with
%%% ONEDATA_GIT_URL value.
%%% @end
%%%-------------------------------------------------------------------
case os:getenv("ONEDATA_GIT_URL") of
false -> CONFIG;
OnedataGitUrl ->
Replace = fun(Entry) ->
re:replace(Entry, "ssh://git@git.onedata.org:7999/vfs",
OnedataGitUrl, [{return,list}])
end,
ParseVCS = fun ParseVCS(Entry) ->
case Entry of
{git, Url} ->
{git, Replace(Url)};
{git, Url, Ref} ->
{git, Replace(Url), Ref};
{raw, RawEntry} ->
{raw, ParseVCS(RawEntry)};
E -> E
end
end,
{deps, DepsList} = lists:keyfind(deps, 1, CONFIG),
ParsedDeps = lists:map(fun(Dep) ->
case Dep of
{E1, VCS} ->
{E1, ParseVCS(VCS)};
{E1, VCS1, VCS2} ->
{E1, ParseVCS(VCS1), ParseVCS(VCS2)};
{E1, E2, VCS, E3} ->
{E1, E2, ParseVCS(VCS), E3};
E -> E
end
end, DepsList),
lists:keystore(deps, 1, CONFIG, {deps, ParsedDeps})
end.