diff options
author | Ahmad Sherif <me@ahmadsherif.com> | 2018-01-29 18:22:33 +0100 |
---|---|---|
committer | Ahmad Sherif <me@ahmadsherif.com> | 2018-01-30 19:05:34 +0100 |
commit | 11191f938c3b865dbb3e203ecdb018fd91bd0c91 (patch) | |
tree | 8d8151f249b4d4458ea21c26ff3ffff2bfbf8a43 | |
parent | 44edd1111f9ba6dd0dacffad23b54c0c85a723c4 (diff) | |
download | gitlab-ce-fix/move-can-be-merged-to-lib-git.tar.gz |
Move Repository#can_be_merged? to Gitlab::Git::Repositoryfix/move-can-be-merged-to-lib-git
Fixes #42544
-rw-r--r-- | app/models/repository.rb | 20 | ||||
-rw-r--r-- | lib/gitlab/git/repository.rb | 18 |
2 files changed, 19 insertions, 19 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb index 5b06dc5a39b..49a094ab2da 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -800,16 +800,6 @@ class Repository with_cache_hooks { raw.multi_action(user, **options) } end - def can_be_merged?(source_sha, target_branch) - 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 - def merge(user, source_sha, merge_request, message) with_cache_hooks do raw_repository.merge(user, source_sha, merge_request.target_branch, message) do |commit_id| @@ -876,7 +866,7 @@ class Repository @root_ref_sha ||= commit(root_ref).sha end - delegate :merged_branch_names, to: :raw_repository + delegate :merged_branch_names, :can_be_merged?, to: :raw_repository def merge_base(first_commit_id, second_commit_id) first_commit_id = commit(first_commit_id).try(:id) || first_commit_id @@ -1095,12 +1085,4 @@ class Repository def initialize_raw_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 end diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb index 3a7930154e5..ff2a5df5676 100644 --- a/lib/gitlab/git/repository.rb +++ b/lib/gitlab/git/repository.rb @@ -1392,6 +1392,16 @@ module Gitlab run_git(args).first.scrub.split(/^--$/) end + def can_be_merged?(source_sha, target_branch) + gitaly_migrate(:can_be_merged) do |is_enabled| + if is_enabled + gitaly_can_be_merged?(source_sha, find_branch(target_branch, true).target) + else + rugged_can_be_merged?(source_sha, target_branch) + end + end + end + def search_files_by_name(query, ref) safe_query = Regexp.escape(query.sub(/^\/*/, "")) @@ -2234,6 +2244,14 @@ module Gitlab run_git(['fetch', remote_name], env: env).last.zero? end + def gitaly_can_be_merged?(their_commit, our_commit) + !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 gitlab_projects_error raise CommandError, @gitlab_projects.output end |