summaryrefslogtreecommitdiff
path: root/src/rebar_utils.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/rebar_utils.erl')
-rw-r--r--src/rebar_utils.erl28
1 files changed, 17 insertions, 11 deletions
diff --git a/src/rebar_utils.erl b/src/rebar_utils.erl
index 87387be..ae1d126 100644
--- a/src/rebar_utils.erl
+++ b/src/rebar_utils.erl
@@ -135,7 +135,7 @@ sh(Command0, Options0) ->
?DEBUG("sh info:\n\tcwd: ~p\n\tcmd: ~s\n", [get_cwd(), Command0]),
?DEBUG("\topts: ~p\n", [Options0]),
- DefaultOptions = [use_stdout, abort_on_error],
+ DefaultOptions = [{use_stdout, false}, abort_on_error],
Options = [expand_sh_flag(V)
|| V <- proplists:compact(Options0 ++ DefaultOptions)],
@@ -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,19 @@ 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.
+%% Temp work around for repos like relx that use "semver"
+vcs_vsn_cmd(VCS, Dir) when VCS =:= semver ; VCS =:= "semver" ->
+ rebar_git_resource:make_vsn(Dir);
+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}]),