Expand {vsn,git} in app.src to git-describe output

This commit is contained in:
Adam Kocoloski 2010-12-02 17:12:54 -05:00 committed by Tuncer Ayaz
parent 0a06a53c8e
commit b0860da124
2 changed files with 14 additions and 2 deletions

View file

@ -89,7 +89,14 @@ app_applications(AppFile) ->
app_vsn(AppFile) -> app_vsn(AppFile) ->
case load_app_file(AppFile) of case load_app_file(AppFile) of
{ok, _, AppInfo} -> {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} -> {error, Reason} ->
?ABORT("Failed to extract vsn from ~s: ~p\n", ?ABORT("Failed to extract vsn from ~s: ~p\n",
[AppFile, Reason]) [AppFile, Reason])

View file

@ -96,8 +96,13 @@ preprocess(Config, AppSrcFile) ->
AppVars = load_app_vars(Config) ++ [{modules, ebin_modules()}], AppVars = load_app_vars(Config) ++ [{modules, ebin_modules()}],
A1 = apply_app_vars(AppVars, AppData), 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 %% 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 %% Setup file .app filename and write new contents
AppFile = rebar_app_utils:app_src_to_app(AppSrcFile), AppFile = rebar_app_utils:app_src_to_app(AppSrcFile),