summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFred Hebert <mononcqc@ferd.ca>2018-11-13 12:07:34 -0500
committerGitHub <noreply@github.com>2018-11-13 12:07:34 -0500
commitcad1da876974e252c66e3143be58f6565dfddfa8 (patch)
tree9601583c4314fd1fdca3c12d657ac54b286f9d21
parentd0e9a553468424b53aeb9907201d0b4f5aa4fad2 (diff)
parent4014faf695c3da3a8f0c7aa088cdae0725433d16 (diff)
Merge pull request #1844 from simonxu72/master
add git clone --reference path support
-rw-r--r--src/rebar_git_resource.erl40
1 files changed, 28 insertions, 12 deletions
diff --git a/src/rebar_git_resource.erl b/src/rebar_git_resource.erl
index 03aa6d8..0ca6627 100644
--- a/src/rebar_git_resource.erl
+++ b/src/rebar_git_resource.erl
@@ -159,38 +159,44 @@ maybe_warn_local_url(Url) ->
%% Use different git clone commands depending on git --version
git_clone(branch,Vsn,Url,Dir,Branch) when Vsn >= {1,7,10}; Vsn =:= undefined ->
- rebar_utils:sh(?FMT("git clone ~ts ~ts -b ~ts --single-branch",
- [rebar_utils:escape_chars(Url),
+ rebar_utils:sh(?FMT("git clone ~ts ~ts ~ts -b ~ts --single-branch",
+ [git_clone_options(),
+ rebar_utils:escape_chars(Url),
rebar_utils:escape_chars(filename:basename(Dir)),
rebar_utils:escape_chars(Branch)]),
[{cd, filename:dirname(Dir)}]);
git_clone(branch,_Vsn,Url,Dir,Branch) ->
- rebar_utils:sh(?FMT("git clone ~ts ~ts -b ~ts",
- [rebar_utils:escape_chars(Url),
+ rebar_utils:sh(?FMT("git clone ~ts ~ts ~ts -b ~ts",
+ [git_clone_options(),
+ rebar_utils:escape_chars(Url),
rebar_utils:escape_chars(filename:basename(Dir)),
rebar_utils:escape_chars(Branch)]),
[{cd, filename:dirname(Dir)}]);
git_clone(tag,Vsn,Url,Dir,Tag) when Vsn >= {1,7,10}; Vsn =:= undefined ->
- rebar_utils:sh(?FMT("git clone ~ts ~ts -b ~ts --single-branch",
- [rebar_utils:escape_chars(Url),
+ rebar_utils:sh(?FMT("git clone ~ts ~ts ~ts -b ~ts --single-branch",
+ [git_clone_options(),
+ rebar_utils:escape_chars(Url),
rebar_utils:escape_chars(filename:basename(Dir)),
rebar_utils:escape_chars(Tag)]),
[{cd, filename:dirname(Dir)}]);
git_clone(tag,_Vsn,Url,Dir,Tag) ->
- rebar_utils:sh(?FMT("git clone ~ts ~ts -b ~ts",
- [rebar_utils:escape_chars(Url),
+ rebar_utils:sh(?FMT("git clone ~ts ~ts ~ts -b ~ts",
+ [git_clone_options(),
+ rebar_utils:escape_chars(Url),
rebar_utils:escape_chars(filename:basename(Dir)),
rebar_utils:escape_chars(Tag)]),
[{cd, filename:dirname(Dir)}]);
git_clone(ref,_Vsn,Url,Dir,Ref) ->
- rebar_utils:sh(?FMT("git clone -n ~ts ~ts",
- [rebar_utils:escape_chars(Url),
+ rebar_utils:sh(?FMT("git clone ~ts -n ~ts ~ts",
+ [git_clone_options(),
+ rebar_utils:escape_chars(Url),
rebar_utils:escape_chars(filename:basename(Dir))]),
[{cd, filename:dirname(Dir)}]),
rebar_utils:sh(?FMT("git checkout -q ~ts", [Ref]), [{cd, Dir}]);
git_clone(rev,_Vsn,Url,Dir,Rev) ->
- rebar_utils:sh(?FMT("git clone -n ~ts ~ts",
- [rebar_utils:escape_chars(Url),
+ rebar_utils:sh(?FMT("git clone ~ts -n ~ts ~ts",
+ [git_clone_options(),
+ rebar_utils:escape_chars(Url),
rebar_utils:escape_chars(filename:basename(Dir))]),
[{cd, filename:dirname(Dir)}]),
rebar_utils:sh(?FMT("git checkout -q ~ts", [rebar_utils:escape_chars(Rev)]),
@@ -311,6 +317,16 @@ parse_tags(Dir) ->
end
end.
+git_clone_options() ->
+ Option = case os:getenv("REBAR_GIT_CLONE_OPTIONS") of
+ false -> "" ; %% env var not set
+ Opt -> %% env var set to empty or others
+ Opt
+ end,
+
+ ?DEBUG("Git clone Option = ~p",[Option]),
+ Option.
+
check_type_support() ->
case get({is_supported, ?MODULE}) of
true ->