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),