summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTristan Sloughter <t@crashfast.com>2015-05-03 11:34:21 -0500
committerTristan Sloughter <t@crashfast.com>2015-05-03 12:15:27 -0500
commit214d6c979756a0acfcfa52d88d07ba882cde56d7 (patch)
tree2abb4727b3aa15219d07cd1a9c8cb22e155b2f89 /src
parentb4b6638ba9f7fb41f776c18eb08d31c3f804f00a (diff)
on upgrade of git branch check against remote
Diffstat (limited to 'src')
-rw-r--r--src/rebar_git_resource.erl11
-rw-r--r--src/rebar_prv_upgrade.erl1
2 files changed, 7 insertions, 5 deletions
diff --git a/src/rebar_git_resource.erl b/src/rebar_git_resource.erl
index 3b77da2..4e7485c 100644
--- a/src/rebar_git_resource.erl
+++ b/src/rebar_git_resource.erl
@@ -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}) ->
diff --git a/src/rebar_prv_upgrade.erl b/src/rebar_prv_upgrade.erl
index d7d2921..05845e4 100644
--- a/src/rebar_prv_upgrade.erl
+++ b/src/rebar_prv_upgrade.erl
@@ -140,4 +140,3 @@ info_useless(Old, New) ->
|| Name <- Old,
not lists:member(Name, New)],
ok.
-