Skip to content

Commit

Permalink
on upgrade of git branch check against remote
Browse files Browse the repository at this point in the history
  • Loading branch information
tsloughter committed May 3, 2015
1 parent b4b6638 commit 214d6c9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
11 changes: 7 additions & 4 deletions src/rebar_git_resource.erl
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,14 @@ needs_update(Dir, {git, Url, {tag, Tag}}) ->
?DEBUG("Comparing git tag ~s with ~s", [Tag, Current1]),
not ((Current1 =:= Tag) andalso compare_url(Dir, Url));
needs_update(Dir, {git, Url, {branch, Branch}}) ->
{ok, Current} = rebar_utils:sh(?FMT("git symbolic-ref -q --short HEAD", []),
%% Fetch remote so we can check if the branch has changed
{ok, _} = rebar_utils:sh(?FMT("git fetch", []),
[{cd, Dir}]),
%% Check for new commits to origin/Branch
{ok, Current} = rebar_utils:sh(?FMT("git log HEAD..origin/~s --oneline", [Branch]),
[{cd, Dir}]),
Current1 = string:strip(string:strip(Current, both, $\n), both, $\r),
?DEBUG("Comparing git branch ~s with ~s", [Branch, Current1]),
not ((Current1 =:= Branch) andalso compare_url(Dir, Url));
?DEBUG("Checking git branch ~s for updates", [Branch]),
not ((Current =:= []) andalso compare_url(Dir, Url));
needs_update(Dir, {git, Url, "master"}) ->
needs_update(Dir, {git, Url, {branch, "master"}});
needs_update(Dir, {git, Url, Ref}) ->
Expand Down
1 change: 0 additions & 1 deletion src/rebar_prv_upgrade.erl
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,3 @@ info_useless(Old, New) ->
|| Name <- Old,
not lists:member(Name, New)],
ok.

0 comments on commit 214d6c9

Please sign in to comment.