Skip to content

Commit

Permalink
Merge pull request #2854 from filmor/vsn-from-hex
Browse files Browse the repository at this point in the history
Fall back to reading versions from hex metadata
  • Loading branch information
ferd authored Jan 8, 2024
2 parents 8f9c872 + b68df95 commit 837ccb0
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion apps/rebar/src/rebar_utils.erl
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,12 @@ vcs_vsn(AppInfo, Vcs, State) ->
{cmd, CmdString} ->
cmd_vsn_invoke(CmdString, rebar_app_info:dir(AppInfo));
unknown ->
?ABORT("vcs_vsn: Unknown vsn format: ~p", [Vcs]);
case vsn_from_hex_metadata(AppInfo) of
unknown ->
?ABORT("vcs_vsn: Unknown vsn format: ~p", [Vcs]);
Other ->
Other
end;
{error, Reason} ->
?ABORT("vcs_vsn: ~ts", [Reason])
end.
Expand Down Expand Up @@ -802,6 +807,21 @@ vcs_vsn_cmd(AppInfo, VCS, State) when is_list(VCS) ->
vcs_vsn_cmd(_, _, _) ->
unknown.

vsn_from_hex_metadata(AppInfo) ->
HexMetadataPath = filename:join(
rebar_app_info:dir(AppInfo),
"hex_metadata.config"
),

case filelib:is_regular(HexMetadataPath) of
true ->
{ok, HexMetadata} = file:consult(HexMetadataPath),
binary_to_list(proplists:get_value(<<"version">>, HexMetadata));
_ ->
unknown
end.


cmd_vsn_invoke(Cmd, Dir) ->
{ok, VsnString} = rebar_utils:sh(Cmd, [{cd, Dir}, {use_stdout, false}]),
rebar_string:trim(VsnString, trailing, "\n").
Expand Down

0 comments on commit 837ccb0

Please sign in to comment.