summaryrefslogtreecommitdiff
path: root/src/rebar_hg_resource.erl
diff options
context:
space:
mode:
authorFred Hebert <mononcqc@ferd.ca>2017-10-05 13:14:50 -0400
committerFred Hebert <mononcqc@ferd.ca>2017-10-05 13:14:50 -0400
commit228df89f3bdf92b9cd4aa36fca69f7d2738a1951 (patch)
tree5d264b0fa2f2284e1da5e293ac92747106f46e09 /src/rebar_hg_resource.erl
parent4352614e9b74ca9e6a54552afbb536049a08bc7c (diff)
Warn user when a local git or hg resource is used
Those aren't supported and so a warning should be output. Fixes #1003
Diffstat (limited to 'src/rebar_hg_resource.erl')
-rw-r--r--src/rebar_hg_resource.erl14
1 files changed, 14 insertions, 0 deletions
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")};