Skip to content
This repository has been archived by the owner on May 12, 2018. It is now read-only.

Commit

Permalink
bootstrap: fix and enhance VCS_INFO handling
Browse files Browse the repository at this point in the history
* re-compile rebar.erl instead of rebar_core to define VCS_INFO
* append "-dirty" if vcs indicates unclean repo status
  • Loading branch information
Tuncer Ayaz committed Aug 12, 2012
1 parent 0822075 commit e34b702
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions bootstrap
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@ main(Args) ->
Built = build_time(), Built = build_time(),


%% Get a string repr of first matching VCS changeset %% Get a string repr of first matching VCS changeset
VcsInfo = vcs_info([{hg, ".hg", "hg identify -i"}, VcsInfo = vcs_info([{hg, ".hg", "hg identify -i", "hg status"},
{git, ".git", "git describe --always --tags"}]), {git, ".git", "git describe --always --tags",
"git status -s"}]),


%% Check for force=1 flag to force a rebuild %% Check for force=1 flag to force a rebuild
case lists:member("force=1", Args) of case lists:member("force=1", Args) of
true -> true ->
rm("ebin/*.beam"); rm("ebin/*.beam");
false -> false ->
rm("ebin/rebar_core.beam") rm("ebin/rebar.beam")
end, end,


%% Add check for debug flag %% Add check for debug flag
Expand Down Expand Up @@ -93,10 +94,17 @@ build_time() ->


vcs_info([]) -> vcs_info([]) ->
"No VCS info available."; "No VCS info available.";
vcs_info([{Id, Dir, Cmd} | Rest]) -> vcs_info([{Id, Dir, VsnCmd, StatusCmd} | Rest]) ->
case filelib:is_dir(Dir) of case filelib:is_dir(Dir) of
true -> true ->
lists:concat([Id, " ", string:strip(os:cmd(Cmd), both, $\n)]); Vsn = string:strip(os:cmd(VsnCmd), both, $\n),
Status = case string:strip(os:cmd(StatusCmd), both, $\n) of
[] ->
"";
_ ->
"-dirty"
end,
lists:concat([Id, " ", Vsn, Status]);
false -> false ->
vcs_info(Rest) vcs_info(Rest)
end. end.
Expand Down

0 comments on commit e34b702

Please sign in to comment.