Skip to content

Commit

Permalink
testing
Browse files Browse the repository at this point in the history
  • Loading branch information
gregorej committed Feb 14, 2012
1 parent aef2525 commit d1c9d3a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 16 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ where ```Protocol``` is one of following:
You also have to add following dependency:

```erlang
{rebar_scm_plugin, {git, "git://github.com/gregorej/rebar_scm_plugin"}}
{rebar_scm_plugin, "1", {git, "git://github.com/gregorej/rebar_scm_plugin"}}
```


Expand Down
6 changes: 3 additions & 3 deletions rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@

{scm, {svn, "http://www.some/svn/trunk"}}.

{deps, [
{rebar, "2", {git, "git://github.com/basho/rebar"}}
]}.
%{deps, [
% {rebar, "2", {git, "git://github.com/basho/rebar"}}
%]}.
19 changes: 7 additions & 12 deletions src/rebar_scm_plugin.erl
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
-module(rebar_scm_plugin).

-export([
pre_scm/2,
scm/2
]).

-include_lib("rebar/include/rebar.hrl").
-include_lib("rebar.hrl").


%%
% url() ::= {protocol, [Path]}


as_url(UrlString) ->
Sep = "://",
L = length(Sep),
Expand All @@ -28,16 +26,11 @@ as_string({Protocol, PathParts}) ->
atom_to_list(Protocol) ++ "://" ++ string:join(PathParts, "/").


pre_scm(Config, AppFile) ->
rebar_config:set_global(skip_deps, true),
ok.

% copied from http://hyperthunk.github.com/rebar-plugin-tutorial/part-2-plugin-anatomy/index.html
is_base_dir() ->
rebar_utils:get_cwd() == rebar_config:get_global(base_dir, undefined).

scm(Config, AppFile) ->
?DEBUG("Works!~nConfig: ~p~nAppFile: ~p~n", [Config, AppFile]),
scm(Config, _AppFile) ->
case is_base_dir() of
true ->
Tag = rebar_config:get_global(tag, undefined),
Expand Down Expand Up @@ -65,15 +58,17 @@ scm(Config, AppFile) ->
tag({svn, UrlStr}, Tag) when is_list(UrlStr) ->
{ok, {Protocol, Path}} = as_url(UrlStr),
TargetPath = case lists:last(Path) of
% get rid of /trunk and append /tags/[Tag]
"trunk" -> lists:append(lists:sublist(Path, length(Path) - 1), ["tags",Tag]);
_ -> lists:append(Path, ["tags", Tag])
end,
rebar_utils:sh("svn copy " ++ UrlStr ++ " " ++ as_string({Protocol, TargetPath}), []);

tag({git, _Url}, Tag) ->
?Tag("Tagging with Git ~s", [Url]),
rebar_utils:sh("git tag " ++ Tag).
?INFO("Tagging with Git ~s", [Tag]),
rebar_utils:sh("git tag " ++ Tag);


tag({Scm, _},Tag) ->
tag({Scm, _}, _Tag) ->
?ERROR("Unknown scm: ~p", [Scm]).

0 comments on commit d1c9d3a

Please sign in to comment.