Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Feature: force protocol when getting dependencies #158

Closed
wants to merge 4 commits into from

2 participants

@dawik

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
@Vagabond
Owner

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

@Vagabond
Owner

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

[url "ssh://git@github.com/"]
  insteadOf = git://github.com/
  insteadOf = https://github.com/
  insteadOf = http://github.com/

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

@dawik

Hey:

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

    Consistency

    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
View
32 src/rebar_deps.erl
@@ -478,13 +478,41 @@ use_source(Config, Dep, Count) ->
"with reason:~n~p.\n", [Dep#dep.dir, Reason])
end;
false ->
- ?CONSOLE("Pulling ~p from ~p\n", [Dep#dep.app, Dep#dep.source]),
require_source_engine(Dep#dep.source),
{true, TargetDir} = get_deps_dir(Config, Dep#dep.app),
- download_source(TargetDir, Dep#dep.source),
+ {true, TargetUrl} = set_protocol(Config, Dep#dep.source),
+ ?CONSOLE("Pulling ~p from ~p\n", [Dep#dep.app, TargetUrl]),
+ download_source(TargetDir, TargetUrl),
use_source(Config, Dep#dep { dir = TargetDir }, Count-1)
end.
+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.