diff options
author | Tuncer Ayaz <tuncer.ayaz@gmail.com> | 2011-09-02 14:54:08 +0200 |
---|---|---|
committer | Tuncer Ayaz <tuncer.ayaz@gmail.com> | 2011-09-02 14:54:08 +0200 |
commit | c3a4ed292e54601fd6813ed9673ac24ec30a6d98 (patch) | |
tree | 09dda39e15ef695cf56ddcd29c995abbcb4fe388 /src | |
parent | a337939e7a736f6ca1c597fb8264a86a15c15727 (diff) |
Clean up and fix vcs functions and logging
Diffstat (limited to 'src')
-rw-r--r-- | src/rebar_deps.erl | 57 |
1 files changed, 32 insertions, 25 deletions
diff --git a/src/rebar_deps.erl b/src/rebar_deps.erl index c35d14e..63f12d5 100644 --- a/src/rebar_deps.erl +++ b/src/rebar_deps.erl @@ -144,9 +144,7 @@ compile(Config, AppFile) -> 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), + lists:foreach(fun(Dep) -> print_source(Dep) end, AvailDeps), ok; {_, MissingDeps} -> ?ABORT("Missing dependencies: ~p\n", [MissingDeps]) @@ -422,17 +420,17 @@ source_engine_avail(Source) -> source_engine_avail(Name, Source) when Name == hg; Name == git; Name == svn; Name == bzr -> - case scm_client_vsn(Name) >= required_scm_client_vsn(Name) of + case vcs_client_vsn(Name) >= required_vcs_client_vsn(Name) of true -> true; false -> ?ABORT("Rebar requires version ~p or higher of ~s to process ~p\n", - [required_scm_client_vsn(Name), Name, Source]) + [required_vcs_client_vsn(Name), Name, Source]) end. -scm_client_vsn(false, _VsnArg, _VsnRegex) -> +vcs_client_vsn(false, _VsnArg, _VsnRegex) -> false; -scm_client_vsn(Path, VsnArg, VsnRegex) -> +vcs_client_vsn(Path, VsnArg, VsnRegex) -> {ok, Info} = rebar_utils:sh(Path ++ VsnArg, [{env, [{"LANG", "C"}]}, {use_stdout, false}]), case re:run(Info, VsnRegex, [{capture, all_but_first, list}]) of @@ -442,22 +440,22 @@ scm_client_vsn(Path, VsnArg, VsnRegex) -> false end. -required_scm_client_vsn(hg) -> {1, 1}; -required_scm_client_vsn(git) -> {1, 5}; -required_scm_client_vsn(bzr) -> {2, 0}; -required_scm_client_vsn(svn) -> {1, 6}. +required_vcs_client_vsn(hg) -> {1, 1}; +required_vcs_client_vsn(git) -> {1, 5}; +required_vcs_client_vsn(bzr) -> {2, 0}; +required_vcs_client_vsn(svn) -> {1, 6}. -scm_client_vsn(hg) -> - scm_client_vsn(rebar_utils:find_executable("hg"), " --version", +vcs_client_vsn(hg) -> + vcs_client_vsn(rebar_utils:find_executable("hg"), " --version", "version (\\d+).(\\d+)"); -scm_client_vsn(git) -> - scm_client_vsn(rebar_utils:find_executable("git"), " --version", +vcs_client_vsn(git) -> + vcs_client_vsn(rebar_utils:find_executable("git"), " --version", "git version (\\d+).(\\d+)"); -scm_client_vsn(bzr) -> - scm_client_vsn(rebar_utils:find_executable("bzr"), " --version", +vcs_client_vsn(bzr) -> + vcs_client_vsn(rebar_utils:find_executable("bzr"), " --version", "Bazaar \\(bzr\\) (\\d+).(\\d+)"); -scm_client_vsn(svn) -> - scm_client_vsn(rebar_utils:find_executable("svn"), " --version", +vcs_client_vsn(svn) -> + vcs_client_vsn(rebar_utils:find_executable("svn"), " --version", "svn, version (\\d+).(\\d+)"). has_vcs_dir(git, Dir) -> @@ -472,9 +470,18 @@ has_vcs_dir(svn, Dir) -> 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]). - +print_source(#dep{app=App, source=Source}) -> + ?CONSOLE("~s~n", [format_source(App, Source)]). + +format_source(App, {git, Url}) -> + ?FMT("~p BRANCH ~s ~s", [App, "HEAD", Url]); +format_source(App, {git, Url, ""}) -> + ?FMT("~p BRANCH ~s ~s", [App, "HEAD", Url]); +format_source(App, {git, Url, {branch, Branch}}) -> + ?FMT("~p BRANCH ~s ~s", [App, Branch, Url]); +format_source(App, {git, Url, {tag, Tag}}) -> + ?FMT("~p TAG ~s ~s", [App, Tag, Url]); +format_source(App, {_, Url, Rev}) -> + ?FMT("~p REV ~s ~s", [App, Rev, Url]); +format_source(App, undefined) -> + ?FMT("~p", [App]). |