summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/rebar_utils.erl66
1 files changed, 33 insertions, 33 deletions
diff --git a/src/rebar_utils.erl b/src/rebar_utils.erl
index 27b2440..30e8621 100644
--- a/src/rebar_utils.erl
+++ b/src/rebar_utils.erl
@@ -205,39 +205,6 @@ vcs_vsn(Vcs, Dir) ->
VsnString
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, undefined, When).
@@ -427,6 +394,39 @@ emulate_escript_foldl(Fun, Acc, File) ->
Error
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) ->
%% git describe the last commit that touched CWD
%% required for correct versioning of apps in subdirs, such as apps/app1