From 02bc52fc6aaca0ddb66dbe9e586df10ac82c6bce Mon Sep 17 00:00:00 2001 From: Dave Smith Date: Tue, 22 Jun 2010 13:47:06 -0600 Subject: [PATCH] Add support for embedding VCS info into the version data --- bootstrap | 6 +++++- src/rebar_core.erl | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/bootstrap b/bootstrap index cbd17c3..d9327ba 100755 --- a/bootstrap +++ b/bootstrap @@ -6,6 +6,9 @@ main(Args) -> %% Get a string repr of build time Built = build_time(), + %% Get a string repr of hg changeset + HgInfo = "hg " ++ string:strip(os:cmd("hg identify -i"), both, $\n), + %% Check for force=1 flag to force a rebuild case lists:member("force=1", Args) of true -> @@ -17,7 +20,8 @@ main(Args) -> %% Compile all src/*.erl to ebin case make:files(filelib:wildcard("src/*.erl"), [{outdir, "ebin"}, {i, "include"}, - {d, 'BUILD_TIME', Built}]) of + {d, 'BUILD_TIME', Built}, + {d, 'VCS_INFO', HgInfo}]) of up_to_date -> ok; error -> diff --git a/src/rebar_core.erl b/src/rebar_core.erl index ec568f9..e9c37de 100644 --- a/src/rebar_core.erl +++ b/src/rebar_core.erl @@ -38,6 +38,10 @@ -define(BUILD_TIME, "undefined"). -endif. +-ifndef(VCS_INFO). +-define(VCS_INFO, "undefined"). +-endif. + %% =================================================================== %% Public API %% =================================================================== @@ -231,7 +235,7 @@ version Show version information %% version() -> {ok, Vsn} = application:get_key(rebar, vsn), - ?CONSOLE("Version ~s built ~s\n", [Vsn, ?BUILD_TIME]). + ?CONSOLE("rebar version: ~s date: ~s vcs: ~s\n", [Vsn, ?BUILD_TIME, ?VCS_INFO]). %% %% options accepted via getopt