summaryrefslogtreecommitdiff
path: root/src/rebar_hg_resource.erl
diff options
context:
space:
mode:
authorFred Hebert <mononcqc@ferd.ca>2018-10-20 16:59:08 -0400
committerGitHub <noreply@github.com>2018-10-20 16:59:08 -0400
commit78e0d7923d78d912844e413bc82aa24ff1484d6e (patch)
treeb17c5fa70874649cf2b5e0872fe89e6f94a8ebfc /src/rebar_hg_resource.erl
parentac69c3898609c5ff55c063c6ac12c6c201ab0cc0 (diff)
parenta279020d1b860313719a3ba07972004b8235146d (diff)
Merge pull request #1921 from ferd/check-tool-avail
check if git/hg is installed
Diffstat (limited to 'src/rebar_hg_resource.erl')
-rw-r--r--src/rebar_hg_resource.erl19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/rebar_hg_resource.erl b/src/rebar_hg_resource.erl
index 21d4b9d..8139d04 100644
--- a/src/rebar_hg_resource.erl
+++ b/src/rebar_hg_resource.erl
@@ -18,6 +18,7 @@ init(Type, _State) ->
{ok, Resource}.
lock(AppInfo, _) ->
+ check_type_support(),
lock_(rebar_app_info:dir(AppInfo), rebar_app_info:source(AppInfo)).
lock_(AppDir, {hg, Url, _}) ->
@@ -61,6 +62,7 @@ needs_update_(Dir, {hg, Url, Ref}) ->
not ((LocalRef =:= TargetRef) andalso compare_url(Dir, Url)).
download(TmpDir, AppInfo, State, _) ->
+ check_type_support(),
case download_(TmpDir, rebar_app_info:source(AppInfo), State) of
{ok, _} ->
ok;
@@ -110,6 +112,7 @@ download_(Dir, {hg, Url, Rev}, _State) ->
[{cd, filename:dirname(Dir)}]).
make_vsn(AppInfo, _) ->
+ check_type_support(),
make_vsn_(rebar_app_info:dir(AppInfo)).
make_vsn_(Dir) ->
@@ -183,3 +186,19 @@ parse_hg_url("http://" ++ HostPath) ->
parse_hg_url("https://" ++ HostPath) ->
[Host | Path] = rebar_string:lexemes(HostPath, "/"),
{Host, filename:rootname(filename:join(Path), ".hg")}.
+
+check_type_support() ->
+ case get({is_supported, ?MODULE}) of
+ true ->
+ ok;
+ false ->
+ case rebar_utils:sh("hg --version", [{return_on_error, true},
+ {use_stdout, false}]) of
+ {error, _} ->
+ ?ABORT("hg not installed", []);
+ _ ->
+ put({is_supported, ?MODULE}, true),
+ ok
+ end
+ end.
+