diff options
author | Elvin Efendi <elvin.efendiev@shopify.com> | 2015-12-13 22:12:24 -0500 |
---|---|---|
committer | Elvin Efendi <elvin.efendiev@shopify.com> | 2015-12-13 22:12:24 -0500 |
commit | c2a52593a70a89582202d629842189b4a1448a15 (patch) | |
tree | 8855bcd679ba5ffb15acdf6a0ef6ec2b87867f89 /lib | |
parent | 1fd8f795e40641356d0a4577744c197723b6a3a1 (diff) |
do not commit when there is no diff
Diffstat (limited to 'lib')
-rw-r--r-- | lib/oxidized/hook/githubrepo.rb | 17 |
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], |