summaryrefslogtreecommitdiff
path: root/src/rebar_app_utils.erl
diff options
context:
space:
mode:
authorAlexey Romanov <alexey.v.romanov@gmail.com>2011-02-21 12:41:20 +0300
committerAlexey Romanov <alexey.v.romanov@gmail.com>2011-02-21 12:41:20 +0300
commit7dc371d8a3b9a6e2ab9f814c0d2536cf638ceb99 (patch)
tree174193ae08d2824164ba99e63f696a6593ee63c6 /src/rebar_app_utils.erl
parent2ceeb3272139b7569c8dabc215ca1e7063b0d385 (diff)
parent6056c63eed288736c912c82d6f36aa7dd055f9ca (diff)
Merge branch 'master' of https://github.com/basho/rebar
Diffstat (limited to 'src/rebar_app_utils.erl')
-rw-r--r--src/rebar_app_utils.erl29
1 files changed, 26 insertions, 3 deletions
diff --git a/src/rebar_app_utils.erl b/src/rebar_app_utils.erl
index 9574775..27b9176 100644
--- a/src/rebar_app_utils.erl
+++ b/src/rebar_app_utils.erl
@@ -1,4 +1,4 @@
-%% -*- tab-width: 4;erlang-indent-level: 4;indent-tabs-mode: nil -*-
+%% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*-
%% ex: ts=4 sw=4 et
%% -------------------------------------------------------------------
%%
@@ -80,7 +80,7 @@ app_name(AppFile) ->
app_applications(AppFile) ->
case load_app_file(AppFile) of
{ok, _, AppInfo} ->
- proplists:get_value(applications, AppInfo);
+ get_value(applications, AppInfo, AppFile);
{error, Reason} ->
?ABORT("Failed to extract applications from ~s: ~p\n",
[AppFile, Reason])
@@ -89,7 +89,7 @@ app_applications(AppFile) ->
app_vsn(AppFile) ->
case load_app_file(AppFile) of
{ok, _, AppInfo} ->
- proplists:get_value(vsn, AppInfo);
+ vcs_vsn(get_value(vsn, AppInfo, AppFile));
{error, Reason} ->
?ABORT("Failed to extract vsn from ~s: ~p\n",
[AppFile, Reason])
@@ -116,3 +116,26 @@ load_app_file(Filename) ->
{AppName, AppData} ->
{ok, AppName, AppData}
end.
+
+get_value(Key, AppInfo, AppFile) ->
+ case proplists:get_value(Key, AppInfo) of
+ undefined ->
+ ?ABORT("Failed to get app value '~p' from '~s'~n", [Key, AppFile]);
+ Value ->
+ Value
+ end.
+
+vcs_vsn(Vcs) ->
+ case vcs_vsn_cmd(Vcs) of
+ {unknown, VsnString} ->
+ VsnString;
+ Cmd ->
+ {ok, VsnString} = rebar_utils:sh(Cmd, [{use_stdout, false}]),
+ string:strip(VsnString, right, $\n)
+ end.
+
+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";
+vcs_vsn_cmd(Version) -> {unknown, Version}.