summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTuncer Ayaz <tuncer.ayaz@gmail.com>2011-02-16 23:47:23 +0100
committerTuncer Ayaz <tuncer.ayaz@gmail.com>2011-02-17 19:23:43 +0100
commit01a7473dac44befe05c460e28c601e2eec785b41 (patch)
tree6ea5dc9e8f450d7669ca7f667630ae04f3bb100a /src
parentb0860da1241e482e5125714e1cd343c9d734db10 (diff)
Add {vsn,Vcs} support for bzr, hg and svn
Diffstat (limited to 'src')
-rw-r--r--src/rebar_app_utils.erl21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/rebar_app_utils.erl b/src/rebar_app_utils.erl
index 34d357a..f50ac86 100644
--- a/src/rebar_app_utils.erl
+++ b/src/rebar_app_utils.erl
@@ -90,12 +90,11 @@ app_vsn(AppFile) ->
case load_app_file(AppFile) of
{ok, _, AppInfo} ->
case get_value(vsn, AppInfo, AppFile) of
- git ->
- Cmd = "git describe --tags --always",
- {ok, VsnString} = rebar_utils:sh(Cmd, []),
- string:strip(VsnString, right, $\n);
- Version ->
- Version
+ git -> vcs_vsn(git);
+ hg -> vcs_vsn(hg);
+ bzr -> vcs_vsn(bzr);
+ svn -> vcs_vsn(svn);
+ Version -> Version
end;
{error, Reason} ->
?ABORT("Failed to extract vsn from ~s: ~p\n",
@@ -131,3 +130,13 @@ get_value(Key, AppInfo, AppFile) ->
Value ->
Value
end.
+
+vcs_vsn(Vcs) ->
+ Cmd = vcs_vsn_cmd(Vcs),
+ {ok, VsnString} = rebar_utils:sh(Cmd, [{use_stdout, false}]),
+ string:strip(VsnString, right, $\n).
+
+vcs_vsn_cmd(git) -> "git describe --always --tags";
+vcs_vsn_cmd(hg) -> "hg identify -i";
+vcs_vsn_cmd(bzr) -> "bzr revno";
+vcs_vsn_cmd(svn) -> "svnversion".