Make ec_git_vsn Windows-compatible, readd prefix functionality.
This commit is contained in:
parent
874f2dc821
commit
57f56c2860
1 changed files with 8 additions and 16 deletions
|
@ -52,7 +52,7 @@ collect_default_refcount(Data) ->
|
||||||
RawCount =
|
RawCount =
|
||||||
case Tag of
|
case Tag of
|
||||||
undefined ->
|
undefined ->
|
||||||
os:cmd("git rev-list HEAD | wc -l");
|
os:cmd("git rev-list --count HEAD");
|
||||||
_ ->
|
_ ->
|
||||||
get_patch_count(Tag)
|
get_patch_count(Tag)
|
||||||
end,
|
end,
|
||||||
|
@ -80,23 +80,15 @@ build_vsn_string(Vsn, RawRef, RawCount) ->
|
||||||
|
|
||||||
get_patch_count(RawRef) ->
|
get_patch_count(RawRef) ->
|
||||||
Ref = re:replace(RawRef, "\\s", "", [global]),
|
Ref = re:replace(RawRef, "\\s", "", [global]),
|
||||||
Cmd = io_lib:format("git rev-list ~s..HEAD | wc -l",
|
Cmd = io_lib:format("git rev-list --count ~s..HEAD",
|
||||||
[Ref]),
|
[Ref]),
|
||||||
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(_) ->
|
parse_tags(Pattern) ->
|
||||||
first_valid_tag(os:cmd("git log --oneline --decorate | grep -F \"tag: \"")).
|
Cmd = io_lib:format("git describe --abbrev=0 --match \"~s*\"", [Pattern]),
|
||||||
%% TODO: The following command sould be able to get the version
|
Tag = os:cmd(Cmd),
|
||||||
%% number directly, without a re:run. Should be checked for POSIX
|
Vsn = string:substr(Tag, string:len(Pattern) + 1),
|
||||||
%% "git log --oneline --decorate | grep -F \"tag: \" --color=never | head -n 1 | sed \"s/.*tag: v?\([^,)]*\).*/\1/\"".
|
Vsn1 = string:strip(Vsn, left, $v),
|
||||||
|
{Tag, Vsn1}.
|
||||||
|
|
||||||
-spec first_valid_tag(string()) -> {string()|undefined, ec_semver:version_string()}.
|
|
||||||
first_valid_tag(Line) ->
|
|
||||||
RE = "(\\(|\\s)tag:\\s(v?([^,\\)]+))",
|
|
||||||
case re:run(Line, RE, [{capture, [2, 3], list}]) of
|
|
||||||
{match,[Tag, Vsn]} ->
|
|
||||||
{Tag, Vsn};
|
|
||||||
nomatch ->
|
|
||||||
{undefined, "0.0.0"}
|
|
||||||
end.
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue