summaryrefslogtreecommitdiff
path: root/src/rebar_git_resource.erl
diff options
context:
space:
mode:
authorFred Hebert <mononcqc@ferd.ca>2017-10-08 17:23:41 -0400
committerGitHub <noreply@github.com>2017-10-08 17:23:41 -0400
commit4f6646bb1c8900f6ecb9e92ccc4c0b39219042c8 (patch)
tree5d264b0fa2f2284e1da5e293ac92747106f46e09 /src/rebar_git_resource.erl
parent4352614e9b74ca9e6a54552afbb536049a08bc7c (diff)
parent228df89f3bdf92b9cd4aa36fca69f7d2738a1951 (diff)
Merge pull request #1641 from ferd/warn-local-resources
Warn user when a local git or hg resource is used
Diffstat (limited to 'src/rebar_git_resource.erl')
-rw-r--r--src/rebar_git_resource.erl14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/rebar_git_resource.erl b/src/rebar_git_resource.erl
index a6b4d00..c63d10d 100644
--- a/src/rebar_git_resource.erl
+++ b/src/rebar_git_resource.erl
@@ -105,18 +105,32 @@ download(Dir, {git, Url, ""}, State) ->
download(Dir, {git, Url, {branch, "master"}}, State);
download(Dir, {git, Url, {branch, Branch}}, _State) ->
ok = filelib:ensure_dir(Dir),
+ maybe_warn_local_url(Url),
git_clone(branch, git_vsn(), Url, Dir, Branch);
download(Dir, {git, Url, {tag, Tag}}, _State) ->
ok = filelib:ensure_dir(Dir),
+ maybe_warn_local_url(Url),
git_clone(tag, git_vsn(), Url, Dir, Tag);
download(Dir, {git, Url, {ref, Ref}}, _State) ->
ok = filelib:ensure_dir(Dir),
+ maybe_warn_local_url(Url),
git_clone(ref, git_vsn(), Url, Dir, Ref);
download(Dir, {git, Url, Rev}, _State) ->
?WARN("WARNING: It is recommended to use {branch, Name}, {tag, Tag} or {ref, Ref}, otherwise updating the dep may not work as expected.", []),
ok = filelib:ensure_dir(Dir),
+ maybe_warn_local_url(Url),
git_clone(rev, git_vsn(), Url, Dir, Rev).
+maybe_warn_local_url(Url) ->
+ WarnStr = "Local git resources (~ts) are unsupported and may have odd behaviour. "
+ "Use remote git resources, or a plugin for local dependencies.",
+ case parse_git_url(Url) of
+ {error, no_scheme} -> ?WARN(WarnStr, [Url]);
+ {error, {no_default_port, _, _}} -> ?WARN(WarnStr, [Url]);
+ {error, {malformed_url, _, _}} -> ?WARN(WarnStr, [Url]);
+ _ -> ok
+ end.
+
%% 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",