summaryrefslogtreecommitdiff
path: root/lib/oxidized/hook/githubrepo.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/oxidized/hook/githubrepo.rb')
-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],