Skip to content

Commit c0c81d6

Browse files
author
Martin Cox
authored
Merge pull request #933 from postbasho/patch/mapdeps-add-version-labels
Extend mapdeps to add edge version labels
2 parents 8199c53 + 36ede71 commit c0c81d6

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

misc/mapdeps.erl

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,15 @@ map_dir(BaseDir) ->
6868
exit(-1)
6969
end.
7070

71+
72+
% Obtain a nice version string to use in the label
73+
ver({tag,T}) ->
74+
io_lib:format("tag:~s", [T]);
75+
ver({branch, B} ) ->
76+
io_lib:format("branch:~s", [B]);
77+
ver(R) ->
78+
io_lib:format("ref:~s", [R]).
79+
7180
%% Read a rebar file. Find any `deps' option. Accumulate tuples of the
7281
%% form `{App, Dep}' for each element in this deps list. Recurse and
7382
%% attempt to read the rebar.config for each dep.
@@ -76,9 +85,10 @@ map_rebar(BaseDir, Path, Acc) ->
7685
{ok, Opts} ->
7786
Deps = proplists:get_value(deps, Opts, []),
7887
lists:foldl(
79-
fun({DepName, _, _}, A) ->
88+
fun({DepName, _, {_,_,V} }, A) ->
8089
From = app_name(Path),
81-
To = atom_to_list(DepName),
90+
VerStr = ver(V),
91+
To = {atom_to_list(DepName), VerStr},
8292
case ordsets:is_element({To, From}, A) of
8393
true ->
8494
%% we've already seen the other side,
@@ -92,7 +102,9 @@ map_rebar(BaseDir, Path, Acc) ->
92102
atom_to_list(DepName),
93103
"rebar.config"]),
94104
map_rebar(BaseDir, DepPath, NA)
95-
end
105+
end;
106+
({_DepName, _, {_,_,_} }, A) ->
107+
A
96108
end,
97109
Acc,
98110
Deps);
@@ -110,5 +122,5 @@ file_start() ->
110122
file_end() ->
111123
io:format(standard_io, "}~n", []).
112124

113-
file_edge(From, To) ->
114-
io:format(standard_io, " \"~s\" -> ~s;~n", [From, To]).
125+
file_edge(From, {To,V} ) ->
126+
io:format(standard_io, " \"~s\" -> ~s [ label=\"~s\" ];~n", [From, To,V]).

0 commit comments

Comments
 (0)