summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Kocoloski <adam@cloudant.com>2010-12-02 17:12:54 -0500
committerTuncer Ayaz <tuncer.ayaz@gmail.com>2011-02-17 19:17:28 +0100
commitb0860da1241e482e5125714e1cd343c9d734db10 (patch)
tree40546032898d11c7a8155c7f77a0ef80065bfcfd
parent0a06a53c8e60723f547b7abfc23bdc637035c307 (diff)
Expand {vsn,git} in app.src to git-describe output
-rw-r--r--src/rebar_app_utils.erl9
-rw-r--r--src/rebar_otp_app.erl7
2 files changed, 14 insertions, 2 deletions
diff --git a/src/rebar_app_utils.erl b/src/rebar_app_utils.erl
index 1fa870b..34d357a 100644
--- a/src/rebar_app_utils.erl
+++ b/src/rebar_app_utils.erl
@@ -89,7 +89,14 @@ app_applications(AppFile) ->
app_vsn(AppFile) ->
case load_app_file(AppFile) of
{ok, _, AppInfo} ->
- get_value(vsn, AppInfo, AppFile);
+ 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
+ end;
{error, Reason} ->
?ABORT("Failed to extract vsn from ~s: ~p\n",
[AppFile, Reason])
diff --git a/src/rebar_otp_app.erl b/src/rebar_otp_app.erl
index 4f21a67..f92de5c 100644
--- a/src/rebar_otp_app.erl
+++ b/src/rebar_otp_app.erl
@@ -96,8 +96,13 @@ preprocess(Config, AppSrcFile) ->
AppVars = load_app_vars(Config) ++ [{modules, ebin_modules()}],
A1 = apply_app_vars(AppVars, AppData),
+
+ %% AppSrcFile may contain instructions for generating a vsn number
+ Vsn = rebar_app_utils:app_vsn(AppSrcFile),
+ A2 = lists:keystore(vsn, 1, A1, {vsn, Vsn}),
+
%% Build the final spec as a string
- Spec = io_lib:format("~p.\n", [{application, AppName, A1}]),
+ Spec = io_lib:format("~p.\n", [{application, AppName, A2}]),
%% Setup file .app filename and write new contents
AppFile = rebar_app_utils:app_src_to_app(AppSrcFile),