From 2eef353c6ef98662c3092a5a28ee6f167b1d1774 Mon Sep 17 00:00:00 2001 From: Elvin Efendi Date: Tue, 8 Dec 2015 18:34:16 -0500 Subject: warn when there is a conflict --- lib/oxidized/hook/githubrepo.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/oxidized/hook/githubrepo.rb b/lib/oxidized/hook/githubrepo.rb index 83e1078..25b2cd0 100644 --- a/lib/oxidized/hook/githubrepo.rb +++ b/lib/oxidized/hook/githubrepo.rb @@ -16,12 +16,14 @@ class GithubRepo < Oxidized::Hook end def fetch_and_merge_remote(repo, credentials) - their_branch = repo.branches["origin/master"] or return - repo.fetch('origin', [repo.head.name], credentials: credentials) + their_branch = repo.branches["origin/master"] or return + merge_index = repo.merge_commits(repo.head.target_id, their_branch.target_id) + log("Conflicts detected", :warn) if merge_index.conflicts? + Rugged::Commit.create(repo, { parents: [repo.head.target, their_branch.target], tree: merge_index.write_tree(repo), -- cgit v1.2.1 From b6a9c3ae528de0b577ff3f7c601b4ca5b641185d Mon Sep 17 00:00:00 2001 From: Elvin Efendi Date: Tue, 8 Dec 2015 18:43:18 -0500 Subject: fix spec --- spec/githubrepo_spec.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/spec/githubrepo_spec.rb b/spec/githubrepo_spec.rb index 9b509e4..07296f3 100644 --- a/spec/githubrepo_spec.rb +++ b/spec/githubrepo_spec.rb @@ -18,8 +18,9 @@ describe Oxidized::Node do repo.expects(:remotes).returns({'origin' => remote}) repo.expects(:path).returns('foo.git') repo_head = mock() - repo_head.expects(:name).returns('origin/master') - repo.expects(:head).returns(repo_head) + repo_head.expects(:name).twice.returns('origin/master') + repo.expects(:head).twice.returns(repo_head) + repo.expects(:fetch).returns(true) repo.expects(:branches).returns({}) Rugged::Repository.expects(:new).with('foo.git').returns(repo) end -- cgit v1.2.1