Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzegorz@gitlab.com>2018-01-15 11:10:30 +0300
committerGrzegorz Bizon <grzegorz@gitlab.com>2018-01-15 11:10:30 +0300
commit6277ef8e285b203bbe5db3893af2a84b537fc454 (patch)
treea5a467df20cecb2772233d12050d4c7e3fd55c21 /app
parent74f2f9b30fb1972a26481072486b358eb943309f (diff)
parentb4b267b7395ca524f4251f6eefe91e502b086ab0 (diff)
Merge branch 'feature/migrate-can-be-merged-to-gitaly' into 'master'
Migrate Repository#can_be_merged? to Gitaly Closes gitaly#893 See merge request gitlab-org/gitlab-ce!16316
Diffstat (limited to 'app')
-rw-r--r--app/models/repository.rb21
1 files changed, 14 insertions, 7 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb
index 8e9f33c174c..2ffd9558ebc 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -831,13 +831,12 @@ class Repository
end
def can_be_merged?(source_sha, target_branch)
- our_commit = rugged.branches[target_branch].target
- their_commit = rugged.lookup(source_sha)
-
- if our_commit && their_commit
- !rugged.merge_commits(our_commit, their_commit).conflicts?
- else
- false
+ raw_repository.gitaly_migrate(:can_be_merged) do |is_enabled|
+ if is_enabled
+ gitaly_can_be_merged?(source_sha, find_branch(target_branch).target)
+ else
+ rugged_can_be_merged?(source_sha, target_branch)
+ end
end
end
@@ -1132,6 +1131,14 @@ class Repository
Gitlab::Git::Repository.new(project.repository_storage, disk_path + '.git', Gitlab::GlRepository.gl_repository(project, is_wiki))
end
+ def gitaly_can_be_merged?(their_commit, our_commit)
+ !raw_repository.gitaly_conflicts_client(our_commit, their_commit).conflicts?
+ end
+
+ def rugged_can_be_merged?(their_commit, our_commit)
+ !rugged.merge_commits(our_commit, their_commit).conflicts?
+ end
+
def find_commits_by_message_by_shelling_out(query, ref, path, limit, offset)
ref ||= root_ref