Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Feature: force protocol when getting dependencies #158

wants to merge 4 commits into from

2 participants


Added because of not always being able to use certain protocols (mainly git) from corporate intranet. And dirtying dependencies by editing their configuration files is well, dirty.

To force ssh, http or https use force_protocol=Protocol.

In effect

                    rebar get-deps force_protocol=https

This looks fine, but can you add some eunits to test the regexes are behaving?


Also, why is this better than simply configuring git like this:

[url "ssh://"]
  insteadOf = git://
  insteadOf =
  insteadOf =

If, for example, I wanted to default to the ssh protocol on github?



It's not really; I did'nt know of the insteadOf option when writiing this.

So; Im closing this PR.

Thanks for replying :)

@dawik dawik closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 17, 2013
  1. @dawik
  2. @dawik
Commits on Oct 18, 2013
  1. @dawik

    That should cover it..

    dawik authored
  2. @dawik


    dawik authored
This page is out of date. Refresh to see the latest.
Showing with 30 additions and 2 deletions.
  1. +30 −2 src/rebar_deps.erl
32 src/rebar_deps.erl
@@ -478,13 +478,41 @@ use_source(Config, Dep, Count) ->
"with reason:~n~p.\n", [Dep#dep.dir, Reason])
false ->
- ?CONSOLE("Pulling ~p from ~p\n", [, Dep#dep.source]),
{true, TargetDir} = get_deps_dir(Config,,
- download_source(TargetDir, Dep#dep.source),
+ {true, TargetUrl} = set_protocol(Config, Dep#dep.source),
+ ?CONSOLE("Pulling ~p from ~p\n", [, TargetUrl]),
+ download_source(TargetDir, TargetUrl),
use_source(Config, Dep#dep { dir = TargetDir }, Count-1)
+set_protocol(bzr, "ssh", Url) ->
+ re:replace(Url, "^.[^:]*","bzr+ssh",[{return,list}]);
+set_protocol(fossil, _Protocol, Url) ->
+ Url;
+set_protocol(git, Protocol, Url) ->
+ re:replace(re:replace(Url, "^.[^:]*",Protocol,[{return,list}]), ".git$", "",[{return,list}]);
+set_protocol(rsync, _Protocol, Url) ->
+ Url;
+set_protocol(svn, "ssh", Url) ->
+ re:replace(Url, "^.[^:]*","svn+ssh",[{return,list}]);
+set_protocol(_Cvs, Protocol, Url) ->
+ re:replace(Url, "^.[^:]*",Protocol,[{return,list}]).
+set_protocol({"default", Source}) ->
+ {true, Source};
+set_protocol({Protocol, {Cvs, Url}}) ->
+ {true, {Cvs, set_protocol(Cvs, Protocol, Url)}};
+set_protocol({Protocol, {Cvs, Url, Tag}}) ->
+ {true, {Cvs, set_protocol(Cvs, Protocol, Url), Tag}}.
+set_protocol(Config, Source) ->
+ Protocol = rebar_config:get_global(Config, force_protocol, "default"),
+ case lists:member(list_to_atom(Protocol), [default, http, https, ssh]) of
+ true -> set_protocol({Protocol, Source});
+ false -> ?ABORT("~p invalid option\n", [Protocol])
+ end.
download_source(AppDir, {hg, Url, Rev}) ->
ok = filelib:ensure_dir(AppDir),
rebar_utils:sh(?FMT("hg clone -U ~s ~s", [Url, filename:basename(AppDir)]),
Something went wrong with that request. Please try again.