Commit fd089dd5 authored by GitLab Bot's avatar GitLab Bot

Automatic merge of gitlab-org/gitlab-ce master

parents c5b892f8 bbd0a2ce
...@@ -45,9 +45,7 @@ module Secpick ...@@ -45,9 +45,7 @@ module Secpick
def git_commands def git_commands
["git fetch #{@options[:remote]} #{stable_branch}", ["git fetch #{@options[:remote]} #{stable_branch}",
"git checkout #{stable_branch}", "git checkout -B #{source_branch} #{@options[:remote]}/#{stable_branch}",
"git pull #{@options[:remote]} #{stable_branch}",
"git checkout -B #{source_branch}",
"git cherry-pick #{@options[:sha]}", "git cherry-pick #{@options[:sha]}",
"git push #{@options[:remote]} #{source_branch}", "git push #{@options[:remote]} #{source_branch}",
"git checkout #{original_branch}"] "git checkout #{original_branch}"]
......
---
title: 'API: Expose if the current user can merge a MR'
merge_request: 25207
author: Robert Schilling
type: added
...@@ -438,6 +438,9 @@ Parameters: ...@@ -438,6 +438,9 @@ Parameters:
"avatar_url": null, "avatar_url": null,
"web_url" : "https://gitlab.example.com/admin" "web_url" : "https://gitlab.example.com/admin"
}, },
"user" : {
"can_merge" : false
}
"assignee": { "assignee": {
"id": 1, "id": 1,
"name": "Administrator", "name": "Administrator",
......
...@@ -734,6 +734,12 @@ module API ...@@ -734,6 +734,12 @@ module API
def build_available?(options) def build_available?(options)
options[:project]&.feature_available?(:builds, options[:current_user]) options[:project]&.feature_available?(:builds, options[:current_user])
end end
expose :user do
expose :can_merge do |merge_request, options|
merge_request.can_be_merged_by?(options[:current_user])
end
end
end end
class MergeRequestChanges < MergeRequest class MergeRequestChanges < MergeRequest
......
...@@ -114,7 +114,7 @@ module Gitlab ...@@ -114,7 +114,7 @@ module Gitlab
%r{\A(ee/)?spec/(?!javascripts)[^/]+} => :backend, %r{\A(ee/)?spec/(?!javascripts)[^/]+} => :backend,
%r{\A(ee/)?vendor/(?!assets)[^/]+} => :backend, %r{\A(ee/)?vendor/(?!assets)[^/]+} => :backend,
%r{\A(ee/)?vendor/(languages\.yml|licenses\.csv)\z} => :backend, %r{\A(ee/)?vendor/(languages\.yml|licenses\.csv)\z} => :backend,
%r{\A(Dangerfile|Gemfile|Gemfile.lock|Procfile|Rakefile)\z} => :backend, %r{\A(Dangerfile|Gemfile|Gemfile.lock|Procfile|Rakefile|\.gitlab-ci\.yml)\z} => :backend,
%r{\A[A-Z_]+_VERSION\z} => :backend, %r{\A[A-Z_]+_VERSION\z} => :backend,
%r{\A(ee/)?db/} => :database, %r{\A(ee/)?db/} => :database,
......
...@@ -244,12 +244,13 @@ describe Gitlab::Danger::Helper do ...@@ -244,12 +244,13 @@ describe Gitlab::Danger::Helper do
'vendor/languages.yml' | :backend 'vendor/languages.yml' | :backend
'vendor/licenses.csv' | :backend 'vendor/licenses.csv' | :backend
'Dangerfile' | :backend 'Dangerfile' | :backend
'Gemfile' | :backend 'Gemfile' | :backend
'Gemfile.lock' | :backend 'Gemfile.lock' | :backend
'Procfile' | :backend 'Procfile' | :backend
'Rakefile' | :backend 'Rakefile' | :backend
'FOO_VERSION' | :backend '.gitlab-ci.yml' | :backend
'FOO_VERSION' | :backend
'ee/FOO_VERSION' | :unknown 'ee/FOO_VERSION' | :unknown
......
...@@ -372,6 +372,7 @@ describe API::MergeRequests do ...@@ -372,6 +372,7 @@ describe API::MergeRequests do
expect(json_response['force_close_merge_request']).to be_falsy expect(json_response['force_close_merge_request']).to be_falsy
expect(json_response['changes_count']).to eq(merge_request.merge_request_diff.real_size) expect(json_response['changes_count']).to eq(merge_request.merge_request_diff.real_size)
expect(json_response['merge_error']).to eq(merge_request.merge_error) expect(json_response['merge_error']).to eq(merge_request.merge_error)
expect(json_response['user']['can_merge']).to be_truthy
expect(json_response).not_to include('rebase_in_progress') expect(json_response).not_to include('rebase_in_progress')
end end
...@@ -499,6 +500,15 @@ describe API::MergeRequests do ...@@ -499,6 +500,15 @@ describe API::MergeRequests do
expect(json_response['allow_maintainer_to_push']).to be_truthy expect(json_response['allow_maintainer_to_push']).to be_truthy
end end
end end
it 'indicates if a user cannot merge the MR' do
user2 = create(:user)
project.add_reporter(user2)
get api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user2)
expect(json_response['user']['can_merge']).to be_falsy
end
end end
describe 'GET /projects/:id/merge_requests/:merge_request_iid/participants' do describe 'GET /projects/:id/merge_requests/:merge_request_iid/participants' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment