support reasonable versioning for erlware_commons

You should get the latest and greatest rebar to build this.

Signed-off-by: Jordan Wilberding <diginux@gmail.com>
This commit is contained in:
Eric Merritt 2012-09-19 07:57:48 -07:00 committed by Jordan Wilberding
parent f77afd43c3
commit 0db7042ff9
2 changed files with 23 additions and 1 deletions

View file

@ -1,7 +1,7 @@
%% -*- mode: Erlang; fill-column: 75; comment-column: 50; -*- %% -*- mode: Erlang; fill-column: 75; comment-column: 50; -*-
{application, erlware_commons, {application, erlware_commons,
[{description, "Additional standard library for Erlang"}, [{description, "Additional standard library for Erlang"},
{vsn, "0.8.0"}, {vsn, git},
{modules, []}, {modules, []},
{registered, []}, {registered, []},
{applications, [kernel, stdlib]}]}. {applications, [kernel, stdlib]}]}.

View file

@ -0,0 +1,22 @@
%% -*- mode: Erlang; erlang-indent-level: 4; indent-tabs-mode: nil; fill-column: 80 -*-
[{application, AppName, Details0}] = CONFIG,
%% Get the tag timestamp and minimal ref from the system. The
%% timestamp is really important from an ordering perspective.
{ok, RawRef} = rebar_utils:sh("git log -n 1 --pretty=format:'%ct.%h\n' .", []),
{ok, RawTag} = rebar_utils:sh("git describe --always --abbrev=0 --tags "
"`git log -n 1 --pretty=format:%h .`", []),
%% Cleanup the tag and the Ref information. Basically leading 'v's and
%% whitespace needs to go away.
Tag = re:replace(RawTag, "(^v)|\\s", "", [global]),
Ref = re:replace(RawRef, "\\s", "", [global]),
%% Create the valid [semver](http://semver.org) version from the tag
Vsn = erlang:binary_to_list(erlang:iolist_to_binary([Tag, "+build.", Ref])),
%% Replace the old version with the new one
Details1 = lists:keyreplace(vsn, 1, Details0, {vsn, Vsn}),
[{application, AppName, Details1}].