summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFred Hebert <mononcqc@ferd.ca>2015-02-16 12:16:51 -0500
committerFred Hebert <mononcqc@ferd.ca>2015-02-16 12:16:51 -0500
commitf6cdf563474979bc3d52f6570506291ca1d6db20 (patch)
tree17022575cc0d4f93595fc8ebb0c9d7aa113bb05a /src
parent9665eb8e72bf941b833d5ffa0f95ab736868a602 (diff)
parent9f2133df471197b936187a03a3c47b6bd860ea92 (diff)
Merge pull request #154 from tsloughter/git_ref_needs_update
needs_update: on ref defined deps only have to match prefix if 7+ chars
Diffstat (limited to 'src')
-rw-r--r--src/rebar_git_resource.erl23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/rebar_git_resource.erl b/src/rebar_git_resource.erl
index 4edaa48..bd0a978 100644
--- a/src/rebar_git_resource.erl
+++ b/src/rebar_git_resource.erl
@@ -37,18 +37,25 @@ needs_update(Dir, {git, Url, {branch, Branch}}) ->
needs_update(Dir, {git, Url, "master"}) ->
needs_update(Dir, {git, Url, {branch, "master"}});
needs_update(Dir, {git, Url, Ref}) ->
- case Ref of
- {ref, Ref1} ->
- Ref1;
- Ref1 ->
- Ref1
- end,
-
{ok, Current} = rebar_utils:sh(?FMT("git rev-parse -q HEAD", []),
[{cd, Dir}]),
Current1 = string:strip(string:strip(Current, both, $\n), both, $\r),
+
+ Ref2 = case Ref of
+ {ref, Ref1} ->
+ Length = length(Current1),
+ if
+ Length >= 7 ->
+ lists:sublist(Ref1, Length);
+ true ->
+ Ref1
+ end;
+ Ref1 ->
+ Ref1
+ end,
+
?DEBUG("Comparing git ref ~s with ~s", [Ref1, Current1]),
- not ((Current1 =:= Ref1) andalso compare_url(Dir, Url)).
+ not ((Current1 =:= Ref2) andalso compare_url(Dir, Url)).
compare_url(Dir, Url) ->
{ok, CurrentUrl} = rebar_utils:sh(?FMT("git config --get remote.origin.url", []),