-
Notifications
You must be signed in to change notification settings - Fork 12
/
rebar.config.script
26 lines (26 loc) · 1.29 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
case os:getenv("GIT_SERVER") of
false ->
CONFIG;
Server ->
Project = os:getenv("GIT_PROJECT", ""),
RewriteFun = fun({Name, {git, RepoUrl, Version}}) ->
RepoName = filename:basename(RepoUrl, ".git"),
NewRepoUrl = lists:flatten(io_lib:format("ssh://git@~s/~s/~s.git", [Server, Project, RepoName])),
{Name, {git, NewRepoUrl, Version}};
({Name, Version}) ->
RepoUrl = lists:flatten(io_lib:format("ssh://git@~s/~s/~s.git", [Server, Project, Name])),
{Name, {git, RepoUrl, {tag, Version}}}
end,
%% Rewrite dependencies
Deps = proplists:get_value(deps, CONFIG),
NewDeps = [RewriteFun(Dep) || Dep <- Deps],
%% Rewrite test dependencies
Profiles = proplists:get_value(profiles, CONFIG),
TestProfile = proplists:get_value(test, Profiles),
TestDeps = proplists:get_value(deps, TestProfile),
NewTestDeps = [RewriteFun(Dep) || Dep <- TestDeps],
NewTestProfile = lists:keystore(deps, 1, TestProfile, {deps, NewTestDeps}),
NewProfiles = lists:keyreplace(test, 1, Profiles, {test, NewTestProfile}),
%% Forge the final config
lists:keystore(profiles, 1, lists:keystore(deps, 1, CONFIG, {deps, NewDeps}), {profiles, NewProfiles})
end.