summaryrefslogtreecommitdiff
path: root/src/rebar_utils.erl
diff options
context:
space:
mode:
authorTristan Sloughter <t@crashfast.com>2014-11-03 11:41:47 -0600
committerTristan Sloughter <t@crashfast.com>2014-11-03 11:41:47 -0600
commita7bd7a3e1c9a31e6395a1a56e3815634f84e15ed (patch)
treecb0c806c6ad483f71c92ca87fc9572541244efec /src/rebar_utils.erl
parentf873510025924d662b2adde880f951b8787ded1d (diff)
add make_vsn to rebar_resource for replacing app vsns
Diffstat (limited to 'src/rebar_utils.erl')
-rw-r--r--src/rebar_utils.erl23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/rebar_utils.erl b/src/rebar_utils.erl
index 347b02a..4815ad2 100644
--- a/src/rebar_utils.erl
+++ b/src/rebar_utils.erl
@@ -438,13 +438,15 @@ escript_foldl(Fun, Acc, File) ->
end.
vcs_vsn_1(Vcs, Dir) ->
- case vcs_vsn_cmd(Vcs) of
+ case vcs_vsn_cmd(Vcs, Dir) of
{plain, VsnString} ->
VsnString;
{cmd, CmdString} ->
vcs_vsn_invoke(CmdString, Dir);
unknown ->
?ABORT("vcs_vsn: Unknown vsn format: ~p\n", [Vcs]);
+ {error, Reason} ->
+ ?ABORT("vcs_vsn: ~s\n", [Reason]);
Cmd ->
%% If there is a valid VCS directory in the application directory,
%% use that version info
@@ -471,15 +473,16 @@ vcs_vsn_1(Vcs, Dir) ->
end
end.
-vcs_vsn_cmd(git) -> "git describe --always --tags";
-vcs_vsn_cmd(p4) -> "echo #head";
-vcs_vsn_cmd(hg) -> "hg identify -i";
-vcs_vsn_cmd(bzr) -> "bzr revno";
-vcs_vsn_cmd(svn) -> "svnversion";
-vcs_vsn_cmd(fossil) -> "fossil info";
-vcs_vsn_cmd({cmd, _Cmd}=Custom) -> Custom;
-vcs_vsn_cmd(Version) when is_list(Version) -> {plain, Version};
-vcs_vsn_cmd(_) -> unknown.
+vcs_vsn_cmd(VCS, Dir) when VCS =:= git ; VCS =:= "git" ->
+ rebar_git_resource:make_vsn(Dir);
+vcs_vsn_cmd(VCS, Dir) when VCS =:= pkg ; VCS =:= "pkg" ->
+ rebar_pkg_resource:make_vsn(Dir);
+vcs_vsn_cmd({cmd, _Cmd}=Custom, _) ->
+ Custom;
+vcs_vsn_cmd(Version, _) when is_list(Version) ->
+ {plain, Version};
+vcs_vsn_cmd(_, _) ->
+ unknown.
vcs_vsn_invoke(Cmd, Dir) ->
{ok, VsnString} = rebar_utils:sh(Cmd, [{cd, Dir}, {use_stdout, false}]),