浏览代码

Merge pull request #598 from ferd/semver-nopath-change

Only have the port cd, not rebar3 as a whole
pull/603/head
Tristan Sloughter 9 年前
父节点
当前提交
9d20fb5c10
共有 1 个文件被更改,包括 10 次插入15 次删除
  1. +10
    -15
      src/rebar_git_resource.erl

+ 10
- 15
src/rebar_git_resource.erl 查看文件

@ -113,28 +113,23 @@ download(Dir, {git, Url, Rev}, _State) ->
rebar_utils:sh(?FMT("git checkout -q ~s", [Rev]), [{cd, Dir}]).
make_vsn(Dir) ->
Cwd = rebar_dir:get_cwd(),
try
ok = file:set_cwd(Dir),
{Vsn, RawRef, RawCount} = collect_default_refcount(),
{plain, build_vsn_string(Vsn, RawRef, RawCount)}
after
file:set_cwd(Cwd)
end.
{Vsn, RawRef, RawCount} = collect_default_refcount(Dir),
{plain, build_vsn_string(Vsn, RawRef, RawCount)}.
%% Internal functions
collect_default_refcount() ->
collect_default_refcount(Dir) ->
%% Get the tag timestamp and minimal ref from the system. The
%% timestamp is really important from an ordering perspective.
AbortMsg1 = "Getting log of git dependency failed in " ++ rebar_dir:get_cwd(),
{ok, String} =
rebar_utils:sh("git log -n 1 --pretty=format:\"%h\n\" ",
[{use_stdout, false},
{cd, Dir},
{debug_abort_on_error, AbortMsg1}]),
RawRef = string:strip(String, both, $\n),
{Tag, TagVsn} = parse_tags(),
{Tag, TagVsn} = parse_tags(Dir),
{ok, RawCount} =
case Tag of
undefined ->
@ -144,7 +139,7 @@ collect_default_refcount() ->
{debug_abort_on_error, AbortMsg2}]),
rebar_utils:line_count(PatchLines);
_ ->
get_patch_count(Tag)
get_patch_count(Dir, Tag)
end,
{TagVsn, RawRef, RawCount}.
@ -162,8 +157,8 @@ build_vsn_string(Vsn, RawRef, Count) ->
integer_to_list(Count), RefTag]))
end.
get_patch_count(RawRef) ->
AbortMsg = "Getting rev-list of git dep failed in " ++ rebar_dir:get_cwd(),
get_patch_count(Dir, RawRef) ->
AbortMsg = "Getting rev-list of git dep failed in " ++ Dir,
Ref = re:replace(RawRef, "\\s", "", [global]),
Cmd = io_lib:format("git rev-list ~s..HEAD",
[Ref]),
@ -173,10 +168,10 @@ get_patch_count(RawRef) ->
rebar_utils:line_count(PatchLines).
parse_tags() ->
parse_tags(Dir) ->
%% Don't abort on error, we want the bad return to be turned into 0.0.0
case rebar_utils:sh("git log --oneline --no-walk --tags --decorate",
[{use_stdout, false}, return_on_error]) of
[{use_stdout, false}, return_on_error, {cd, Dir}]) of
{error, _} ->
{undefined, "0.0.0"};
{ok, Line} ->

正在加载...
取消
保存