mirror of
https://github.com/correl/rebar.git
synced 2025-04-09 17:00:11 -09:00
rebar_utils: move internal fun to proper place
This commit is contained in:
parent
4fc3e9bfb6
commit
c41fda6a2f
1 changed files with 33 additions and 33 deletions
|
@ -205,39 +205,6 @@ vcs_vsn(Vcs, Dir) ->
|
||||||
VsnString
|
VsnString
|
||||||
end.
|
end.
|
||||||
|
|
||||||
vcs_vsn_1(Vcs, Dir) ->
|
|
||||||
case vcs_vsn_cmd(Vcs) of
|
|
||||||
{unknown, VsnString} ->
|
|
||||||
?DEBUG("vcs_vsn: Unknown VCS atom in vsn field: ~p\n", [Vcs]),
|
|
||||||
VsnString;
|
|
||||||
{cmd, CmdString} ->
|
|
||||||
vcs_vsn_invoke(CmdString, Dir);
|
|
||||||
Cmd ->
|
|
||||||
%% If there is a valid VCS directory in the application directory,
|
|
||||||
%% use that version info
|
|
||||||
Extension = lists:concat([".", Vcs]),
|
|
||||||
case filelib:is_dir(filename:join(Dir, Extension)) of
|
|
||||||
true ->
|
|
||||||
?DEBUG("vcs_vsn: Primary vcs used for ~s\n", [Dir]),
|
|
||||||
vcs_vsn_invoke(Cmd, Dir);
|
|
||||||
false ->
|
|
||||||
%% No VCS directory found for the app. Depending on source
|
|
||||||
%% tree structure, there may be one higher up, but that can
|
|
||||||
%% yield unexpected results when used with deps. So, we
|
|
||||||
%% fallback to searching for a priv/vsn.Vcs file.
|
|
||||||
VsnFile = filename:join([Dir, "priv", "vsn" ++ Extension]),
|
|
||||||
case file:read_file(VsnFile) of
|
|
||||||
{ok, VsnBin} ->
|
|
||||||
?DEBUG("vcs_vsn: Read ~s from priv/vsn.~p\n",
|
|
||||||
[VsnBin, Vcs]),
|
|
||||||
string:strip(binary_to_list(VsnBin), right, $\n);
|
|
||||||
{error, enoent} ->
|
|
||||||
?DEBUG("vcs_vsn: Fallback to vcs for ~s\n", [Dir]),
|
|
||||||
vcs_vsn_invoke(Cmd, Dir)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end.
|
|
||||||
|
|
||||||
get_deprecated_global(OldOpt, NewOpt, When) ->
|
get_deprecated_global(OldOpt, NewOpt, When) ->
|
||||||
get_deprecated_global(OldOpt, NewOpt, undefined, When).
|
get_deprecated_global(OldOpt, NewOpt, undefined, When).
|
||||||
|
|
||||||
|
@ -427,6 +394,39 @@ emulate_escript_foldl(Fun, Acc, File) ->
|
||||||
Error
|
Error
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
vcs_vsn_1(Vcs, Dir) ->
|
||||||
|
case vcs_vsn_cmd(Vcs) of
|
||||||
|
{unknown, VsnString} ->
|
||||||
|
?DEBUG("vcs_vsn: Unknown VCS atom in vsn field: ~p\n", [Vcs]),
|
||||||
|
VsnString;
|
||||||
|
{cmd, CmdString} ->
|
||||||
|
vcs_vsn_invoke(CmdString, Dir);
|
||||||
|
Cmd ->
|
||||||
|
%% If there is a valid VCS directory in the application directory,
|
||||||
|
%% use that version info
|
||||||
|
Extension = lists:concat([".", Vcs]),
|
||||||
|
case filelib:is_dir(filename:join(Dir, Extension)) of
|
||||||
|
true ->
|
||||||
|
?DEBUG("vcs_vsn: Primary vcs used for ~s\n", [Dir]),
|
||||||
|
vcs_vsn_invoke(Cmd, Dir);
|
||||||
|
false ->
|
||||||
|
%% No VCS directory found for the app. Depending on source
|
||||||
|
%% tree structure, there may be one higher up, but that can
|
||||||
|
%% yield unexpected results when used with deps. So, we
|
||||||
|
%% fallback to searching for a priv/vsn.Vcs file.
|
||||||
|
VsnFile = filename:join([Dir, "priv", "vsn" ++ Extension]),
|
||||||
|
case file:read_file(VsnFile) of
|
||||||
|
{ok, VsnBin} ->
|
||||||
|
?DEBUG("vcs_vsn: Read ~s from priv/vsn.~p\n",
|
||||||
|
[VsnBin, Vcs]),
|
||||||
|
string:strip(binary_to_list(VsnBin), right, $\n);
|
||||||
|
{error, enoent} ->
|
||||||
|
?DEBUG("vcs_vsn: Fallback to vcs for ~s\n", [Dir]),
|
||||||
|
vcs_vsn_invoke(Cmd, Dir)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end.
|
||||||
|
|
||||||
vcs_vsn_cmd(git) ->
|
vcs_vsn_cmd(git) ->
|
||||||
%% git describe the last commit that touched CWD
|
%% git describe the last commit that touched CWD
|
||||||
%% required for correct versioning of apps in subdirs, such as apps/app1
|
%% required for correct versioning of apps in subdirs, such as apps/app1
|
||||||
|
|
Loading…
Add table
Reference in a new issue