|
@ -5,7 +5,8 @@ |
|
|
-behaviour(rebar_resource). |
|
|
-behaviour(rebar_resource). |
|
|
|
|
|
|
|
|
-export([lock/2 |
|
|
-export([lock/2 |
|
|
,download/2]). |
|
|
|
|
|
|
|
|
,download/2 |
|
|
|
|
|
,needs_update/2]). |
|
|
|
|
|
|
|
|
-include("rebar.hrl"). |
|
|
-include("rebar.hrl"). |
|
|
|
|
|
|
|
@ -15,6 +16,40 @@ lock(AppDir, {git, Url, _}) -> |
|
|
,both, $\n), |
|
|
,both, $\n), |
|
|
{git, Url, {ref, Ref}}. |
|
|
{git, Url, {ref, Ref}}. |
|
|
|
|
|
|
|
|
|
|
|
needs_update(Dir, {git, Url, {tag, Tag}}) -> |
|
|
|
|
|
{ok, CurrentUrl} = rebar_utils:sh(?FMT("git config --get remote.origin.url", []), |
|
|
|
|
|
[{cd, Dir}]), |
|
|
|
|
|
{ok, Current} = rebar_utils:sh(?FMT("git describe --tags --exact-match", []), |
|
|
|
|
|
[{cd, Dir}]), |
|
|
|
|
|
Current1 = string:strip(string:strip(Current, both, $\n), both, $\r), |
|
|
|
|
|
CurrentUrl1 = string:strip(string:strip(CurrentUrl, both, $\n), both, $\r), |
|
|
|
|
|
?DEBUG("Comparing git tag ~s with ~s and url ~s with ~s~n", [Tag, Current1, Url, CurrentUrl1]), |
|
|
|
|
|
not ((Current1 =:= Tag) andalso (CurrentUrl1 =:= Url)); |
|
|
|
|
|
needs_update(Dir, {git, Url, {branch, Branch}}) -> |
|
|
|
|
|
{ok, CurrentUrl} = rebar_utils:sh(?FMT("git config --get remote.origin.url", []), |
|
|
|
|
|
[{cd, Dir}]), |
|
|
|
|
|
{ok, Current} = rebar_utils:sh(?FMT("git symbolic-ref -q --short HEAD", []), |
|
|
|
|
|
[{cd, Dir}]), |
|
|
|
|
|
Current1 = string:strip(string:strip(Current, both, $\n), both, $\r), |
|
|
|
|
|
CurrentUrl1 = string:strip(string:strip(CurrentUrl, both, $\n), both, $\r), |
|
|
|
|
|
?DEBUG("Comparing git branch ~s with ~s and url ~s with ~s~n", [Branch, Current1, Url, CurrentUrl1]), |
|
|
|
|
|
not ((Current1 =:= Branch) andalso (CurrentUrl1 =:= Url)); |
|
|
|
|
|
needs_update(Dir, {git, Url, Ref}) -> |
|
|
|
|
|
case Ref of |
|
|
|
|
|
{ref, Ref1} -> |
|
|
|
|
|
Ref1; |
|
|
|
|
|
Ref1 -> |
|
|
|
|
|
Ref1 |
|
|
|
|
|
end, |
|
|
|
|
|
{ok, CurrentUrl} = rebar_utils:sh(?FMT("git config --get remote.origin.url", []), |
|
|
|
|
|
[{cd, Dir}]), |
|
|
|
|
|
{ok, Current} = rebar_utils:sh(?FMT("git rev-parse -q HEAD", []), |
|
|
|
|
|
[{cd, Dir}]), |
|
|
|
|
|
Current1 = string:strip(string:strip(Current, both, $\n), both, $\r), |
|
|
|
|
|
CurrentUrl1 = string:strip(string:strip(CurrentUrl, both, $\n), both, $\r), |
|
|
|
|
|
?DEBUG("Comparing git ref ~s with ~s and url ~s with ~s~n", [Ref1, Current1, Url, CurrentUrl1]), |
|
|
|
|
|
not ((Current1 =:= Ref1) andalso (CurrentUrl1 =:= Url)). |
|
|
|
|
|
|
|
|
download(Dir, {git, Url}) -> |
|
|
download(Dir, {git, Url}) -> |
|
|
?WARN("WARNING: It is recommended to use {branch, Name}, {tag, Tag} or {ref, Ref}, otherwise updating the dep may not work as expected.~n", []), |
|
|
?WARN("WARNING: It is recommended to use {branch, Name}, {tag, Tag} or {ref, Ref}, otherwise updating the dep may not work as expected.~n", []), |
|
|
download(Dir, {git, Url, {branch, "HEAD"}}); |
|
|
download(Dir, {git, Url, {branch, "HEAD"}}); |
|
|