Skip to content

Commit

Permalink
Use git command in non interactive mode
Browse files Browse the repository at this point in the history
  • Loading branch information
gearnode committed Dec 20, 2021
1 parent 1d8d857 commit 780ca48
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/rebar_git_resource.erl
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,15 @@ maybe_warn_local_url(Url) ->
end.

%% Use different git clone commands depending on git --version
git_clone(branch, GitVsn, Url, Dir, Branch) when GitVsn >= {2,3,0}; GitVsn =:= undefined ->
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)},
{env, [{"GIT_TERMINAL_PROMPT", "0"}]}]),
ok;
git_clone(branch, GitVsn, Url, Dir, Branch) when GitVsn >= {1,7,10}; GitVsn =:= undefined ->
rebar_utils:sh(?FMT("git clone ~ts ~ts ~ts -b ~ts --single-branch",
[git_clone_options(),
Expand All @@ -196,6 +205,15 @@ git_clone(branch, _GitVsn, Url, Dir, Branch) ->
rebar_utils:escape_chars(Branch)]),
[{cd, filename:dirname(Dir)}]),
ok;
git_clone(tag, GitVsn, Url, Dir, Tag) when GitVsn >= {2,3,0}; GitVsn =:= undefined ->
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)},
{env, [{"GIT_TERMINAL_PROMPT", "0"}]}]),
ok;
git_clone(tag, GitVsn, Url, Dir, Tag) when GitVsn >= {1,7,10}; GitVsn =:= undefined ->
rebar_utils:sh(?FMT("git clone ~ts ~ts ~ts -b ~ts --single-branch",
[git_clone_options(),
Expand Down Expand Up @@ -396,4 +414,3 @@ check_type_support() ->
ok
end
end.

0 comments on commit 780ca48

Please sign in to comment.