From 85eb2957c3fd908e8250f8d0816d220bcf06bb77 Mon Sep 17 00:00:00 2001 From: Dave Smith Date: Thu, 21 Apr 2011 06:08:40 -0600 Subject: [PATCH] Add list-deps command --- src/rebar_deps.erl | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/rebar_deps.erl b/src/rebar_deps.erl index 01cfad3..fe73ca5 100644 --- a/src/rebar_deps.erl +++ b/src/rebar_deps.erl @@ -34,7 +34,8 @@ 'check-deps'/2, 'get-deps'/2, 'update-deps'/2, - 'delete-deps'/2]). + 'delete-deps'/2, + 'list-deps'/2]). -record(dep, { dir, @@ -139,6 +140,18 @@ compile(Config, AppFile) -> lists:prefix(DepsDir, D#dep.dir)], ok. +'list-deps'(Config, _) -> + Deps = rebar_config:get_local(Config, deps, []), + case find_deps(find, Deps) of + {AvailDeps, []} -> + lists:foreach(fun(Dep) -> + ?CONSOLE("~s\n", [print_source(Dep#dep.source)]) + end, AvailDeps), + ok; + {_, MissingDeps} -> + ?ABORT("Missing dependencies: ~p\n", [MissingDeps]) + end. + %% =================================================================== %% Internal functions @@ -449,3 +462,10 @@ has_vcs_dir(svn, Dir) -> orelse filelib:is_dir(filename:join(Dir, "_svn")); has_vcs_dir(_, _) -> true. + +print_source({git, Url}) -> ?FMT("BRANCH ~s ~s", ["HEAD", Url]); +print_source({git, Url, ""}) -> ?FMT("BRANCH ~s ~s", ["HEAD", Url]); +print_source({git, Url, {branch, Branch}}) -> ?FMT("BRANCH ~s ~s", [Branch, Url]); +print_source({git, Url, {tag, Tag}}) -> ?FMT("TAG ~s ~s", [Tag, Url]); +print_source({_, Url, Rev}) -> ?FMT("REV ~s ~s", [Rev, Url]). +