summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/rebar_git_resource.erl14
-rw-r--r--src/rebar_hg_resource.erl14
2 files changed, 28 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",
diff --git a/src/rebar_hg_resource.erl b/src/rebar_hg_resource.erl
index 42e634c..0a77c1f 100644
--- a/src/rebar_hg_resource.erl
+++ b/src/rebar_hg_resource.erl
@@ -56,6 +56,7 @@ download(Dir, {hg, Url, ""}, State) ->
download(Dir, {hg, Url, {branch, "default"}}, State);
download(Dir, {hg, Url, {branch, Branch}}, _State) ->
ok = filelib:ensure_dir(Dir),
+ maybe_warn_local_url(Url),
rebar_utils:sh(?FMT("hg clone -q -b ~ts ~ts ~ts",
[rebar_utils:escape_chars(Branch),
rebar_utils:escape_chars(Url),
@@ -63,6 +64,7 @@ download(Dir, {hg, Url, {branch, Branch}}, _State) ->
[{cd, filename:dirname(Dir)}]);
download(Dir, {hg, Url, {tag, Tag}}, _State) ->
ok = filelib:ensure_dir(Dir),
+ maybe_warn_local_url(Url),
rebar_utils:sh(?FMT("hg clone -q -u ~ts ~ts ~ts",
[rebar_utils:escape_chars(Tag),
rebar_utils:escape_chars(Url),
@@ -70,6 +72,7 @@ download(Dir, {hg, Url, {tag, Tag}}, _State) ->
[{cd, filename:dirname(Dir)}]);
download(Dir, {hg, Url, {ref, Ref}}, _State) ->
ok = filelib:ensure_dir(Dir),
+ maybe_warn_local_url(Url),
rebar_utils:sh(?FMT("hg clone -q -r ~ts ~ts ~ts",
[rebar_utils:escape_chars(Ref),
rebar_utils:escape_chars(Url),
@@ -77,6 +80,7 @@ download(Dir, {hg, Url, {ref, Ref}}, _State) ->
[{cd, filename:dirname(Dir)}]);
download(Dir, {hg, Url, Rev}, _State) ->
ok = filelib:ensure_dir(Dir),
+ maybe_warn_local_url(Url),
rebar_utils:sh(?FMT("hg clone -q -r ~ts ~ts ~ts",
[rebar_utils:escape_chars(Rev),
rebar_utils:escape_chars(Url),
@@ -135,6 +139,16 @@ get_branch_ref(Dir, Branch) ->
[{use_stdout, false}, {debug_abort_on_error, AbortMsg}]),
string:strip(BranchRefString, both, $\n).
+
+maybe_warn_local_url(Url) ->
+ try
+ _ = parse_hg_url(Url),
+ ok
+ catch
+ _:_ ->
+ ?WARN("URL format (~ts) unsupported.", [])
+ end.
+
parse_hg_url("ssh://" ++ HostPath) ->
[Host | Path] = string:tokens(HostPath, "/"),
{Host, filename:rootname(filename:join(Path), ".hg")};