Made grep version command's grep POSIX
This commit is contained in:
parent
e56c73c940
commit
381189c006
2 changed files with 19 additions and 1 deletions
|
@ -86,7 +86,10 @@ get_patch_count(RawRef) ->
|
||||||
|
|
||||||
-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({Prefix}) ->
|
||||||
first_valid_tag(os:cmd("git log --oneline --decorate | fgrep \"tag: \" -1000"), Prefix).
|
first_valid_tag(os:cmd("git log --oneline --decorate | grep -F \"tag: \""), Prefix).
|
||||||
|
%% TODO: The following command sould be able to get the version
|
||||||
|
%% 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/\"".
|
||||||
|
|
||||||
-spec first_valid_tag(string(), string()) -> {string()|undefined, ec_semver:version_string()}.
|
-spec first_valid_tag(string(), string()) -> {string()|undefined, ec_semver:version_string()}.
|
||||||
first_valid_tag(Line, Prefix) ->
|
first_valid_tag(Line, Prefix) ->
|
||||||
|
|
15
test/ec_git_vsn_tests.erl
Normal file
15
test/ec_git_vsn_tests.erl
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
-module(ec_git_vsn_tests).
|
||||||
|
-include_lib("eunit/include/eunit.hrl").
|
||||||
|
-compile([export_all]).
|
||||||
|
|
||||||
|
|
||||||
|
%% Hi! This test only works because you've cloned this repo out of git
|
||||||
|
%% AND we're tagging this repo with a "v" prefix. Hey, it's better
|
||||||
|
%% than nothing.
|
||||||
|
vsn_grep_test() ->
|
||||||
|
{ok, VSN} = ec_git_vsn:vsn({"v"}),
|
||||||
|
|
||||||
|
[$v|OtherVSN] = os:cmd("git tag | xargs -I@ git log --format=format:\"%ai @%n\" -1 @ | sort -r | awk '{print $4}' | head -n 1"),
|
||||||
|
|
||||||
|
?assertEqual(OtherVSN, VSN ++ "\n"),
|
||||||
|
ok.
|
Loading…
Add table
Add a link
Reference in a new issue