Skip to content

Commit

Permalink
Improve on previous fix (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulo-ferraz-oliveira committed Apr 19, 2022
1 parent c1ef3ac commit 5ff9c80
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/dep_updater.erl
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,13 @@ maybe_update_hex_dep(Vsn, Package, Opts) ->
end.

%% NOTE: This function only updates git deps when they use valid semver tags.
maybe_update_git_dep(Name, {git, Repo, {tag, Vsn}}, _Dep, Opts) ->
maybe_update_git_dep(Name, {git, Repo, {tag, Vsn}}, Dep, Opts) ->
GitCmd =
lists:flatten(
io_lib:format("git -c 'versionsort.suffix=-' ls-remote --refs --tags ~p '*.*.*'",
[Repo])),
LatestVsn =
case rebar_utils:sh(GitCmd, [use_stdout]) of
case rebar_utils:sh(GitCmd, [return_on_error]) of
{ok, ""} ->
rebar_api:info("Latest version for ~p not found, keeping ~ts", [Name, Vsn]),
Vsn;
Expand All @@ -97,7 +97,10 @@ maybe_update_git_dep(Name, {git, Repo, {tag, Vsn}}, _Dep, Opts) ->
NewVsn =
lists:last(
string:tokens(LastTag, [$/])),
latest_version(Name, Vsn, iolist_to_binary(NewVsn), Opts)
latest_version(Name, Vsn, iolist_to_binary(NewVsn), Opts);
{error, {_Code, Msg}} ->
rebar_api:warn(Msg ++ "===> Skipping ~p", [Name]),
Dep
end,
{Name, {git, Repo, {tag, LatestVsn}}};
maybe_update_git_dep(Name, _Source, Dep, _Opts) ->
Expand Down

0 comments on commit 5ff9c80

Please sign in to comment.