summaryrefslogtreecommitdiff
path: root/src/rebar_git_resource.erl
diff options
context:
space:
mode:
authorsimonxu72 <simon.xu72@gmail.com>2018-11-13 13:19:13 +0800
committersimonxu72 <simon.xu72@gmail.com>2018-11-13 13:19:13 +0800
commit4014faf695c3da3a8f0c7aa088cdae0725433d16 (patch)
tree9601583c4314fd1fdca3c12d657ac54b286f9d21 /src/rebar_git_resource.erl
parent41d133856bf199034b0eeb0903bedc2071fba7e1 (diff)
parentd0e9a553468424b53aeb9907201d0b4f5aa4fad2 (diff)
merge from upstream/master
Diffstat (limited to 'src/rebar_git_resource.erl')
-rw-r--r--src/rebar_git_resource.erl17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/rebar_git_resource.erl b/src/rebar_git_resource.erl
index cec7dfc..0ca6627 100644
--- a/src/rebar_git_resource.erl
+++ b/src/rebar_git_resource.erl
@@ -21,6 +21,7 @@ init(Type, _State) ->
{ok, Resource}.
lock(AppInfo, _) ->
+ check_type_support(),
lock_(rebar_app_info:dir(AppInfo), rebar_app_info:source(AppInfo)).
lock_(AppDir, {git, Url, _}) ->
@@ -43,6 +44,7 @@ lock_(AppDir, {git, Url}) ->
%% Return true if either the git url or tag/branch/ref is not the same as the currently
%% checked out git repo for the dep
needs_update(AppInfo, _) ->
+ check_type_support(),
needs_update_(rebar_app_info:dir(AppInfo), rebar_app_info:source(AppInfo)).
needs_update_(Dir, {git, Url, {tag, Tag}}) ->
@@ -111,6 +113,7 @@ parse_git_url(not_scp, Url) ->
end.
download(TmpDir, AppInfo, State, _) ->
+ check_type_support(),
case download_(TmpDir, rebar_app_info:source(AppInfo), State) of
{ok, _} ->
ok;
@@ -324,4 +327,18 @@ git_clone_options() ->
?DEBUG("Git clone Option = ~p",[Option]),
Option.
+check_type_support() ->
+ case get({is_supported, ?MODULE}) of
+ true ->
+ ok;
+ _ ->
+ case rebar_utils:sh("git --version", [{return_on_error, true},
+ {use_stdout, false}]) of
+ {error, _} ->
+ ?ABORT("git not installed", []);
+ _ ->
+ put({is_supported, ?MODULE}, true),
+ ok
+ end
+ end.