diff options
author | Tuncer Ayaz <tuncer.ayaz@gmail.com> | 2012-06-23 22:00:38 +0200 |
---|---|---|
committer | Tuncer Ayaz <tuncer.ayaz@gmail.com> | 2012-06-23 22:00:38 +0200 |
commit | c41fda6a2fdcdc492c2f6f319e2a5fae3f39031c (patch) | |
tree | 172e60692f1ab3b203eb682d36c3e5f367ef7881 /src | |
parent | 4fc3e9bfb6c19c8f1da56c0485bbca1077a7541b (diff) |
rebar_utils: move internal fun to proper place
Diffstat (limited to 'src')
-rw-r--r-- | src/rebar_utils.erl | 66 |
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 |