diff options
Diffstat (limited to 'src/rebar_utils.erl')
-rw-r--r-- | src/rebar_utils.erl | 23 |
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}]), |