mirror of
https://github.com/correl/rebar.git
synced 2024-12-18 03:00:17 +00:00
Expand {vsn,git} in app.src to git-describe output
This commit is contained in:
parent
0a06a53c8e
commit
b0860da124
2 changed files with 14 additions and 2 deletions
|
@ -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])
|
||||
|
|
|
@ -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),
|
||||
|
|
Loading…
Reference in a new issue