summaryrefslogtreecommitdiff
path: root/lib/oxidized/hook
diff options
context:
space:
mode:
authorElvin Efendi <elvin.efendiyev@gmail.com>2015-12-13 22:21:21 -0500
committerElvin Efendi <elvin.efendiyev@gmail.com>2015-12-13 22:21:21 -0500
commitef1a59d2b29df5b00246ee34eba96b0cf4927fa2 (patch)
tree8855bcd679ba5ffb15acdf6a0ef6ec2b87867f89 /lib/oxidized/hook
parent1fd8f795e40641356d0a4577744c197723b6a3a1 (diff)
parentc2a52593a70a89582202d629842189b4a1448a15 (diff)
Merge pull request #15 from Shopify/issue-14
do not commit when there is no diff
Diffstat (limited to 'lib/oxidized/hook')
-rw-r--r--lib/oxidized/hook/githubrepo.rb17
1 files changed, 14 insertions, 3 deletions
diff --git a/lib/oxidized/hook/githubrepo.rb b/lib/oxidized/hook/githubrepo.rb
index 22ee8ea..d10b51e 100644
--- a/lib/oxidized/hook/githubrepo.rb
+++ b/lib/oxidized/hook/githubrepo.rb
@@ -15,13 +15,24 @@ class GithubRepo < Oxidized::Hook
end
def fetch_and_merge_remote(repo)
- repo.fetch('origin', [repo.head.name], credentials: credentials)
+ result = repo.fetch('origin', [repo.head.name], credentials: credentials)
+ log result.inspect, :debug
- their_branch = repo.branches["origin/master"] or return
+ unless result[:total_deltas] > 0
+ log "nothing recieved after fetch", :debug
+ return
+ end
+
+ their_branch = repo.branches["origin/master"]
+
+ log "merging fetched branch #{their_branch.name}", :debug
merge_index = repo.merge_commits(repo.head.target_id, their_branch.target_id)
- log("Conflicts detected", :warn) if merge_index.conflicts?
+ if merge_index.conflicts?
+ log("Conflicts detected, skipping Rugged::Commit.create", :warn)
+ return
+ end
Rugged::Commit.create(repo, {
parents: [repo.head.target, their_branch.target],