make v optional as prefix to version in git_vsn
This commit is contained in:
parent
26c600922e
commit
7c37ecf949
2 changed files with 8 additions and 11 deletions
|
@ -24,7 +24,7 @@
|
||||||
%%%===================================================================
|
%%%===================================================================
|
||||||
%% This should be opaque, but that kills dialyzer so for now we export it
|
%% This should be opaque, but that kills dialyzer so for now we export it
|
||||||
%% however you should not rely on the internal representation here
|
%% however you should not rely on the internal representation here
|
||||||
-type t() :: {string()}.
|
-type t() :: {}.
|
||||||
|
|
||||||
%%%===================================================================
|
%%%===================================================================
|
||||||
%%% API
|
%%% API
|
||||||
|
@ -32,7 +32,7 @@
|
||||||
|
|
||||||
-spec new() -> t().
|
-spec new() -> t().
|
||||||
new() ->
|
new() ->
|
||||||
{"v"}.
|
{}.
|
||||||
|
|
||||||
-spec vsn(t()) -> {ok, string()} | {error, Reason::any()}.
|
-spec vsn(t()) -> {ok, string()} | {error, Reason::any()}.
|
||||||
vsn(Data) ->
|
vsn(Data) ->
|
||||||
|
@ -85,15 +85,15 @@ get_patch_count(RawRef) ->
|
||||||
os:cmd(Cmd).
|
os:cmd(Cmd).
|
||||||
|
|
||||||
-spec parse_tags(t()) -> {string()|undefined, ec_semver:version_string()}.
|
-spec parse_tags(t()) -> {string()|undefined, ec_semver:version_string()}.
|
||||||
parse_tags({Prefix}) ->
|
parse_tags(_) ->
|
||||||
first_valid_tag(os:cmd("git log --oneline --decorate | grep -F \"tag: \""), Prefix).
|
first_valid_tag(os:cmd("git log --oneline --decorate | grep -F \"tag: \"")).
|
||||||
%% TODO: The following command sould be able to get the version
|
%% TODO: The following command sould be able to get the version
|
||||||
%% number directly, without a re:run. Should be checked for POSIX
|
%% number directly, without a re:run. Should be checked for POSIX
|
||||||
%% "git log --oneline --decorate | grep -F \"tag: \" --color=never | head -n 1 | sed \"s/.*tag: " ++ Prefix ++ "\([^,)]*\).*/\1/\"".
|
%% "git log --oneline --decorate | grep -F \"tag: \" --color=never | head -n 1 | sed \"s/.*tag: v?\([^,)]*\).*/\1/\"".
|
||||||
|
|
||||||
-spec first_valid_tag(string(), string()) -> {string()|undefined, ec_semver:version_string()}.
|
-spec first_valid_tag(string()) -> {string()|undefined, ec_semver:version_string()}.
|
||||||
first_valid_tag(Line, Prefix) ->
|
first_valid_tag(Line) ->
|
||||||
RE = lists:flatten(io_lib:format("(\\(|\\s)tag:\\s(~s([^,\\)]+))", [Prefix])),
|
RE = "(\\(|\\s)tag:\\s(v?([^,\\)]+))",
|
||||||
case re:run(Line, RE, [{capture, [2, 3], list}]) of
|
case re:run(Line, RE, [{capture, [2, 3], list}]) of
|
||||||
{match,[Tag, Vsn]} ->
|
{match,[Tag, Vsn]} ->
|
||||||
{Tag, Vsn};
|
{Tag, Vsn};
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
%%% @copyright Erlware, LLC.
|
%%% @copyright Erlware, LLC.
|
||||||
-module(ec_plists_tests).
|
-module(ec_plists_tests).
|
||||||
|
|
||||||
-ifdef(DEV_ONLY).
|
|
||||||
|
|
||||||
-include_lib("eunit/include/eunit.hrl").
|
-include_lib("eunit/include/eunit.hrl").
|
||||||
|
|
||||||
%%%===================================================================
|
%%%===================================================================
|
||||||
|
@ -76,4 +74,3 @@ ftmap_bad_test() ->
|
||||||
?assertMatch([{value, 1}, {error,{throw,test_exception}}, {value, 3},
|
?assertMatch([{value, 1}, {error,{throw,test_exception}}, {value, 3},
|
||||||
{value, 4}, {value, 5}] , Results).
|
{value, 4}, {value, 5}] , Results).
|
||||||
|
|
||||||
-endif.
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue