summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/api/entities.rb6
-rw-r--r--lib/gitlab/git/repository.rb16
2 files changed, 18 insertions, 4 deletions
diff --git a/lib/api/entities.rb b/lib/api/entities.rb
index 16ae99b5c6c..acfd4a1ef4d 100644
--- a/lib/api/entities.rb
+++ b/lib/api/entities.rb
@@ -242,7 +242,11 @@ module API
end
expose :merged do |repo_branch, options|
- options[:project].repository.merged_to_root_ref?(repo_branch, options[:merged_branch_names])
+ if options[:merged_branch_names]
+ options[:merged_branch_names].include?(repo_branch.name)
+ else
+ options[:project].repository.merged_to_root_ref?(repo_branch)
+ end
end
expose :protected do |repo_branch, options|
diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb
index dcca20c75ef..ff408c0c4dd 100644
--- a/lib/gitlab/git/repository.rb
+++ b/lib/gitlab/git/repository.rb
@@ -1243,11 +1243,21 @@ module Gitlab
sort_branches(branches, sort_by)
end
+ # Gitaly migration: https://gitlab.com/gitlab-org/gitaly/issues/695
def git_merged_branch_names(branch_names = [])
- lines = run_git(['branch', '--merged', root_ref] + branch_names)
- .first.lines
+ root_sha = find_branch(root_ref).target
- lines.map(&:strip)
+ git_arguments =
+ %W[branch --merged #{root_sha}
+ --format=%(refname:short)\ %(objectname)] + branch_names
+
+ lines = run_git(git_arguments).first.lines
+
+ lines.each_with_object([]) do |line, branches|
+ name, sha = line.strip.split(' ', 2)
+
+ branches << name if sha != root_sha
+ end
end
def log_using_shell?(options)