Commit a0101ebf authored by James Lopez's avatar James Lopez

Update occurrences of MWBS to MWPS

 Rename column in the database
 Rename fields related to import/export feature
 Rename API endpoints
 Rename documentation links
 Rename the rest of occurrences in the code
 Replace the images that contain the words "build succeeds" and docs referencing to them
 Make sure pipeline is green and nothing is missing.

updated doc images

renamed only_allow_merge_if_build_succeeds in projects and fixed references

more updates

fix some spec failures

fix rubocop offences

fix v3 api spec

fix MR  specs

fixed issues with partials

fix MR spec

fix alignment

add missing v3 to v4 doc

wip - refactor v3 endpoints

fix specs

fix a few typos

fix project specs

copy entities fully to V3

fix  entity error

more fixes

fix failing specs

fixed missing entities in V3 API

remove comment

updated code based on feedback

typo

fix spec
parent c8f98196
...@@ -21,9 +21,9 @@ ...@@ -21,9 +21,9 @@
}); });
$(document) $(document)
.off('click', '.merge_when_build_succeeds') .off('click', '.merge_when_pipeline_succeeds')
.on('click', '.merge_when_build_succeeds', () => { .on('click', '.merge_when_pipeline_succeeds', () => {
$('#merge_when_build_succeeds').val('1'); $('#merge_when_pipeline_succeeds').val('1');
}); });
$(document) $(document)
......
...@@ -10,11 +10,11 @@ class Projects::MergeRequestsController < Projects::ApplicationController ...@@ -10,11 +10,11 @@ class Projects::MergeRequestsController < Projects::ApplicationController
before_action :module_enabled before_action :module_enabled
before_action :merge_request, only: [ before_action :merge_request, only: [
:edit, :update, :show, :diffs, :commits, :conflicts, :conflict_for_path, :pipelines, :merge, :merge_check, :edit, :update, :show, :diffs, :commits, :conflicts, :conflict_for_path, :pipelines, :merge, :merge_check,
:ci_status, :ci_environments_status, :toggle_subscription, :cancel_merge_when_build_succeeds, :remove_wip, :resolve_conflicts, :assign_related_issues :ci_status, :ci_environments_status, :toggle_subscription, :cancel_merge_when_pipeline_succeeds, :remove_wip, :resolve_conflicts, :assign_related_issues
] ]
before_action :validates_merge_request, only: [:show, :diffs, :commits, :pipelines] before_action :validates_merge_request, only: [:show, :diffs, :commits, :pipelines]
before_action :define_show_vars, only: [:show, :diffs, :commits, :conflicts, :conflict_for_path, :builds, :pipelines] before_action :define_show_vars, only: [:show, :diffs, :commits, :conflicts, :conflict_for_path, :builds, :pipelines]
before_action :define_widget_vars, only: [:merge, :cancel_merge_when_build_succeeds, :merge_check] before_action :define_widget_vars, only: [:merge, :cancel_merge_when_pipeline_succeeds, :merge_check]
before_action :define_commit_vars, only: [:diffs] before_action :define_commit_vars, only: [:diffs]
before_action :define_diff_comment_vars, only: [:diffs] before_action :define_diff_comment_vars, only: [:diffs]
before_action :ensure_ref_fetched, only: [:show, :diffs, :commits, :builds, :conflicts, :conflict_for_path, :pipelines] before_action :ensure_ref_fetched, only: [:show, :diffs, :commits, :builds, :conflicts, :conflict_for_path, :pipelines]
...@@ -326,8 +326,8 @@ class Projects::MergeRequestsController < Projects::ApplicationController ...@@ -326,8 +326,8 @@ class Projects::MergeRequestsController < Projects::ApplicationController
render partial: "projects/merge_requests/widget/show.html.haml", layout: false render partial: "projects/merge_requests/widget/show.html.haml", layout: false
end end
def cancel_merge_when_build_succeeds def cancel_merge_when_pipeline_succeeds
unless @merge_request.can_cancel_merge_when_build_succeeds?(current_user) unless @merge_request.can_cancel_merge_when_pipeline_succeeds?(current_user)
return access_denied! return access_denied!
end end
...@@ -339,9 +339,9 @@ class Projects::MergeRequestsController < Projects::ApplicationController ...@@ -339,9 +339,9 @@ class Projects::MergeRequestsController < Projects::ApplicationController
def merge def merge
return access_denied! unless @merge_request.can_be_merged_by?(current_user) return access_denied! unless @merge_request.can_be_merged_by?(current_user)
# Disable the CI check if merge_when_build_succeeds is enabled since we have # Disable the CI check if merge_when_pipeline_succeeds is enabled since we have
# to wait until CI completes to know # to wait until CI completes to know
unless @merge_request.mergeable?(skip_ci_check: merge_when_build_succeeds_active?) unless @merge_request.mergeable?(skip_ci_check: merge_when_pipeline_succeeds_active?)
@status = :failed @status = :failed
return return
end end
...@@ -353,7 +353,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController ...@@ -353,7 +353,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
@merge_request.update(merge_error: nil) @merge_request.update(merge_error: nil)
if params[:merge_when_build_succeeds].present? if params[:merge_when_pipeline_succeeds].present?
unless @merge_request.head_pipeline unless @merge_request.head_pipeline
@status = :failed @status = :failed
return return
...@@ -364,7 +364,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController ...@@ -364,7 +364,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
.new(@project, current_user, merge_params) .new(@project, current_user, merge_params)
.execute(@merge_request) .execute(@merge_request)
@status = :merge_when_build_succeeds @status = :merge_when_pipeline_succeeds
elsif @merge_request.head_pipeline.success? elsif @merge_request.head_pipeline.success?
# This can be triggered when a user clicks the auto merge button while # This can be triggered when a user clicks the auto merge button while
# the tests finish at about the same time # the tests finish at about the same time
...@@ -381,8 +381,8 @@ class Projects::MergeRequestsController < Projects::ApplicationController ...@@ -381,8 +381,8 @@ class Projects::MergeRequestsController < Projects::ApplicationController
def merge_widget_refresh def merge_widget_refresh
@status = @status =
if merge_request.merge_when_build_succeeds if merge_request.merge_when_pipeline_succeeds
:merge_when_build_succeeds :merge_when_pipeline_succeeds
else else
# Only MRs that can be merged end in this action # Only MRs that can be merged end in this action
# MR can be already picked up for merge / merged already or can be waiting for worker to be picked up # MR can be already picked up for merge / merged already or can be waiting for worker to be picked up
...@@ -672,8 +672,8 @@ class Projects::MergeRequestsController < Projects::ApplicationController ...@@ -672,8 +672,8 @@ class Projects::MergeRequestsController < Projects::ApplicationController
@merge_request.ensure_ref_fetched @merge_request.ensure_ref_fetched
end end
def merge_when_build_succeeds_active? def merge_when_pipeline_succeeds_active?
params[:merge_when_build_succeeds].present? && params[:merge_when_pipeline_succeeds].present? &&
@merge_request.head_pipeline && @merge_request.head_pipeline.active? @merge_request.head_pipeline && @merge_request.head_pipeline.active?
end end
......
...@@ -314,7 +314,7 @@ class ProjectsController < Projects::ApplicationController ...@@ -314,7 +314,7 @@ class ProjectsController < Projects::ApplicationController
:name, :name,
:namespace_id, :namespace_id,
:only_allow_merge_if_all_discussions_are_resolved, :only_allow_merge_if_all_discussions_are_resolved,
:only_allow_merge_if_build_succeeds, :only_allow_merge_if_pipeline_succeeds,
:path, :path,
:public_builds, :public_builds,
:request_access_enabled, :request_access_enabled,
......
...@@ -146,7 +146,7 @@ module MergeRequestsHelper ...@@ -146,7 +146,7 @@ module MergeRequestsHelper
def merge_params(merge_request) def merge_params(merge_request)
{ {
merge_when_build_succeeds: true, merge_when_pipeline_succeeds: true,
should_remove_source_branch: true, should_remove_source_branch: true,
sha: merge_request.diff_head_sha sha: merge_request.diff_head_sha
}.merge(merge_params_ee(merge_request)) }.merge(merge_params_ee(merge_request))
......
...@@ -97,7 +97,7 @@ class MergeRequest < ActiveRecord::Base ...@@ -97,7 +97,7 @@ class MergeRequest < ActiveRecord::Base
validates :source_branch, presence: true validates :source_branch, presence: true
validates :target_project, presence: true validates :target_project, presence: true
validates :target_branch, presence: true validates :target_branch, presence: true
validates :merge_user, presence: true, if: :merge_when_build_succeeds?, unless: :importing? validates :merge_user, presence: true, if: :merge_when_pipeline_succeeds?, unless: :importing?
validate :validate_branches, unless: [:allow_broken, :importing?, :closed_without_fork?] validate :validate_branches, unless: [:allow_broken, :importing?, :closed_without_fork?]
validate :validate_fork, unless: :closed_without_fork? validate :validate_fork, unless: :closed_without_fork?
...@@ -436,7 +436,7 @@ class MergeRequest < ActiveRecord::Base ...@@ -436,7 +436,7 @@ class MergeRequest < ActiveRecord::Base
true true
end end
def can_cancel_merge_when_build_succeeds?(current_user) def can_cancel_merge_when_pipeline_succeeds?(current_user)
can_be_merged_by?(current_user) || self.author == current_user can_be_merged_by?(current_user) || self.author == current_user
end end
...@@ -644,10 +644,10 @@ class MergeRequest < ActiveRecord::Base ...@@ -644,10 +644,10 @@ class MergeRequest < ActiveRecord::Base
message.join("\n\n") message.join("\n\n")
end end
def reset_merge_when_build_succeeds def reset_merge_when_pipeline_succeeds
return unless merge_when_build_succeeds? return unless merge_when_pipeline_succeeds?
self.merge_when_build_succeeds = false self.merge_when_pipeline_succeeds = false
self.merge_user = nil self.merge_user = nil
if merge_params if merge_params
merge_params.delete('should_remove_source_branch') merge_params.delete('should_remove_source_branch')
...@@ -706,7 +706,7 @@ class MergeRequest < ActiveRecord::Base ...@@ -706,7 +706,7 @@ class MergeRequest < ActiveRecord::Base
end end
def mergeable_ci_state? def mergeable_ci_state?
return true unless project.only_allow_merge_if_build_succeeds? return true unless project.only_allow_merge_if_pipeline_succeeds?
!head_pipeline || head_pipeline.success? || head_pipeline.skipped? !head_pipeline || head_pipeline.success? || head_pipeline.skipped?
end end
......
...@@ -6,7 +6,7 @@ class MergeRequestEntity < IssuableEntity ...@@ -6,7 +6,7 @@ class MergeRequestEntity < IssuableEntity
expose :merge_params expose :merge_params
expose :merge_status expose :merge_status
expose :merge_user_id expose :merge_user_id
expose :merge_when_build_succeeds expose :merge_when_pipeline_succeeds
expose :source_branch expose :source_branch
expose :source_project_id expose :source_project_id
expose :target_branch expose :target_branch
......
module MergeRequests module MergeRequests
class MergeWhenPipelineSucceedsService < MergeRequests::BaseService class MergeWhenPipelineSucceedsService < MergeRequests::BaseService
# Marks the passed `merge_request` to be merged when the build succeeds or # Marks the passed `merge_request` to be merged when the pipeline succeeds or
# updates the params for the automatic merge # updates the params for the automatic merge
def execute(merge_request) def execute(merge_request)
merge_request.merge_params.merge!(params) merge_request.merge_params.merge!(params)
# The service is also called when the merge params are updated. # The service is also called when the merge params are updated.
already_approved = merge_request.merge_when_build_succeeds? already_approved = merge_request.merge_when_pipeline_succeeds?
unless already_approved unless already_approved
merge_request.merge_when_build_succeeds = true merge_request.merge_when_pipeline_succeeds = true
merge_request.merge_user = @current_user merge_request.merge_user = @current_user
SystemNoteService.merge_when_build_succeeds(merge_request, @project, @current_user, merge_request.diff_head_commit) SystemNoteService.merge_when_pipeline_succeeds(merge_request, @project, @current_user, merge_request.diff_head_commit)
end end
merge_request.save merge_request.save
...@@ -23,7 +23,7 @@ module MergeRequests ...@@ -23,7 +23,7 @@ module MergeRequests
return unless pipeline.success? return unless pipeline.success?
pipeline_merge_requests(pipeline) do |merge_request| pipeline_merge_requests(pipeline) do |merge_request|
next unless merge_request.merge_when_build_succeeds? next unless merge_request.merge_when_pipeline_succeeds?
unless merge_request.mergeable? unless merge_request.mergeable?
todo_service.merge_request_became_unmergeable(merge_request) todo_service.merge_request_became_unmergeable(merge_request)
...@@ -36,9 +36,9 @@ module MergeRequests ...@@ -36,9 +36,9 @@ module MergeRequests
# Cancels the automatic merge # Cancels the automatic merge
def cancel(merge_request) def cancel(merge_request)
if merge_request.merge_when_build_succeeds? && merge_request.open? if merge_request.merge_when_pipeline_succeeds? && merge_request.open?
merge_request.reset_merge_when_build_succeeds merge_request.reset_merge_when_pipeline_succeeds
SystemNoteService.cancel_merge_when_build_succeeds(merge_request, @project, @current_user) SystemNoteService.cancel_merge_when_pipeline_succeeds(merge_request, @project, @current_user)
success success
else else
......
...@@ -11,7 +11,7 @@ module MergeRequests ...@@ -11,7 +11,7 @@ module MergeRequests
# empty diff during a manual merge # empty diff during a manual merge
close_merge_requests close_merge_requests
reload_merge_requests reload_merge_requests
reset_merge_when_build_succeeds reset_merge_when_pipeline_succeeds
mark_pending_todos_done mark_pending_todos_done
cache_merge_requests_closing_issues cache_merge_requests_closing_issues
...@@ -78,8 +78,8 @@ module MergeRequests ...@@ -78,8 +78,8 @@ module MergeRequests
end end
end end
def reset_merge_when_build_succeeds def reset_merge_when_pipeline_succeeds
merge_requests_for_source_branch.each(&:reset_merge_when_build_succeeds) merge_requests_for_source_branch.each(&:reset_merge_when_pipeline_succeeds)
end end
def mark_pending_todos_done def mark_pending_todos_done
......
...@@ -135,7 +135,7 @@ class NotificationService ...@@ -135,7 +135,7 @@ class NotificationService
merge_request.target_project, merge_request.target_project,
current_user, current_user,
:merged_merge_request_email, :merged_merge_request_email,
skip_current_user: !merge_request.merge_when_build_succeeds? skip_current_user: !merge_request.merge_when_pipeline_succeeds?
) )
end end
......
...@@ -59,7 +59,7 @@ module SlashCommands ...@@ -59,7 +59,7 @@ module SlashCommands
@updates[:state_event] = 'reopen' @updates[:state_event] = 'reopen'
end end
desc 'Merge (when build succeeds)' desc 'Merge (when the pipeline succeeds)'
condition do condition do
last_diff_sha = params && params[:merge_request_diff_head_sha] last_diff_sha = params && params[:merge_request_diff_head_sha]
issuable.is_a?(MergeRequest) && issuable.is_a?(MergeRequest) &&
......
...@@ -187,14 +187,14 @@ module SystemNoteService ...@@ -187,14 +187,14 @@ module SystemNoteService
end end
# Called when 'merge when pipeline succeeds' is executed # Called when 'merge when pipeline succeeds' is executed
def merge_when_build_succeeds(noteable, project, author, last_commit) def merge_when_pipeline_succeeds(noteable, project, author, last_commit)
body = "enabled an automatic merge when the pipeline for #{last_commit.to_reference(project)} succeeds" body = "enabled an automatic merge when the pipeline for #{last_commit.to_reference(project)} succeeds"
create_note(noteable: noteable, project: project, author: author, note: body) create_note(noteable: noteable, project: project, author: author, note: body)
end end
# Called when 'merge when pipeline succeeds' is canceled # Called when 'merge when pipeline succeeds' is canceled
def cancel_merge_when_build_succeeds(noteable, project, author) def cancel_merge_when_pipeline_succeeds(noteable, project, author)
body = 'canceled the automatic merge' body = 'canceled the automatic merge'
create_note(noteable: noteable, project: project, author: author, note: body) create_note(noteable: noteable, project: project, author: author, note: body)
......
...@@ -103,7 +103,7 @@ class TodoService ...@@ -103,7 +103,7 @@ class TodoService
# #
def merge_request_build_failed(merge_request) def merge_request_build_failed(merge_request)
create_build_failed_todo(merge_request, merge_request.author) create_build_failed_todo(merge_request, merge_request.author)
create_build_failed_todo(merge_request, merge_request.merge_user) if merge_request.merge_when_build_succeeds? create_build_failed_todo(merge_request, merge_request.merge_user) if merge_request.merge_when_pipeline_succeeds?
end end
# When a new commit is pushed to a merge request we should: # When a new commit is pushed to a merge request we should:
...@@ -121,7 +121,7 @@ class TodoService ...@@ -121,7 +121,7 @@ class TodoService
# #
def merge_request_build_retried(merge_request) def merge_request_build_retried(merge_request)
mark_pending_todos_as_done(merge_request, merge_request.author) mark_pending_todos_as_done(merge_request, merge_request.author)
mark_pending_todos_as_done(merge_request, merge_request.merge_user) if merge_request.merge_when_build_succeeds? mark_pending_todos_as_done(merge_request, merge_request.merge_user) if merge_request.merge_when_pipeline_succeeds?
end end
# When a merge request could not be automatically merged due to its unmergeable state we should: # When a merge request could not be automatically merged due to its unmergeable state we should:
...@@ -129,7 +129,7 @@ class TodoService ...@@ -129,7 +129,7 @@ class TodoService
# * create a todo for a merge_user # * create a todo for a merge_user
# #
def merge_request_became_unmergeable(merge_request) def merge_request_became_unmergeable(merge_request)
create_unmergeable_todo(merge_request, merge_request.merge_user) if merge_request.merge_when_build_succeeds? create_unmergeable_todo(merge_request, merge_request.merge_user) if merge_request.merge_when_pipeline_succeeds?
end end
# When create a note we should: # When create a note we should:
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
.form-group .form-group
.checkbox.builds-feature .checkbox.builds-feature
= form.label :only_allow_merge_if_build_succeeds do = form.label :only_allow_merge_if_pipeline_succeeds do
= form.check_box :only_allow_merge_if_build_succeeds = form.check_box :only_allow_merge_if_pipeline_succeeds
%strong Only allow merge requests to be merged if the pipeline succeeds %strong Only allow merge requests to be merged if the pipeline succeeds
%br %br
%span.descr %span.descr
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
- when :success - when :success
:plain :plain
merge_request_widget.mergeInProgress(#{params[:should_remove_source_branch] == '1'}); merge_request_widget.mergeInProgress(#{params[:should_remove_source_branch] == '1'});
- when :merge_when_build_succeeds - when :merge_when_pipeline_succeeds
:plain :plain
$('.mr-widget-body').html("#{escape_javascript(render('projects/merge_requests/widget/open/merge_when_build_succeeds'))}"); $('.mr-widget-body').html("#{escape_javascript(render('projects/merge_requests/widget/open/merge_when_pipeline_succeeds'))}");
- when :sha_mismatch - when :sha_mismatch
:plain :plain
$('.mr-widget-body').html("#{escape_javascript(render('projects/merge_requests/widget/open/sha_mismatch'))}"); $('.mr-widget-body').html("#{escape_javascript(render('projects/merge_requests/widget/open/sha_mismatch'))}");
......
...@@ -19,8 +19,8 @@ ...@@ -19,8 +19,8 @@
= render 'projects/merge_requests/widget/open/conflicts' = render 'projects/merge_requests/widget/open/conflicts'
- elsif @merge_request.work_in_progress? - elsif @merge_request.work_in_progress?
= render 'projects/merge_requests/widget/open/wip' = render 'projects/merge_requests/widget/open/wip'
- elsif @merge_request.merge_when_build_succeeds? - elsif @merge_request.merge_when_pipeline_succeeds?
= render 'projects/merge_requests/widget/open/merge_when_build_succeeds' = render 'projects/merge_requests/widget/open/merge_when_pipeline_succeeds'
- elsif !@merge_request.can_be_merged_by?(current_user) - elsif !@merge_request.can_be_merged_by?(current_user)
= render 'projects/merge_requests/widget/open/not_allowed' = render 'projects/merge_requests/widget/open/not_allowed'
- elsif !@merge_request.mergeable_ci_state? && (@pipeline.failed? || @pipeline.canceled?) - elsif !@merge_request.mergeable_ci_state? && (@pipeline.failed? || @pipeline.canceled?)
......
...@@ -11,16 +11,16 @@ ...@@ -11,16 +11,16 @@
.accept-action .accept-action
- if @pipeline && @pipeline.active? - if @pipeline && @pipeline.active?
%span.btn-group %span.btn-group
= button_tag class: "btn btn-create js-merge-button merge_when_build_succeeds" do = button_tag class: "btn btn-create js-merge-button merge_when_pipeline_succeeds" do
Merge When Pipeline Succeeds Merge When Pipeline Succeeds
- unless @project.only_allow_merge_if_build_succeeds? - unless @project.only_allow_merge_if_pipeline_succeeds?
= button_tag class: "btn btn-success dropdown-toggle", 'data-toggle' => 'dropdown' do = button_tag class: "btn btn-success dropdown-toggle", 'data-toggle' => 'dropdown' do
= icon('caret-down') = icon('caret-down')
%span.sr-only %span.sr-only
Select Merge Moment Select Merge Moment
%ul.js-merge-dropdown.dropdown-menu.dropdown-menu-right{ role: 'menu' } %ul.js-merge-dropdown.dropdown-menu.dropdown-menu-right{ role: 'menu' }
%li %li
= link_to "#", class: "merge_when_build_succeeds" do = link_to "#", class: "merge_when_pipeline_succeeds" do
= icon('check fw') = icon('check fw')
Merge When Pipeline Succeeds Merge When Pipeline Succeeds
%li %li
...@@ -49,4 +49,4 @@ ...@@ -49,4 +49,4 @@
text: @merge_request.merge_commit_message, text: @merge_request.merge_commit_message,
rows: 14, hint: true rows: 14, hint: true
= hidden_field_tag :merge_when_build_succeeds, "", autocomplete: "off" = hidden_field_tag :merge_when_pipeline_succeeds, "", autocomplete: "off"
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
The source branch will not be removed. The source branch will not be removed.
- remove_source_branch_button = !@merge_request.remove_source_branch? && @merge_request.can_remove_source_branch?(current_user) && @merge_request.merge_user == current_user - remove_source_branch_button = !@merge_request.remove_source_branch? && @merge_request.can_remove_source_branch?(current_user) && @merge_request.merge_user == current_user
- user_can_cancel_automatic_merge = @merge_request.can_cancel_merge_when_build_succeeds?(current_user) - user_can_cancel_automatic_merge = @merge_request.can_cancel_merge_when_pipeline_succeeds?(current_user)
- if remove_source_branch_button || user_can_cancel_automatic_merge - if remove_source_branch_button || user_can_cancel_automatic_merge
.clearfix.prepend-top-10 .clearfix.prepend-top-10
- if remove_source_branch_button - if remove_source_branch_button
...@@ -24,5 +24,5 @@ ...@@ -24,5 +24,5 @@
Remove Source Branch When Merged Remove Source Branch When Merged
- if user_can_cancel_automatic_merge - if user_can_cancel_automatic_merge
= link_to cancel_merge_when_build_succeeds_namespace_project_merge_request_path(@merge_request.target_project.namespace, @merge_request.target_project, @merge_request), remote: true, method: :post, class: "btn btn-grouped btn-sm" do = link_to cancel_merge_when_pipeline_succeeds_namespace_project_merge_request_path(@merge_request.target_project.namespace, @merge_request.target_project, @merge_request), remote: true, method: :post, class: "btn btn-grouped btn-sm" do
Cancel Automatic Merge Cancel Automatic Merge
...@@ -100,7 +100,7 @@ constraints(ProjectUrlConstrainer.new) do ...@@ -100,7 +100,7 @@ constraints(ProjectUrlConstrainer.new) do
get :merge_check get :merge_check
post :merge post :merge
get :merge_widget_refresh get :merge_widget_refresh
post :cancel_merge_when_build_succeeds post :cancel_merge_when_pipeline_succeeds
get :ci_status get :ci_status
get :ci_environments_status get :ci_environments_status
post :toggle_subscription post :toggle_subscription
......
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
class RenameMergeWhenBuildSucceeds < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
# Set this constant to true if this migration requires downtime.
DOWNTIME = true
# When a migration requires downtime you **must** uncomment the following
# constant and define a short and easy to understand explanation as to why the
# migration requires downtime.
DOWNTIME_REASON = 'Renaming the column merge_when_build_succeeds'
# When using the methods "add_concurrent_index" or "add_column_with_default"
# you must disable the use of transactions as these methods can not run in an
# existing transaction. When using "add_concurrent_index" make sure that this
# method is the _only_ method called in the migration, any other changes
# should go in a separate migration. This ensures that upon failure _only_ the
# index creation fails and can be retried or reverted easily.
#
# To disable transactions uncomment the following line and remove these
# comments:
# disable_ddl_transaction!
def change
rename_column :merge_requests, :merge_when_build_succeeds, :merge_when_pipeline_succeeds
end
end
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
class RenameOnlyAllowMergeIfBuildSucceeds < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
# Set this constant to true if this migration requires downtime.
DOWNTIME = true
# When a migration requires downtime you **must** uncomment the following
# constant and define a short and easy to understand explanation as to why the
# migration requires downtime.
DOWNTIME_REASON = 'Renaming the column only_allow_merge_if_build_succeeds'
# When using the methods "add_concurrent_index" or "add_column_with_default"
# you must disable the use of transactions as these methods can not run in an
# existing transaction. When using "add_concurrent_index" make sure that this
# method is the _only_ method called in the migration, any other changes
# should go in a separate migration. This ensures that upon failure _only_ the
# index creation fails and can be retried or reverted easily.
#
# To disable transactions uncomment the following line and remove these
# comments:
# disable_ddl_transaction!
def change
rename_column :projects, :only_allow_merge_if_build_succeeds, :only_allow_merge_if_pipeline_succeeds
end
end
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20170216141440) do ActiveRecord::Schema.define(version: 20170217151947) do
# These are extensions that must be enabled in order to support this database # These are extensions that must be enabled in order to support this database
enable_extension "plpgsql" enable_extension "plpgsql"
...@@ -689,7 +689,7 @@ ActiveRecord::Schema.define(version: 20170216141440) do ...@@ -689,7 +689,7 @@ ActiveRecord::Schema.define(version: 20170216141440) do
t.integer "updated_by_id" t.integer "updated_by_id"
t.text "merge_error" t.text "merge_error"
t.text "merge_params" t.text "merge_params"
t.boolean "merge_when_build_succeeds", default: false, null: false t.boolean "merge_when_pipeline_succeeds", default: false, null: false
t.integer "merge_user_id" t.integer "merge_user_id"
t.string "merge_commit_sha" t.string "merge_commit_sha"
t.datetime "deleted_at" t.datetime "deleted_at"
...@@ -972,7 +972,7 @@ ActiveRecord::Schema.define(version: 20170216141440) do ...@@ -972,7 +972,7 @@ ActiveRecord::Schema.define(version: 20170216141440) do
t.boolean "last_repository_check_failed" t.boolean "last_repository_check_failed"
t.datetime "last_repository_check_at" t.datetime "last_repository_check_at"
t.boolean "container_registry_enabled" t.boolean "container_registry_enabled"
t.boolean "only_allow_merge_if_build_succeeds", default: false, null: false t.boolean "only_allow_merge_if_pipeline_succeeds", default: false, null: false
t.boolean "has_external_issue_tracker" t.boolean "has_external_issue_tracker"
t.string "repository_storage", default: "default", null: false t.string "repository_storage", default: "default", null: false
t.boolean "request_access_enabled", default: false, null: false t.boolean "request_access_enabled", default: false, null: false
......
...@@ -65,7 +65,7 @@ Parameters: ...@@ -65,7 +65,7 @@ Parameters:
"updated_at": "2015-02-02T19:49:26.013Z", "updated_at": "2015-02-02T19:49:26.013Z",
"due_date": null "due_date": null
}, },
"merge_when_build_succeeds": true, "merge_when_pipeline_succeeds": true,
"merge_status": "can_be_merged", "merge_status": "can_be_merged",
"subscribed" : false, "subscribed" : false,
"sha": "8888888888888888888888888888888888888888", "sha": "8888888888888888888888888888888888888888",
...@@ -134,7 +134,7 @@ Parameters: ...@@ -134,7 +134,7 @@ Parameters:
"updated_at": "2015-02-02T19:49:26.013Z", "updated_at": "2015-02-02T19:49:26.013Z",
"due_date": null "due_date": null
}, },
"merge_when_build_succeeds": true, "merge_when_pipeline_succeeds": true,
"merge_status": "can_be_merged", "merge_status": "can_be_merged",
"subscribed" : true, "subscribed" : true,
"sha": "8888888888888888888888888888888888888888", "sha": "8888888888888888888888888888888888888888",
...@@ -239,7 +239,7 @@ Parameters: ...@@ -239,7 +239,7 @@ Parameters:
"updated_at": "2015-02-02T19:49:26.013Z", "updated_at": "2015-02-02T19:49:26.013Z",
"due_date": null "due_date": null
}, },
"merge_when_build_succeeds": true, "merge_when_pipeline_succeeds": true,
"merge_status": "can_be_merged", "merge_status": "can_be_merged",
"subscribed" : true, "subscribed" : true,
"sha": "8888888888888888888888888888888888888888", "sha": "8888888888888888888888888888888888888888",
...@@ -326,7 +326,7 @@ POST /projects/:id/merge_requests ...@@ -326,7 +326,7 @@ POST /projects/:id/merge_requests
"updated_at": "2015-02-02T19:49:26.013Z", "updated_at": "2015-02-02T19:49:26.013Z",
"due_date": null "due_date": null
}, },
"merge_when_build_succeeds": true, "merge_when_pipeline_succeeds": true,
"merge_status": "can_be_merged", "merge_status": "can_be_merged",
"subscribed" : true, "subscribed" : true,
"sha": "8888888888888888888888888888888888888888", "sha": "8888888888888888888888888888888888888888",
...@@ -403,7 +403,7 @@ Must include at least one non-required attribute from above. ...@@ -403,7 +403,7 @@ Must include at least one non-required attribute from above.
"updated_at": "2015-02-02T19:49:26.013Z", "updated_at": "2015-02-02T19:49:26.013Z",
"due_date": null "due_date": null
}, },
"merge_when_build_succeeds": true, "merge_when_pipeline_succeeds": true,
"merge_status": "can_be_merged", "merge_status": "can_be_merged",
"subscribed" : true, "subscribed" : true,
"sha": "8888888888888888888888888888888888888888", "sha": "8888888888888888888888888888888888888888",
...@@ -455,7 +455,7 @@ Parameters: ...@@ -455,7 +455,7 @@ Parameters:
- `merge_request_id` (required) - ID of MR - `merge_request_id` (required) - ID of MR
- `merge_commit_message` (optional) - Custom merge commit message - `merge_commit_message` (optional) - Custom merge commit message
- `should_remove_source_branch` (optional) - if `true` removes the source branch - `should_remove_source_branch` (optional) - if `true` removes the source branch
- `merge_when_build_succeeds` (optional) - if `true` the MR is merged when the build succeeds - `merge_when_pipeline_succeeds` (optional) - if `true` the MR is merged when the pipeline succeeds
- `sha` (optional) - if present, then this SHA must match the HEAD of the source branch, otherwise the merge will fail - `sha` (optional) - if present, then this SHA must match the HEAD of the source branch, otherwise the merge will fail
```json ```json
...@@ -501,7 +501,7 @@ Parameters: ...@@ -501,7 +501,7 @@ Parameters:
"updated_at": "2015-02-02T19:49:26.013Z", "updated_at": "2015-02-02T19:49:26.013Z",
"due_date": null "due_date": null
}, },
"merge_when_build_succeeds": true, "merge_when_pipeline_succeeds": true,
"merge_status": "can_be_merged", "merge_status": "can_be_merged",
"subscribed" : true, "subscribed" : true,
"sha": "8888888888888888888888888888888888888888", "sha": "8888888888888888888888888888888888888888",
...@@ -519,9 +519,9 @@ If you don't have permissions to accept this merge request - you'll get a `401` ...@@ -519,9 +519,9 @@ If you don't have permissions to accept this merge request - you'll get a `401`
If the merge request is already merged or closed - you get `405` and error message 'Method Not Allowed' If the merge request is already merged or closed - you get `405` and error message 'Method Not Allowed'
In case the merge request is not set to be merged when the build succeeds, you'll also get a `406` error. In case the merge request is not set to be merged when the pipeline succeeds, you'll also get a `406` error.
``` ```
PUT /projects/:id/merge_requests/:merge_request_id/cancel_merge_when_build_succeeds PUT /projects/:id/merge_requests/:merge_request_id/cancel_merge_when_pipeline_succeeds
``` ```
Parameters: Parameters:
...@@ -571,7 +571,7 @@ Parameters: ...@@ -571,7 +571,7 @@ Parameters:
"updated_at": "2015-02-02T19:49:26.013Z", "updated_at": "2015-02-02T19:49:26.013Z",
"due_date": null "due_date": null
}, },
"merge_when_build_succeeds": true, "merge_when_pipeline_succeeds": true,
"merge_status": "can_be_merged", "merge_status": "can_be_merged",
"subscribed" : true, "subscribed" : true,
"sha": "8888888888888888888888888888888888888888", "sha": "8888888888888888888888888888888888888888",
...@@ -726,7 +726,7 @@ Example response: ...@@ -726,7 +726,7 @@ Example response:
"updated_at": "2016-04-05T21:41:40.905Z", "updated_at": "2016-04-05T21:41:40.905Z",
"due_date": null "due_date": null
}, },
"merge_when_build_succeeds": false, "merge_when_pipeline_succeeds": false,
"merge_status": "cannot_be_merged", "merge_status": "cannot_be_merged",
"subscribed": true, "subscribed": true,
"sha": "8888888888888888888888888888888888888888", "sha": "8888888888888888888888888888888888888888",
...@@ -800,7 +800,7 @@ Example response: ...@@ -800,7 +800,7 @@ Example response:
"updated_at": "2016-04-05T21:41:40.905Z", "updated_at": "2016-04-05T21:41:40.905Z",
"due_date": null "due_date": null
}, },
"merge_when_build_succeeds": false, "merge_when_pipeline_succeeds": false,
"merge_status": "cannot_be_merged", "merge_status": "cannot_be_merged",
"subscribed": false, "subscribed": false,
"sha": "8888888888888888888888888888888888888888", "sha": "8888888888888888888888888888888888888888",
...@@ -893,7 +893,7 @@ Example response: ...@@ -893,7 +893,7 @@ Example response:
"updated_at": "2016-06-17T07:47:33.840Z", "updated_at": "2016-06-17T07:47:33.840Z",
"due_date": null "due_date": null
}, },
"merge_when_build_succeeds": false, "merge_when_pipeline_succeeds": false,
"merge_status": "unchecked", "merge_status": "unchecked",
"subscribed": true, "subscribed": true,
"sha": "8888888888888888888888888888888888888888", "sha": "8888888888888888888888888888888888888888",
......
...@@ -88,7 +88,7 @@ Parameters: ...@@ -88,7 +88,7 @@ Parameters:
"runners_token": "b8547b1dc37721d05889db52fa2f02", "runners_token": "b8547b1dc37721d05889db52fa2f02",
"public_builds": true, "public_builds": true,
"shared_with_groups": [], "shared_with_groups": [],
"only_allow_merge_if_build_succeeds": false, "only_allow_merge_if_pipeline_succeeds": false,
"only_allow_merge_if_all_discussions_are_resolved": false, "only_allow_merge_if_all_discussions_are_resolved": false,
"request_access_enabled": false "request_access_enabled": false
}, },
...@@ -149,7 +149,7 @@ Parameters: ...@@ -149,7 +149,7 @@ Parameters:
"runners_token": "b8547b1dc37721d05889db52fa2f02", "runners_token": "b8547b1dc37721d05889db52fa2f02",
"public_builds": true, "public_builds": true,
"shared_with_groups": [], "shared_with_groups": [],
"only_allow_merge_if_build_succeeds": false, "only_allow_merge_if_pipeline_succeeds": false,
"only_allow_merge_if_all_discussions_are_resolved": false, "only_allow_merge_if_all_discussions_are_resolved": false,
"request_access_enabled": false "request_access_enabled": false
} }
...@@ -241,7 +241,7 @@ Parameters: ...@@ -241,7 +241,7 @@ Parameters:
"group_access_level": 10 "group_access_level": 10
} }
], ],
"only_allow_merge_if_build_succeeds": false, "only_allow_merge_if_pipeline_succeeds": false,
"only_allow_merge_if_all_discussions_are_resolved": false, "only_allow_merge_if_all_discussions_are_resolved": false,
"request_access_enabled": false "request_access_enabled": false
} }
...@@ -449,7 +449,7 @@ Parameters: ...@@ -449,7 +449,7 @@ Parameters:
| `visibility_level` | integer | no | See [project visibility level](#project-visibility-level) | | `visibility_level` | integer | no | See [project visibility level](#project-visibility-level) |
| `import_url` | string | no | URL to import repository from | | `import_url` | string | no | URL to import repository from |
| `public_builds` | boolean | no | If `true`, builds can be viewed by non-project-members | | `public_builds` | boolean | no | If `true`, builds can be viewed by non-project-members |
| `only_allow_merge_if_build_succeeds` | boolean | no | Set whether merge requests can only be merged with successful builds | | `only_allow_merge_if_pipeline_succeeds` | boolean | no | Set whether merge requests can only be merged with successful builds |
| `only_allow_merge_if_all_discussions_are_resolved` | boolean | no | Set whether merge requests can only be merged when all the discussions are resolved | | `only_allow_merge_if_all_discussions_are_resolved` | boolean | no | Set whether merge requests can only be merged when all the discussions are resolved |
| `lfs_enabled` | boolean | no | Enable LFS | | `lfs_enabled` | boolean | no | Enable LFS |
| `request_access_enabled` | boolean | no | Allow users to request member access | | `request_access_enabled` | boolean | no | Allow users to request member access |
...@@ -482,7 +482,7 @@ Parameters: ...@@ -482,7 +482,7 @@ Parameters:
| `visibility_level` | integer | no | See [project visibility level](#project-visibility-level) | | `visibility_level` | integer | no | See [project visibility level](#project-visibility-level) |
| `import_url` | string | no | URL to import repository from | | `import_url` | string | no | URL to import repository from |
| `public_builds` | boolean | no | If `true`, builds can be viewed by non-project-members | | `public_builds` | boolean | no | If `true`, builds can be viewed by non-project-members |
| `only_allow_merge_if_build_succeeds` | boolean | no | Set whether merge requests can only be merged with successful builds | | `only_allow_merge_if_pipeline_succeeds` | boolean | no | Set whether merge requests can only be merged with successful builds |
| `only_allow_merge_if_all_discussions_are_resolved` | boolean | no | Set whether merge requests can only be merged when all the discussions are resolved | | `only_allow_merge_if_all_discussions_are_resolved` | boolean | no | Set whether merge requests can only be merged when all the discussions are resolved |
| `lfs_enabled` | boolean | no | Enable LFS | | `lfs_enabled` | boolean | no | Enable LFS |
| `request_access_enabled` | boolean | no | Allow users to request member access | | `request_access_enabled` | boolean | no | Allow users to request member access |
...@@ -514,7 +514,7 @@ Parameters: ...@@ -514,7 +514,7 @@ Parameters:
| `visibility_level` | integer | no | See [project visibility level](#project-visibility-level) | | `visibility_level` | integer | no | See [project visibility level](#project-visibility-level) |
| `import_url` | string | no | URL to import repository from | | `import_url` | string | no | URL to import repository from |
| `public_builds` | boolean | no | If `true`, builds can be viewed by non-project-members | | `public_builds` | boolean | no | If `true`, builds can be viewed by non-project-members |
| `only_allow_merge_if_build_succeeds` | boolean | no | Set whether merge requests can only be merged with successful builds | | `only_allow_merge_if_pipeline_succeeds` | boolean | no | Set whether merge requests can only be merged with successful builds |
| `only_allow_merge_if_all_discussions_are_resolved` | boolean | no | Set whether merge requests can only be merged when all the discussions are resolved | | `only_allow_merge_if_all_discussions_are_resolved` | boolean | no | Set whether merge requests can only be merged when all the discussions are resolved |
| `lfs_enabled` | boolean | no | Enable LFS | | `lfs_enabled` | boolean | no | Enable LFS |
| `request_access_enabled` | boolean | no | Allow users to request member access | | `request_access_enabled` | boolean | no | Allow users to request member access |
...@@ -596,7 +596,7 @@ Example response: ...@@ -596,7 +596,7 @@ Example response:
"star_count": 1, "star_count": 1,
"public_builds": true, "public_builds": true,
"shared_with_groups": [], "shared_with_groups": [],
"only_allow_merge_if_build_succeeds": false, "only_allow_merge_if_pipeline_succeeds": false,
"only_allow_merge_if_all_discussions_are_resolved": false, "only_allow_merge_if_all_discussions_are_resolved": false,
"request_access_enabled": false "request_access_enabled": false
} }
...@@ -662,7 +662,7 @@ Example response: ...@@ -662,7 +662,7 @@ Example response:
"star_count": 0, "star_count": 0,
"public_builds": true, "public_builds": true,
"shared_with_groups": [], "shared_with_groups": [],
"only_allow_merge_if_build_succeeds": false, "only_allow_merge_if_pipeline_succeeds": false,
"only_allow_merge_if_all_discussions_are_resolved": false, "only_allow_merge_if_all_discussions_are_resolved": false,
"request_access_enabled": false "request_access_enabled": false
} }
...@@ -745,7 +745,7 @@ Example response: ...@@ -745,7 +745,7 @@ Example response:
"runners_token": "b8bc4a7a29eb76ea83cf79e4908c2b", "runners_token": "b8bc4a7a29eb76ea83cf79e4908c2b",
"public_builds": true, "public_builds": true,
"shared_with_groups": [], "shared_with_groups": [],
"only_allow_merge_if_build_succeeds": false, "only_allow_merge_if_pipeline_succeeds": false,
"only_allow_merge_if_all_discussions_are_resolved": false, "only_allow_merge_if_all_discussions_are_resolved": false,
"request_access_enabled": false "request_access_enabled": false
} }
...@@ -828,7 +828,7 @@ Example response: ...@@ -828,7 +828,7 @@ Example response:
"runners_token": "b8bc4a7a29eb76ea83cf79e4908c2b", "runners_token": "b8bc4a7a29eb76ea83cf79e4908c2b",
"public_builds": true, "public_builds": true,
"shared_with_groups": [], "shared_with_groups": [],
"only_allow_merge_if_build_succeeds": false, "only_allow_merge_if_pipeline_succeeds": false,
"only_allow_merge_if_all_discussions_are_resolved": false, "only_allow_merge_if_all_discussions_are_resolved": false,
"request_access_enabled": false "request_access_enabled": false
} }
......
...@@ -92,7 +92,7 @@ Example Response: ...@@ -92,7 +92,7 @@ Example Response:
"updated_at": "2016-06-17T07:47:34.163Z", "updated_at": "2016-06-17T07:47:34.163Z",
"due_date": null "due_date": null
}, },
"merge_when_build_succeeds": false, "merge_when_pipeline_succeeds": false,
"merge_status": "cannot_be_merged", "merge_status": "cannot_be_merged",
"subscribed": true, "subscribed": true,
"user_notes_count": 7 "user_notes_count": 7
...@@ -165,7 +165,7 @@ Example Response: ...@@ -165,7 +165,7 @@ Example Response:
"updated_at": "2016-06-17T07:47:34.163Z", "updated_at": "2016-06-17T07:47:34.163Z",
"due_date": null "due_date": null
}, },
"merge_when_build_succeeds": false, "merge_when_pipeline_succeeds": false,
"merge_status": "cannot_be_merged", "merge_status": "cannot_be_merged",
"subscribed": true, "subscribed": true,
"user_notes_count": 7 "user_notes_count": 7
...@@ -263,7 +263,7 @@ Example Response: ...@@ -263,7 +263,7 @@ Example Response:
"updated_at": "2016-06-17T07:47:34.163Z", "updated_at": "2016-06-17T07:47:34.163Z",
"due_date": null "due_date": null
}, },
"merge_when_build_succeeds": false, "merge_when_pipeline_succeeds": false,
"merge_status": "cannot_be_merged", "merge_status": "cannot_be_merged",
"subscribed": true, "subscribed": true,
"user_notes_count": 7 "user_notes_count": 7
......
...@@ -38,6 +38,12 @@ changes are in V4: ...@@ -38,6 +38,12 @@ changes are in V4:
- POST `:id/repository/branches` - POST `:id/repository/branches`
- POST `:id/repository/commits` - POST `:id/repository/commits`
- POST/PUT/DELETE `:id/repository/files` - POST/PUT/DELETE `:id/repository/files`
- Renamed `merge when build succeeds` to merge `when pipeline succeeds parameters` on the following endpoints: [!9335](https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/)
- PUT `projects/:id/merge_requests/:merge_request_id/merge`
- POST `projects/:id/merge_requests/:merge_request_id/cancel_merge_when_pipeline_succeeds`
- POST `projects`
- POST `projects/user/:user_id`
- PUT `projects/:id`
- Renamed `branch_name` to `branch` on DELETE `id/repository/branches/:branch` response [!8936](https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/8936) - Renamed `branch_name` to `branch` on DELETE `id/repository/branches/:branch` response [!8936](https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/8936)
- Remove `public` param from create and edit actions of projects [!8736](https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/8736) - Remove `public` param from create and edit actions of projects [!8736](https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/8736)
- Notes do not return deprecated field `upvote` and `downvote` [!9384](https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/9384) - Notes do not return deprecated field `upvote` and `downvote` [!9384](https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/9384)
......
...@@ -5,7 +5,7 @@ more CI jobs running, you can set it to be merged automatically when the ...@@ -5,7 +5,7 @@ more CI jobs running, you can set it to be merged automatically when the
jobs pipeline succeeds. This way, you don't have to wait for the jobs to jobs pipeline succeeds. This way, you don't have to wait for the jobs to
finish and remember to merge the request manually. finish and remember to merge the request manually.
![Enable](img/merge_when_build_succeeds_enable.png) ![Enable](img/merge_when_pipeline_succeeds_enable.png)
When you hit the "Merge When Pipeline Succeeds" button, the status of the merge When you hit the "Merge When Pipeline Succeeds" button, the status of the merge
request will be updated to represent the impending merge. If you cannot wait request will be updated to represent the impending merge. If you cannot wait
...@@ -16,7 +16,7 @@ Both team developers and the author of the merge request have the option to ...@@ -16,7 +16,7 @@ Both team developers and the author of the merge request have the option to
cancel the automatic merge if they find a reason why it shouldn't be merged cancel the automatic merge if they find a reason why it shouldn't be merged
after all. after all.
![Status](img/merge_when_build_succeeds_status.png) ![Status](img/merge_when_pipeline_succeeds_status.png)
When the pipeline succeeds, the merge request will automatically be merged. When the pipeline succeeds, the merge request will automatically be merged.
When the pipeline fails, the author gets a chance to retry any failed jobs, When the pipeline fails, the author gets a chance to retry any failed jobs,
...@@ -32,15 +32,16 @@ changes to be reviewed. ...@@ -32,15 +32,16 @@ changes to be reviewed.
> **Note:** > **Note:**
You need to have jobs configured to enable this feature. You need to have jobs configured to enable this feature.
You can prevent merge requests from being merged if their pipeline did not succeed. You can prevent merge requests from being merged if their pipeline did not succeed
or if there are discussions to be resolved.
Navigate to your project's settings page, select the Navigate to your project's settings page, select the
**Only allow merge requests to be merged if the pipeline succeeds** check box and **Only allow merge requests to be merged if the pipeline succeeds** check box and
hit **Save** for the changes to take effect. hit **Save** for the changes to take effect.
![Only allow merge if pipeline succeeds settings](img/merge_when_build_succeeds_only_if_succeeds_settings.png) ![Only allow merge if pipeline succeeds settings](img/merge_when_pipeline_succeeds_only_if_succeeds_settings.png)
From now on, every time the pipeline fails you will not be able to merge the From now on, every time the pipeline fails you will not be able to merge the
merge request from the UI, until you make all relevant jobs pass. merge request from the UI, until you make all relevant jobs pass.
![Only allow merge if pipeline succeeds message](img/merge_when_build_succeeds_only_if_succeeds_msg.png) ![Only allow merge if pipeline succeeds message](img/merge_when_pipeline_succeeds_only_if_succeeds_msg.png)
...@@ -98,7 +98,7 @@ module API ...@@ -98,7 +98,7 @@ module API
expose :shared_with_groups do |project, options| expose :shared_with_groups do |project, options|
SharedGroup.represent(project.project_group_links.all, options) SharedGroup.represent(project.project_group_links.all, options)
end end
expose :only_allow_merge_if_build_succeeds expose :only_allow_merge_if_pipeline_succeeds
expose :request_access_enabled expose :request_access_enabled
expose :only_allow_merge_if_all_discussions_are_resolved expose :only_allow_merge_if_all_discussions_are_resolved
...@@ -288,7 +288,7 @@ module API ...@@ -288,7 +288,7 @@ module API
expose :label_names, as: :labels expose :label_names, as: :labels
expose :work_in_progress?, as: :work_in_progress expose :work_in_progress?, as: :work_in_progress
expose :milestone, using: Entities::Milestone expose :milestone, using: Entities::Milestone
expose :merge_when_build_succeeds expose :merge_when_pipeline_succeeds
expose :merge_status expose :merge_status
expose :diff_head_sha, as: :sha expose :diff_head_sha, as: :sha
expose :merge_commit_sha expose :merge_commit_sha
......
...@@ -168,8 +168,8 @@ module API ...@@ -168,8 +168,8 @@ module API
optional :merge_commit_message, type: String, desc: 'Custom merge commit message' optional :merge_commit_message, type: String, desc: 'Custom merge commit message'
optional :should_remove_source_branch, type: Boolean, optional :should_remove_source_branch, type: Boolean,
desc: 'When true, the source branch will be deleted if possible' desc: 'When true, the source branch will be deleted if possible'
optional :merge_when_build_succeeds, type: Boolean, optional :merge_when_pipeline_succeeds, type: Boolean,
desc: 'When true, this merge request will be merged when the pipeline succeeds' desc: 'When true, this merge request will be merged when the pipeline succeeds'
optional :sha, type: String, desc: 'When present, must have the HEAD SHA of the source branch' optional :sha, type: String, desc: 'When present, must have the HEAD SHA of the source branch'
end end
put ':id/merge_requests/:merge_request_id/merge' do put ':id/merge_requests/:merge_request_id/merge' do
...@@ -192,7 +192,7 @@ module API ...@@ -192,7 +192,7 @@ module API
should_remove_source_branch: params[:should_remove_source_branch] should_remove_source_branch: params[:should_remove_source_branch]
} }
if params[:merge_when_build_succeeds] && merge_request.head_pipeline && merge_request.head_pipeline.active? if params[:merge_when_pipeline_succeeds] && merge_request.head_pipeline && merge_request.head_pipeline.active?
::MergeRequests::MergeWhenPipelineSucceedsService ::MergeRequests::MergeWhenPipelineSucceedsService
.new(merge_request.target_project, current_user, merge_params) .new(merge_request.target_project, current_user, merge_params)
.execute(merge_request) .execute(merge_request)
...@@ -208,10 +208,10 @@ module API ...@@ -208,10 +208,10 @@ module API
desc 'Cancel merge if "Merge When Pipeline Succeeds" is enabled' do desc 'Cancel merge if "Merge When Pipeline Succeeds" is enabled' do
success Entities::MergeRequest success Entities::MergeRequest
end end
post ':id/merge_requests/:merge_request_id/cancel_merge_when_build_succeeds' do post ':id/merge_requests/:merge_request_id/cancel_merge_when_pipeline_succeeds' do
merge_request = find_project_merge_request(params[:merge_request_id]) merge_request = find_project_merge_request(params[:merge_request_id])
unauthorized! unless merge_request.can_cancel_merge_when_build_succeeds?(current_user) unauthorized! unless merge_request.can_cancel_merge_when_pipeline_succeeds?(current_user)
::MergeRequest::MergeWhenPipelineSucceedsService ::MergeRequest::MergeWhenPipelineSucceedsService
.new(merge_request.target_project, current_user) .new(merge_request.target_project, current_user)
......
...@@ -23,7 +23,7 @@ module API ...@@ -23,7 +23,7 @@ module API
], desc: 'Create a public project. The same as visibility_level = 20.' ], desc: 'Create a public project. The same as visibility_level = 20.'
optional :public_builds, type: Boolean, desc: 'Perform public builds' optional :public_builds, type: Boolean, desc: 'Perform public builds'
optional :request_access_enabled, type: Boolean, desc: 'Allow users to request member access' optional :request_access_enabled, type: Boolean, desc: 'Allow users to request member access'
optional :only_allow_merge_if_build_succeeds, type: Boolean, desc: 'Only allow to merge if builds succeed' optional :only_allow_merge_if_pipeline_succeeds, type: Boolean, desc: 'Only allow to merge if builds succeed'
optional :only_allow_merge_if_all_discussions_are_resolved, type: Boolean, desc: 'Only allow to merge if all discussions are resolved' optional :only_allow_merge_if_all_discussions_are_resolved, type: Boolean, desc: 'Only allow to merge if all discussions are resolved'
end end
end end
...@@ -209,7 +209,7 @@ module API ...@@ -209,7 +209,7 @@ module API
:wiki_enabled, :builds_enabled, :snippets_enabled, :wiki_enabled, :builds_enabled, :snippets_enabled,
:shared_runners_enabled, :container_registry_enabled, :shared_runners_enabled, :container_registry_enabled,
:lfs_enabled, :visibility_level, :public_builds, :lfs_enabled, :visibility_level, :public_builds,
:request_access_enabled, :only_allow_merge_if_build_succeeds, :request_access_enabled, :only_allow_merge_if_pipeline_succeeds,
:only_allow_merge_if_all_discussions_are_resolved, :path, :only_allow_merge_if_all_discussions_are_resolved, :path,
:default_branch :default_branch
end end
......
...@@ -45,6 +45,86 @@ module API ...@@ -45,6 +45,86 @@ module API
expose :created_at, :updated_at expose :created_at, :updated_at
expose :awardable_id, :awardable_type expose :awardable_id, :awardable_type
end end
class Project < Grape::Entity
expose :id, :description, :default_branch, :tag_list
expose :public?, as: :public
expose :archived?, as: :archived
expose :visibility_level, :ssh_url_to_repo, :http_url_to_repo, :web_url
expose :owner, using: ::API::Entities::UserBasic, unless: ->(project, options) { project.group }
expose :name, :name_with_namespace
expose :path, :path_with_namespace
expose :container_registry_enabled
# Expose old field names with the new permissions methods to keep API compatible
expose(:issues_enabled) { |project, options| project.feature_available?(:issues, options[:current_user]) }
expose(:merge_requests_enabled) { |project, options| project.feature_available?(:merge_requests, options[:current_user]) }
expose(:wiki_enabled) { |project, options| project.feature_available?(:wiki, options[:current_user]) }
expose(:builds_enabled) { |project, options| project.feature_available?(:builds, options[:current_user]) }
expose(:snippets_enabled) { |project, options| project.feature_available?(:snippets, options[:current_user]) }
expose :created_at, :last_activity_at
expose :shared_runners_enabled
expose :lfs_enabled?, as: :lfs_enabled
expose :creator_id
expose :namespace, using: 'API::Entities::Namespace'
expose :forked_from_project, using: ::API::Entities::BasicProjectDetails, if: lambda{ |project, options| project.forked? }
expose :avatar_url
expose :star_count, :forks_count
expose :open_issues_count, if: lambda { |project, options| project.feature_available?(:issues, options[:current_user]) && project.default_issues_tracker? }
expose :runners_token, if: lambda { |_project, options| options[:user_can_admin_project] }
expose :public_builds
expose :shared_with_groups do |project, options|
::API::Entities::SharedGroup.represent(project.project_group_links.all, options)
end
expose :only_allow_merge_if_pipeline_succeeds, as: :only_allow_merge_if_build_succeeds
expose :request_access_enabled
expose :only_allow_merge_if_all_discussions_are_resolved
expose :statistics, using: 'API::Entities::ProjectStatistics', if: :statistics
end
class ProjectWithAccess < Project
expose :permissions do
expose :project_access, using: ::API::Entities::ProjectAccess do |project, options|
project.project_members.find_by(user_id: options[:current_user].id)
end
expose :group_access, using: ::API::Entities::GroupAccess do |project, options|
if project.group
project.group.group_members.find_by(user_id: options[:current_user].id)
end
end
end
end
class MergeRequest < Grape::Entity
expose :id, :iid
expose(:project_id) { |entity| entity.project.id }
expose :title, :description
expose :state, :created_at, :updated_at
expose :target_branch, :source_branch
expose :upvotes, :downvotes
expose :author, :assignee, using: ::API::Entities::UserBasic
expose :source_project_id, :target_project_id
expose :label_names, as: :labels
expose :work_in_progress?, as: :work_in_progress
expose :milestone, using: ::API::Entities::Milestone
expose :merge_when_pipeline_succeeds, as: :merge_when_build_succeeds
expose :merge_status
expose :diff_head_sha, as: :sha
expose :merge_commit_sha
expose :subscribed do |merge_request, options|
merge_request.subscribed?(options[:current_user], options[:project])
end
expose :user_notes_count
expose :should_remove_source_branch?, as: :should_remove_source_branch
expose :force_remove_source_branch?, as: :force_remove_source_branch
expose :web_url do |merge_request, options|
Gitlab::UrlBuilder.build(merge_request)
end
end
end end
end end
end end
...@@ -39,7 +39,7 @@ module API ...@@ -39,7 +39,7 @@ module API
desc 'List merge requests' do desc 'List merge requests' do
detail 'iid filter is deprecated have been removed on V4' detail 'iid filter is deprecated have been removed on V4'
success ::API::Entities::MergeRequest success ::API::V3::Entities::MergeRequest
end end
params do params do
optional :state, type: String, values: %w[opened closed merged all], default: 'all', optional :state, type: String, values: %w[opened closed merged all], default: 'all',
...@@ -66,11 +66,11 @@ module API ...@@ -66,11 +66,11 @@ module API
end end
merge_requests = merge_requests.reorder(params[:order_by] => params[:sort]) merge_requests = merge_requests.reorder(params[:order_by] => params[:sort])
present paginate(merge_requests), with: ::API::Entities::MergeRequest, current_user: current_user, project: user_project present paginate(merge_requests), with: ::API::V3::Entities::MergeRequest, current_user: current_user, project: user_project
end end
desc 'Create a merge request' do desc 'Create a merge request' do
success ::API::Entities::MergeRequest success ::API::V3::Entities::MergeRequest
end end
params do params do
requires :title, type: String, desc: 'The title of the merge request' requires :title, type: String, desc: 'The title of the merge request'
...@@ -89,7 +89,7 @@ module API ...@@ -89,7 +89,7 @@ module API
merge_request = ::MergeRequests::CreateService.new(user_project, current_user, mr_params).execute merge_request = ::MergeRequests::CreateService.new(user_project, current_user, mr_params).execute
if merge_request.valid? if merge_request.valid?
present merge_request, with: ::API::Entities::MergeRequest, current_user: current_user, project: user_project present merge_request, with: ::API::V3::Entities::MergeRequest, current_user: current_user, project: user_project
else else
handle_merge_request_errors! merge_request.errors handle_merge_request_errors! merge_request.errors
end end
...@@ -116,12 +116,12 @@ module API ...@@ -116,12 +116,12 @@ module API
if status == :deprecated if status == :deprecated
detail DEPRECATION_MESSAGE detail DEPRECATION_MESSAGE
end end
success ::API::Entities::MergeRequest success ::API::V3::Entities::MergeRequest
end end
get path do get path do
merge_request = find_merge_request_with_access(params[:merge_request_id]) merge_request = find_merge_request_with_access(params[:merge_request_id])
present merge_request, with: ::API::Entities::MergeRequest, current_user: current_user, project: user_project present merge_request, with: ::API::V3::Entities::MergeRequest, current_user: current_user, project: user_project
end end
desc 'Get the commits of a merge request' do desc 'Get the commits of a merge request' do
...@@ -143,7 +143,7 @@ module API ...@@ -143,7 +143,7 @@ module API
end end
desc 'Update a merge request' do desc 'Update a merge request' do
success ::API::Entities::MergeRequest success ::API::V3::Entities::MergeRequest
end end
params do params do
optional :title, type: String, allow_blank: false, desc: 'The title of the merge request' optional :title, type: String, allow_blank: false, desc: 'The title of the merge request'
...@@ -164,21 +164,21 @@ module API ...@@ -164,21 +164,21 @@ module API
merge_request = ::MergeRequests::UpdateService.new(user_project, current_user, mr_params).execute(merge_request) merge_request = ::MergeRequests::UpdateService.new(user_project, current_user, mr_params).execute(merge_request)
if merge_request.valid? if merge_request.valid?
present merge_request, with: ::API::Entities::MergeRequest, current_user: current_user, project: user_project present merge_request, with: ::API::V3::Entities::MergeRequest, current_user: current_user, project: user_project
else else
handle_merge_request_errors! merge_request.errors handle_merge_request_errors! merge_request.errors
end end
end end
desc 'Merge a merge request' do desc 'Merge a merge request' do
success ::API::Entities::MergeRequest success ::API::V3::Entities::MergeRequest
end end
params do params do
optional :merge_commit_message, type: String, desc: 'Custom merge commit message' optional :merge_commit_message, type: String, desc: 'Custom merge commit message'
optional :should_remove_source_branch, type: Boolean, optional :should_remove_source_branch, type: Boolean,
desc: 'When true, the source branch will be deleted if possible' desc: 'When true, the source branch will be deleted if possible'
optional :merge_when_build_succeeds, type: Boolean, optional :merge_when_build_succeeds, type: Boolean,
desc: 'When true, this merge request will be merged when the pipeline succeeds' desc: 'When true, this merge request will be merged when the build succeeds'
optional :sha, type: String, desc: 'When present, must have the HEAD SHA of the source branch' optional :sha, type: String, desc: 'When present, must have the HEAD SHA of the source branch'
end end
put "#{path}/merge" do put "#{path}/merge" do
...@@ -211,16 +211,16 @@ module API ...@@ -211,16 +211,16 @@ module API
.execute(merge_request) .execute(merge_request)
end end
present merge_request, with: ::API::Entities::MergeRequest, current_user: current_user, project: user_project present merge_request, with: ::API::V3::Entities::MergeRequest, current_user: current_user, project: user_project
end end
desc 'Cancel merge if "Merge When Pipeline Succeeds" is enabled' do desc 'Cancel merge if "Merge When Build succeeds" is enabled' do
success ::API::Entities::MergeRequest success ::API::V3::Entities::MergeRequest
end end
post "#{path}/cancel_merge_when_build_succeeds" do post "#{path}/cancel_merge_when_build_succeeds" do
merge_request = find_project_merge_request(params[:merge_request_id]) merge_request = find_project_merge_request(params[:merge_request_id])
unauthorized! unless merge_request.can_cancel_merge_when_build_succeeds?(current_user) unauthorized! unless merge_request.can_cancel_merge_when_pipeline_succeeds?(current_user)
::MergeRequest::MergeWhenPipelineSucceedsService ::MergeRequest::MergeWhenPipelineSucceedsService
.new(merge_request.target_project, current_user) .new(merge_request.target_project, current_user)
......
...@@ -5,6 +5,10 @@ module API ...@@ -5,6 +5,10 @@ module API
before { authenticate_non_get! } before { authenticate_non_get! }
after_validation do
set_only_allow_merge_if_pipeline_succeeds!
end
helpers do helpers do
params :optional_params do params :optional_params do
optional :description, type: String, desc: 'The description of the project' optional :description, type: String, desc: 'The description of the project'
...@@ -25,6 +29,7 @@ module API ...@@ -25,6 +29,7 @@ module API
optional :public_builds, type: Boolean, desc: 'Perform public builds' optional :public_builds, type: Boolean, desc: 'Perform public builds'
optional :request_access_enabled, type: Boolean, desc: 'Allow users to request member access' optional :request_access_enabled, type: Boolean, desc: 'Allow users to request member access'
optional :only_allow_merge_if_build_succeeds, type: Boolean, desc: 'Only allow to merge if builds succeed' optional :only_allow_merge_if_build_succeeds, type: Boolean, desc: 'Only allow to merge if builds succeed'
optional :only_allow_merge_if_pipeline_succeeds, type: Boolean, desc: 'Only allow to merge if builds succeed'
optional :only_allow_merge_if_all_discussions_are_resolved, type: Boolean, desc: 'Only allow to merge if all discussions are resolved' optional :only_allow_merge_if_all_discussions_are_resolved, type: Boolean, desc: 'Only allow to merge if all discussions are resolved'
end end
...@@ -37,6 +42,12 @@ module API ...@@ -37,6 +42,12 @@ module API
end end
attrs attrs
end end
def set_only_allow_merge_if_pipeline_succeeds!
if params.has_key?(:only_allow_merge_if_build_succeeds)
params[:only_allow_merge_if_pipeline_succeeds] = params.delete(:only_allow_merge_if_build_succeeds)
end
end
end end
resource :projects do resource :projects do
...@@ -75,7 +86,7 @@ module API ...@@ -75,7 +86,7 @@ module API
def present_projects(projects, options = {}) def present_projects(projects, options = {})
options = options.reverse_merge( options = options.reverse_merge(
with: ::API::Entities::Project, with: ::API::V3::Entities::Project,
current_user: current_user, current_user: current_user,
simple: params[:simple], simple: params[:simple],
) )
...@@ -95,7 +106,7 @@ module API ...@@ -95,7 +106,7 @@ module API
use :collection_params use :collection_params
end end
get '/visible' do get '/visible' do
entity = current_user ? ::API::Entities::ProjectWithAccess : ::API::Entities::BasicProjectDetails entity = current_user ? ::API::V3::Entities::ProjectWithAccess : ::API::Entities::BasicProjectDetails
present_projects ProjectsFinder.new.execute(current_user), with: entity present_projects ProjectsFinder.new.execute(current_user), with: entity
end end
...@@ -109,7 +120,7 @@ module API ...@@ -109,7 +120,7 @@ module API
authenticate! authenticate!
present_projects current_user.authorized_projects, present_projects current_user.authorized_projects,
with: ::API::Entities::ProjectWithAccess with: ::API::V3::Entities::ProjectWithAccess
end end
desc 'Get an owned projects list for authenticated user' do desc 'Get an owned projects list for authenticated user' do
...@@ -123,7 +134,7 @@ module API ...@@ -123,7 +134,7 @@ module API
authenticate! authenticate!
present_projects current_user.owned_projects, present_projects current_user.owned_projects,
with: ::API::Entities::ProjectWithAccess, with: ::API::V3::Entities::ProjectWithAccess,
statistics: params[:statistics] statistics: params[:statistics]
end end
...@@ -149,11 +160,11 @@ module API ...@@ -149,11 +160,11 @@ module API
get '/all' do get '/all' do
authenticated_as_admin! authenticated_as_admin!
present_projects Project.all, with: ::API::Entities::ProjectWithAccess, statistics: params[:statistics] present_projects Project.all, with: ::API::V3::Entities::ProjectWithAccess, statistics: params[:statistics]
end end
desc 'Search for projects the current user has access to' do desc 'Search for projects the current user has access to' do
success ::API::Entities::Project success ::API::V3::Entities::Project
end end
params do params do
requires :query, type: String, desc: 'The project name to be searched' requires :query, type: String, desc: 'The project name to be searched'
...@@ -165,11 +176,11 @@ module API ...@@ -165,11 +176,11 @@ module API
projects = search_service.objects('projects', params[:page]) projects = search_service.objects('projects', params[:page])
projects = projects.reorder(params[:order_by] => params[:sort]) projects = projects.reorder(params[:order_by] => params[:sort])
present paginate(projects), with: ::API::Entities::Project present paginate(projects), with: ::API::V3::Entities::Project
end end
desc 'Create new project' do desc 'Create new project' do
success ::API::Entities::Project success ::API::V3::Entities::Project
end end
params do params do
optional :name, type: String, desc: 'The name of the project' optional :name, type: String, desc: 'The name of the project'
...@@ -183,7 +194,7 @@ module API ...@@ -183,7 +194,7 @@ module API
project = ::Projects::CreateService.new(current_user, attrs).execute project = ::Projects::CreateService.new(current_user, attrs).execute
if project.saved? if project.saved?
present project, with: ::API::Entities::Project, present project, with: ::API::V3::Entities::Project,
user_can_admin_project: can?(current_user, :admin_project, project) user_can_admin_project: can?(current_user, :admin_project, project)
else else
if project.errors[:limit_reached].present? if project.errors[:limit_reached].present?
...@@ -194,7 +205,7 @@ module API ...@@ -194,7 +205,7 @@ module API
end end
desc 'Create new project for a specified user. Only available to admin users.' do desc 'Create new project for a specified user. Only available to admin users.' do
success ::API::Entities::Project success ::API::V3::Entities::Project
end end
params do params do
requires :name, type: String, desc: 'The name of the project' requires :name, type: String, desc: 'The name of the project'
...@@ -212,7 +223,7 @@ module API ...@@ -212,7 +223,7 @@ module API
project = ::Projects::CreateService.new(user, attrs).execute project = ::Projects::CreateService.new(user, attrs).execute
if project.saved? if project.saved?
present project, with: ::API::Entities::Project, present project, with: ::API::V3::Entities::Project,
user_can_admin_project: can?(current_user, :admin_project, project) user_can_admin_project: can?(current_user, :admin_project, project)
else else
render_validation_error!(project) render_validation_error!(project)
...@@ -225,10 +236,10 @@ module API ...@@ -225,10 +236,10 @@ module API
end end
resource :projects, requirements: { id: /[^\/]+/ } do resource :projects, requirements: { id: /[^\/]+/ } do
desc 'Get a single project' do desc 'Get a single project' do
success ::API::Entities::ProjectWithAccess success ::API::V3::Entities::ProjectWithAccess
end end
get ":id" do get ":id" do
entity = current_user ? ::API::Entities::ProjectWithAccess : ::API::Entities::BasicProjectDetails entity = current_user ? ::API::V3::Entities::ProjectWithAccess : ::API::Entities::BasicProjectDetails
present user_project, with: entity, current_user: current_user, present user_project, with: entity, current_user: current_user,
user_can_admin_project: can?(current_user, :admin_project, user_project) user_can_admin_project: can?(current_user, :admin_project, user_project)
end end
...@@ -244,7 +255,7 @@ module API ...@@ -244,7 +255,7 @@ module API
end end
desc 'Fork new project for the current user or provided namespace.' do desc 'Fork new project for the current user or provided namespace.' do
success ::API::Entities::Project success ::API::V3::Entities::Project
end end
params do params do
optional :namespace, type: String, desc: 'The ID or name of the namespace that the project will be forked into' optional :namespace, type: String, desc: 'The ID or name of the namespace that the project will be forked into'
...@@ -270,13 +281,13 @@ module API ...@@ -270,13 +281,13 @@ module API
if forked_project.errors.any? if forked_project.errors.any?
conflict!(forked_project.errors.messages) conflict!(forked_project.errors.messages)
else else
present forked_project, with: ::API::Entities::Project, present forked_project, with: ::API::V3::Entities::Project,
user_can_admin_project: can?(current_user, :admin_project, forked_project) user_can_admin_project: can?(current_user, :admin_project, forked_project)
end end
end end
desc 'Update an existing project' do desc 'Update an existing project' do
success ::API::Entities::Project success ::API::V3::Entities::Project
end end
params do params do
optional :name, type: String, desc: 'The name of the project' optional :name, type: String, desc: 'The name of the project'
...@@ -300,7 +311,7 @@ module API ...@@ -300,7 +311,7 @@ module API
result = ::Projects::UpdateService.new(user_project, current_user, attrs).execute result = ::Projects::UpdateService.new(user_project, current_user, attrs).execute
if result[:status] == :success if result[:status] == :success
present user_project, with: ::API::Entities::Project, present user_project, with: ::API::V3::Entities::Project,
user_can_admin_project: can?(current_user, :admin_project, user_project) user_can_admin_project: can?(current_user, :admin_project, user_project)
else else
render_validation_error!(user_project) render_validation_error!(user_project)
...@@ -308,29 +319,29 @@ module API ...@@ -308,29 +319,29 @@ module API
end end
desc 'Archive a project' do desc 'Archive a project' do
success ::API::Entities::Project success ::API::V3::Entities::Project
end end
post ':id/archive' do post ':id/archive' do
authorize!(:archive_project, user_project) authorize!(:archive_project, user_project)
user_project.archive! user_project.archive!
present user_project, with: ::API::Entities::Project present user_project, with: ::API::V3::Entities::Project
end end
desc 'Unarchive a project' do desc 'Unarchive a project' do
success ::API::Entities::Project success ::API::V3::Entities::Project
end end
post ':id/unarchive' do post ':id/unarchive' do
authorize!(:archive_project, user_project) authorize!(:archive_project, user_project)
user_project.unarchive! user_project.unarchive!
present user_project, with: ::API::Entities::Project present user_project, with: ::API::V3::Entities::Project
end end
desc 'Star a project' do desc 'Star a project' do
success ::API::Entities::Project success ::API::V3::Entities::Project
end end
post ':id/star' do post ':id/star' do
if current_user.starred?(user_project) if current_user.starred?(user_project)
...@@ -339,19 +350,19 @@ module API ...@@ -339,19 +350,19 @@ module API
current_user.toggle_star(user_project) current_user.toggle_star(user_project)
user_project.reload user_project.reload
present user_project, with: ::API::Entities::Project present user_project, with: ::API::V3::Entities::Project
end end
end end
desc 'Unstar a project' do desc 'Unstar a project' do
success ::API::Entities::Project success ::API::V3::Entities::Project
end end
delete ':id/star' do delete ':id/star' do
if current_user.starred?(user_project) if current_user.starred?(user_project)
current_user.toggle_star(user_project) current_user.toggle_star(user_project)
user_project.reload user_project.reload
present user_project, with: ::API::Entities::Project present user_project, with: ::API::V3::Entities::Project
else else
not_modified! not_modified!
end end
......
...@@ -319,41 +319,41 @@ describe Projects::MergeRequestsController do ...@@ -319,41 +319,41 @@ describe Projects::MergeRequestsController do
merge_with_sha merge_with_sha
end end
context 'when merge_when_build_succeeds is passed' do context 'when the pipeline succeeds is passed' do
def merge_when_build_succeeds def merge_when_pipeline_succeeds
post :merge, base_params.merge(sha: merge_request.diff_head_sha, merge_when_build_succeeds: '1') post :merge, base_params.merge(sha: merge_request.diff_head_sha, merge_when_pipeline_succeeds: '1')
end end
before do before do
create(:ci_empty_pipeline, project: project, sha: merge_request.diff_head_sha, ref: merge_request.source_branch) create(:ci_empty_pipeline, project: project, sha: merge_request.diff_head_sha, ref: merge_request.source_branch)
end end
it 'returns :merge_when_build_succeeds' do it 'returns :merge_when_pipeline_succeeds' do
merge_when_build_succeeds merge_when_pipeline_succeeds
expect(assigns(:status)).to eq(:merge_when_build_succeeds) expect(assigns(:status)).to eq(:merge_when_pipeline_succeeds)
end end
it 'sets the MR to merge when the build succeeds' do it 'sets the MR to merge when the pipeline succeeds' do
service = double(:merge_when_build_succeeds_service) service = double(:merge_when_pipeline_succeeds_service)
expect(MergeRequests::MergeWhenPipelineSucceedsService) expect(MergeRequests::MergeWhenPipelineSucceedsService)
.to receive(:new).with(project, anything, anything) .to receive(:new).with(project, anything, anything)
.and_return(service) .and_return(service)
expect(service).to receive(:execute).with(merge_request) expect(service).to receive(:execute).with(merge_request)
merge_when_build_succeeds merge_when_pipeline_succeeds
end end
context 'when project.only_allow_merge_if_build_succeeds? is true' do context 'when project.only_allow_merge_if_pipeline_succeeds? is true' do
before do before do
project.update_column(:only_allow_merge_if_build_succeeds, true) project.update_column(:only_allow_merge_if_pipeline_succeeds, true)
end end
it 'returns :merge_when_build_succeeds' do it 'returns :merge_when_pipeline_succeeds' do
merge_when_build_succeeds merge_when_pipeline_succeeds
expect(assigns(:status)).to eq(:merge_when_build_succeeds) expect(assigns(:status)).to eq(:merge_when_pipeline_succeeds)
end end
end end
end end
...@@ -1134,14 +1134,14 @@ describe Projects::MergeRequestsController do ...@@ -1134,14 +1134,14 @@ describe Projects::MergeRequestsController do
end end
context 'when waiting for build' do context 'when waiting for build' do
let(:merge_request) { create(:merge_request, source_project: project, merge_when_build_succeeds: true, merge_user: user) } let(:merge_request) { create(:merge_request, source_project: project, merge_when_pipeline_succeeds: true, merge_user: user) }
it 'returns an OK response' do it 'returns an OK response' do
expect(response).to have_http_status(:ok) expect(response).to have_http_status(:ok)
end end
it 'sets status to :merge_when_build_succeeds' do it 'sets status to :merge_when_pipeline_succeeds' do
expect(assigns(:status)).to eq(:merge_when_build_succeeds) expect(assigns(:status)).to eq(:merge_when_pipeline_succeeds)
expect(response).to render_template('merge') expect(response).to render_template('merge')
end end
end end
......
...@@ -59,8 +59,8 @@ FactoryGirl.define do ...@@ -59,8 +59,8 @@ FactoryGirl.define do
target_branch "master" target_branch "master"
end end
trait :merge_when_build_succeeds do trait :merge_when_pipeline_succeeds do
merge_when_build_succeeds true merge_when_pipeline_succeeds true
merge_user author merge_user author
end end
......
...@@ -75,7 +75,7 @@ feature 'Merge When Pipeline Succeeds', :feature, :js do ...@@ -75,7 +75,7 @@ feature 'Merge When Pipeline Succeeds', :feature, :js do
context 'when it was enabled and then canceled' do context 'when it was enabled and then canceled' do
let(:merge_request) do let(:merge_request) do
create(:merge_request_with_diffs, create(:merge_request_with_diffs,
:merge_when_build_succeeds, :merge_when_pipeline_succeeds,
source_project: project, source_project: project,
title: 'Bug NS-04', title: 'Bug NS-04',
author: user, author: user,
...@@ -97,7 +97,7 @@ feature 'Merge When Pipeline Succeeds', :feature, :js do ...@@ -97,7 +97,7 @@ feature 'Merge When Pipeline Succeeds', :feature, :js do
author: user, author: user,
merge_user: user, merge_user: user,
title: 'MepMep', title: 'MepMep',
merge_when_build_succeeds: true) merge_when_pipeline_succeeds: true)
end end
let!(:build) do let!(:build) do
......
require 'spec_helper' require 'spec_helper'
feature 'Only allow merge requests to be merged if the build succeeds', feature: true do feature 'Only allow merge requests to be merged if the pipeline succeeds', feature: true do
let(:merge_request) { create(:merge_request_with_diffs) } let(:merge_request) { create(:merge_request_with_diffs) }
let(:project) { merge_request.target_project } let(:project) { merge_request.target_project }
...@@ -27,9 +27,9 @@ feature 'Only allow merge requests to be merged if the build succeeds', feature: ...@@ -27,9 +27,9 @@ feature 'Only allow merge requests to be merged if the build succeeds', feature:
status: status) status: status)
end end
context 'when merge requests can only be merged if the build succeeds' do context 'when merge requests can only be merged if the pipeline succeeds' do
before do before do
project.update_attribute(:only_allow_merge_if_build_succeeds, true) project.update_attribute(:only_allow_merge_if_pipeline_succeeds, true)
end end
context 'when CI is running' do context 'when CI is running' do
...@@ -88,7 +88,7 @@ feature 'Only allow merge requests to be merged if the build succeeds', feature: ...@@ -88,7 +88,7 @@ feature 'Only allow merge requests to be merged if the build succeeds', feature:
context 'when merge requests can be merged when the build failed' do context 'when merge requests can be merged when the build failed' do
before do before do
project.update_attribute(:only_allow_merge_if_build_succeeds, false) project.update_attribute(:only_allow_merge_if_pipeline_succeeds, false)
end end
context 'when CI is running' do context 'when CI is running' do
......
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
"avatar_url": null, "avatar_url": null,
"star_count": 0, "star_count": 0,
"forks_count": 0, "forks_count": 0,
"only_allow_merge_if_build_succeeds": false, "only_allow_merge_if_pipeline_succeeds": false,
"open_issues_count": 0, "open_issues_count": 0,
"permissions": { "permissions": {
"project_access": null, "project_access": null,
...@@ -88,7 +88,7 @@ ...@@ -88,7 +88,7 @@
"avatar_url": null, "avatar_url": null,
"star_count": 0, "star_count": 0,
"forks_count": 0, "forks_count": 0,
"only_allow_merge_if_build_succeeds": false, "only_allow_merge_if_pipeline_succeeds": false,
"open_issues_count": 5, "open_issues_count": 5,
"permissions": { "permissions": {
"project_access": { "project_access": {
...@@ -139,7 +139,7 @@ ...@@ -139,7 +139,7 @@
"avatar_url": null, "avatar_url": null,
"star_count": 0, "star_count": 0,
"forks_count": 0, "forks_count": 0,
"only_allow_merge_if_build_succeeds": true, "only_allow_merge_if_pipeline_succeeds": true,
"open_issues_count": 4, "open_issues_count": 4,
"permissions": { "permissions": {
"project_access": null, "project_access": null,
...@@ -187,7 +187,7 @@ ...@@ -187,7 +187,7 @@
"avatar_url": null, "avatar_url": null,
"star_count": 0, "star_count": 0,
"forks_count": 0, "forks_count": 0,
"only_allow_merge_if_build_succeeds": true, "only_allow_merge_if_pipeline_succeeds": true,
"open_issues_count": 4, "open_issues_count": 4,
"permissions": { "permissions": {
"project_access": null, "project_access": null,
...@@ -235,7 +235,7 @@ ...@@ -235,7 +235,7 @@
"avatar_url": null, "avatar_url": null,
"star_count": 0, "star_count": 0,
"forks_count": 0, "forks_count": 0,
"only_allow_merge_if_build_succeeds": false, "only_allow_merge_if_pipeline_succeeds": false,
"open_issues_count": 5, "open_issues_count": 5,
"permissions": { "permissions": {
"project_access": null, "project_access": null,
...@@ -283,7 +283,7 @@ ...@@ -283,7 +283,7 @@
"avatar_url": null, "avatar_url": null,
"star_count": 0, "star_count": 0,
"forks_count": 0, "forks_count": 0,
"only_allow_merge_if_build_succeeds": false, "only_allow_merge_if_pipeline_succeeds": false,
"open_issues_count": 5, "open_issues_count": 5,
"permissions": { "permissions": {
"project_access": { "project_access": {
...@@ -334,7 +334,7 @@ ...@@ -334,7 +334,7 @@
"avatar_url": null, "avatar_url": null,
"star_count": 0, "star_count": 0,
"forks_count": 0, "forks_count": 0,
"only_allow_merge_if_build_succeeds": false, "only_allow_merge_if_pipeline_succeeds": false,
"open_issues_count": 3, "open_issues_count": 3,
"permissions": { "permissions": {
"project_access": null, "project_access": null,
...@@ -382,7 +382,7 @@ ...@@ -382,7 +382,7 @@
"avatar_url": null, "avatar_url": null,
"star_count": 0, "star_count": 0,
"forks_count": 0, "forks_count": 0,
"only_allow_merge_if_build_succeeds": false, "only_allow_merge_if_pipeline_succeeds": false,
"open_issues_count": 5, "open_issues_count": 5,
"permissions": { "permissions": {
"project_access": { "project_access": {
...@@ -433,7 +433,7 @@ ...@@ -433,7 +433,7 @@
"avatar_url": null, "avatar_url": null,
"star_count": 0, "star_count": 0,
"forks_count": 0, "forks_count": 0,
"only_allow_merge_if_build_succeeds": false, "only_allow_merge_if_pipeline_succeeds": false,
"open_issues_count": 5, "open_issues_count": 5,
"permissions": { "permissions": {
"project_access": null, "project_access": null,
......
...@@ -2539,7 +2539,7 @@ ...@@ -2539,7 +2539,7 @@
"merge_params": { "merge_params": {
"force_remove_source_branch": null "force_remove_source_branch": null
}, },
"merge_when_build_succeeds": true, "merge_when_pipeline_succeeds": true,
"merge_user_id": null, "merge_user_id": null,
"merge_commit_sha": null, "merge_commit_sha": null,
"deleted_at": null, "deleted_at": null,
...@@ -2976,7 +2976,7 @@ ...@@ -2976,7 +2976,7 @@
"merge_params": { "merge_params": {
"force_remove_source_branch": null "force_remove_source_branch": null
}, },
"merge_when_build_succeeds": false, "merge_when_pipeline_succeeds": false,
"merge_user_id": null, "merge_user_id": null,
"merge_commit_sha": null, "merge_commit_sha": null,
"deleted_at": null, "deleted_at": null,
...@@ -3260,7 +3260,7 @@ ...@@ -3260,7 +3260,7 @@
"merge_params": { "merge_params": {
"force_remove_source_branch": null "force_remove_source_branch": null
}, },
"merge_when_build_succeeds": false, "merge_when_pipeline_succeeds": false,
"merge_user_id": null, "merge_user_id": null,
"merge_commit_sha": null, "merge_commit_sha": null,
"deleted_at": null, "deleted_at": null,
...@@ -3544,7 +3544,7 @@ ...@@ -3544,7 +3544,7 @@
"merge_params": { "merge_params": {
"force_remove_source_branch": null "force_remove_source_branch": null
}, },
"merge_when_build_succeeds": false, "merge_when_pipeline_succeeds": false,
"merge_user_id": null, "merge_user_id": null,
"merge_commit_sha": null, "merge_commit_sha": null,
"deleted_at": null, "deleted_at": null,
...@@ -4234,7 +4234,7 @@ ...@@ -4234,7 +4234,7 @@
"merge_params": { "merge_params": {
"force_remove_source_branch": null "force_remove_source_branch": null
}, },
"merge_when_build_succeeds": false, "merge_when_pipeline_succeeds": false,
"merge_user_id": null, "merge_user_id": null,
"merge_commit_sha": null, "merge_commit_sha": null,
"deleted_at": null, "deleted_at": null,
...@@ -4782,7 +4782,7 @@ ...@@ -4782,7 +4782,7 @@
"merge_params": { "merge_params": {
"force_remove_source_branch": null "force_remove_source_branch": null
}, },
"merge_when_build_succeeds": false, "merge_when_pipeline_succeeds": false,
"merge_user_id": null, "merge_user_id": null,
"merge_commit_sha": null, "merge_commit_sha": null,
"deleted_at": null, "deleted_at": null,
...@@ -5281,7 +5281,7 @@ ...@@ -5281,7 +5281,7 @@
"merge_params": { "merge_params": {
"force_remove_source_branch": null "force_remove_source_branch": null
}, },
"merge_when_build_succeeds": false, "merge_when_pipeline_succeeds": false,
"merge_user_id": null, "merge_user_id": null,
"merge_commit_sha": null, "merge_commit_sha": null,
"deleted_at": null, "deleted_at": null,
...@@ -5541,7 +5541,7 @@ ...@@ -5541,7 +5541,7 @@
"merge_params": { "merge_params": {
"force_remove_source_branch": null "force_remove_source_branch": null
}, },
"merge_when_build_succeeds": false, "merge_when_pipeline_succeeds": false,
"merge_user_id": null, "merge_user_id": null,
"merge_commit_sha": null, "merge_commit_sha": null,
"deleted_at": null, "deleted_at": null,
...@@ -6231,7 +6231,7 @@ ...@@ -6231,7 +6231,7 @@
"merge_params": { "merge_params": {
"force_remove_source_branch": null "force_remove_source_branch": null
}, },
"merge_when_build_succeeds": false, "merge_when_pipeline_succeeds": false,
"merge_user_id": null, "merge_user_id": null,
"merge_commit_sha": null, "merge_commit_sha": null,
"deleted_at": null, "deleted_at": null,
......
...@@ -142,7 +142,7 @@ MergeRequest: ...@@ -142,7 +142,7 @@ MergeRequest:
- updated_by_id - updated_by_id
- merge_error - merge_error
- merge_params - merge_params
- merge_when_build_succeeds - merge_when_pipeline_succeeds
- merge_user_id - merge_user_id
- merge_commit_sha - merge_commit_sha
- deleted_at - deleted_at
......
...@@ -37,12 +37,12 @@ describe MergeRequest, models: true do ...@@ -37,12 +37,12 @@ describe MergeRequest, models: true do
end end
it "is invalid without merge user" do it "is invalid without merge user" do
subject.merge_when_build_succeeds = true subject.merge_when_pipeline_succeeds = true
expect(subject).not_to be_valid expect(subject).not_to be_valid
end end
it "is valid with merge user" do it "is valid with merge user" do
subject.merge_when_build_succeeds = true subject.merge_when_pipeline_succeeds = true
subject.merge_user = build(:user) subject.merge_user = build(:user)
expect(subject).to be_valid expect(subject).to be_valid
...@@ -55,7 +55,7 @@ describe MergeRequest, models: true do ...@@ -55,7 +55,7 @@ describe MergeRequest, models: true do
it { is_expected.to respond_to(:can_be_merged?) } it { is_expected.to respond_to(:can_be_merged?) }
it { is_expected.to respond_to(:cannot_be_merged?) } it { is_expected.to respond_to(:cannot_be_merged?) }
it { is_expected.to respond_to(:merge_params) } it { is_expected.to respond_to(:merge_params) }
it { is_expected.to respond_to(:merge_when_build_succeeds) } it { is_expected.to respond_to(:merge_when_pipeline_succeeds) }
end end
describe '.in_projects' do describe '.in_projects' do
...@@ -508,17 +508,17 @@ describe MergeRequest, models: true do ...@@ -508,17 +508,17 @@ describe MergeRequest, models: true do
end end
end end
describe "#reset_merge_when_build_succeeds" do describe "#reset_merge_when_pipeline_succeeds" do
let(:merge_if_green) do let(:merge_if_green) do
create :merge_request, merge_when_build_succeeds: true, merge_user: create(:user), create :merge_request, merge_when_pipeline_succeeds: true, merge_user: create(:user),
merge_params: { "should_remove_source_branch" => "1", "commit_message" => "msg" } merge_params: { "should_remove_source_branch" => "1", "commit_message" => "msg" }
end end
it "sets the item to false" do it "sets the item to false" do
merge_if_green.reset_merge_when_build_succeeds merge_if_green.reset_merge_when_pipeline_succeeds
merge_if_green.reload merge_if_green.reload
expect(merge_if_green.merge_when_build_succeeds).to be_falsey expect(merge_if_green.merge_when_pipeline_succeeds).to be_falsey
expect(merge_if_green.merge_params["should_remove_source_branch"]).to be_nil expect(merge_if_green.merge_params["should_remove_source_branch"]).to be_nil
expect(merge_if_green.merge_params["commit_message"]).to be_nil expect(merge_if_green.merge_params["commit_message"]).to be_nil
end end
...@@ -812,7 +812,7 @@ describe MergeRequest, models: true do ...@@ -812,7 +812,7 @@ describe MergeRequest, models: true do
end end
describe '#check_if_can_be_merged' do describe '#check_if_can_be_merged' do
let(:project) { create(:empty_project, only_allow_merge_if_build_succeeds: true) } let(:project) { create(:empty_project, only_allow_merge_if_pipeline_succeeds: true) }
subject { create(:merge_request, source_project: project, merge_status: :unchecked) } subject { create(:merge_request, source_project: project, merge_status: :unchecked) }
...@@ -927,7 +927,7 @@ describe MergeRequest, models: true do ...@@ -927,7 +927,7 @@ describe MergeRequest, models: true do
end end
describe '#mergeable_ci_state?' do describe '#mergeable_ci_state?' do
let(:project) { create(:empty_project, only_allow_merge_if_build_succeeds: true) } let(:project) { create(:empty_project, only_allow_merge_if_pipeline_succeeds: true) }
let(:pipeline) { create(:ci_empty_pipeline) } let(:pipeline) { create(:ci_empty_pipeline) }
subject { build(:merge_request, target_project: project) } subject { build(:merge_request, target_project: project) }
...@@ -970,7 +970,7 @@ describe MergeRequest, models: true do ...@@ -970,7 +970,7 @@ describe MergeRequest, models: true do
end end
context 'when merges are not restricted to green builds' do context 'when merges are not restricted to green builds' do
subject { build(:merge_request, target_project: build(:empty_project, only_allow_merge_if_build_succeeds: false)) } subject { build(:merge_request, target_project: build(:empty_project, only_allow_merge_if_pipeline_succeeds: false)) }
context 'and a failed pipeline is associated' do context 'and a failed pipeline is associated' do
before do before do
...@@ -1575,7 +1575,7 @@ describe MergeRequest, models: true do ...@@ -1575,7 +1575,7 @@ describe MergeRequest, models: true do
status: status) status: status)
end end
let(:project) { create(:project, :public, :repository, only_allow_merge_if_build_succeeds: true) } let(:project) { create(:project, :public, :repository, only_allow_merge_if_pipeline_succeeds: true) }
let(:developer) { create(:user) } let(:developer) { create(:user) }
let(:user) { create(:user) } let(:user) { create(:user) }
let(:merge_request) { create(:merge_request, source_project: project) } let(:merge_request) { create(:merge_request, source_project: project) }
......
...@@ -170,7 +170,7 @@ describe API::MergeRequests, api: true do ...@@ -170,7 +170,7 @@ describe API::MergeRequests, api: true do
expect(json_response['source_project_id']).to eq(merge_request.source_project.id) expect(json_response['source_project_id']).to eq(merge_request.source_project.id)
expect(json_response['target_project_id']).to eq(merge_request.target_project.id) expect(json_response['target_project_id']).to eq(merge_request.target_project.id)
expect(json_response['work_in_progress']).to be_falsy expect(json_response['work_in_progress']).to be_falsy
expect(json_response['merge_when_build_succeeds']).to be_falsy expect(json_response['merge_when_pipeline_succeeds']).to be_falsy
expect(json_response['merge_status']).to eq('can_be_merged') expect(json_response['merge_status']).to eq('can_be_merged')
expect(json_response['should_close_merge_request']).to be_falsy expect(json_response['should_close_merge_request']).to be_falsy
expect(json_response['force_close_merge_request']).to be_falsy expect(json_response['force_close_merge_request']).to be_falsy
...@@ -483,11 +483,11 @@ describe API::MergeRequests, api: true do ...@@ -483,11 +483,11 @@ describe API::MergeRequests, api: true do
allow_any_instance_of(MergeRequest).to receive(:head_pipeline).and_return(pipeline) allow_any_instance_of(MergeRequest).to receive(:head_pipeline).and_return(pipeline)
allow(pipeline).to receive(:active?).and_return(true) allow(pipeline).to receive(:active?).and_return(true)
put api("/projects/#{project.id}/merge_requests/#{merge_request.id}/merge", user), merge_when_build_succeeds: true put api("/projects/#{project.id}/merge_requests/#{merge_request.id}/merge", user), merge_when_pipeline_succeeds: true
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(json_response['title']).to eq('Test') expect(json_response['title']).to eq('Test')
expect(json_response['merge_when_build_succeeds']).to eq(true) expect(json_response['merge_when_pipeline_succeeds']).to eq(true)
end end
end end
......
...@@ -320,7 +320,7 @@ describe API::Projects, api: true do ...@@ -320,7 +320,7 @@ describe API::Projects, api: true do
issues_enabled: false, issues_enabled: false,
merge_requests_enabled: false, merge_requests_enabled: false,
wiki_enabled: false, wiki_enabled: false,
only_allow_merge_if_build_succeeds: false, only_allow_merge_if_pipeline_succeeds: false,
request_access_enabled: true, request_access_enabled: true,
only_allow_merge_if_all_discussions_are_resolved: false only_allow_merge_if_all_discussions_are_resolved: false
}) })
...@@ -361,15 +361,15 @@ describe API::Projects, api: true do ...@@ -361,15 +361,15 @@ describe API::Projects, api: true do
end end
it 'sets a project as allowing merge even if build fails' do it 'sets a project as allowing merge even if build fails' do
project = attributes_for(:project, { only_allow_merge_if_build_succeeds: false }) project = attributes_for(:project, { only_allow_merge_if_pipeline_succeeds: false })
post api('/projects', user), project post api('/projects', user), project
expect(json_response['only_allow_merge_if_build_succeeds']).to be_falsey expect(json_response['only_allow_merge_if_pipeline_succeeds']).to be_falsey
end end
it 'sets a project as allowing merge only if build succeeds' do it 'sets a project as allowing merge only if merge_when_pipeline_succeeds' do
project = attributes_for(:project, { only_allow_merge_if_build_succeeds: true }) project = attributes_for(:project, { only_allow_merge_if_pipeline_succeeds: true })
post api('/projects', user), project post api('/projects', user), project
expect(json_response['only_allow_merge_if_build_succeeds']).to be_truthy expect(json_response['only_allow_merge_if_pipeline_succeeds']).to be_truthy
end end
it 'sets a project as allowing merge even if discussions are unresolved' do it 'sets a project as allowing merge even if discussions are unresolved' do
...@@ -484,15 +484,15 @@ describe API::Projects, api: true do ...@@ -484,15 +484,15 @@ describe API::Projects, api: true do
end end
it 'sets a project as allowing merge even if build fails' do it 'sets a project as allowing merge even if build fails' do
project = attributes_for(:project, { only_allow_merge_if_build_succeeds: false }) project = attributes_for(:project, { only_allow_merge_if_pipeline_succeeds: false })
post api("/projects/user/#{user.id}", admin), project post api("/projects/user/#{user.id}", admin), project
expect(json_response['only_allow_merge_if_build_succeeds']).to be_falsey expect(json_response['only_allow_merge_if_pipeline_succeeds']).to be_falsey
end end
it 'sets a project as allowing merge only if build succeeds' do it 'sets a project as allowing merge only if merge_when_pipeline_succeeds' do
project = attributes_for(:project, { only_allow_merge_if_build_succeeds: true }) project = attributes_for(:project, { only_allow_merge_if_pipeline_succeeds: true })
post api("/projects/user/#{user.id}", admin), project post api("/projects/user/#{user.id}", admin), project
expect(json_response['only_allow_merge_if_build_succeeds']).to be_truthy expect(json_response['only_allow_merge_if_pipeline_succeeds']).to be_truthy
end end
it 'sets a project as allowing merge even if discussions are unresolved' do it 'sets a project as allowing merge even if discussions are unresolved' do
...@@ -586,7 +586,7 @@ describe API::Projects, api: true do ...@@ -586,7 +586,7 @@ describe API::Projects, api: true do
expect(json_response['shared_with_groups'][0]['group_id']).to eq(group.id) expect(json_response['shared_with_groups'][0]['group_id']).to eq(group.id)
expect(json_response['shared_with_groups'][0]['group_name']).to eq(group.name) expect(json_response['shared_with_groups'][0]['group_name']).to eq(group.name)
expect(json_response['shared_with_groups'][0]['group_access_level']).to eq(link.group_access) expect(json_response['shared_with_groups'][0]['group_access_level']).to eq(link.group_access)
expect(json_response['only_allow_merge_if_build_succeeds']).to eq(project.only_allow_merge_if_build_succeeds) expect(json_response['only_allow_merge_if_pipeline_succeeds']).to eq(project.only_allow_merge_if_pipeline_succeeds)
expect(json_response['only_allow_merge_if_all_discussions_are_resolved']).to eq(project.only_allow_merge_if_all_discussions_are_resolved) expect(json_response['only_allow_merge_if_all_discussions_are_resolved']).to eq(project.only_allow_merge_if_all_discussions_are_resolved)
end end
......
...@@ -427,7 +427,7 @@ describe API::V3::Projects, api: true do ...@@ -427,7 +427,7 @@ describe API::V3::Projects, api: true do
expect(json_response['only_allow_merge_if_build_succeeds']).to be_falsey expect(json_response['only_allow_merge_if_build_succeeds']).to be_falsey
end end
it 'sets a project as allowing merge only if build succeeds' do it 'sets a project as allowing merge only if merge_when_pipeline_succeeds' do
project = attributes_for(:project, { only_allow_merge_if_build_succeeds: true }) project = attributes_for(:project, { only_allow_merge_if_build_succeeds: true })
post v3_api('/projects', user), project post v3_api('/projects', user), project
expect(json_response['only_allow_merge_if_build_succeeds']).to be_truthy expect(json_response['only_allow_merge_if_build_succeeds']).to be_truthy
...@@ -572,7 +572,7 @@ describe API::V3::Projects, api: true do ...@@ -572,7 +572,7 @@ describe API::V3::Projects, api: true do
expect(json_response['only_allow_merge_if_build_succeeds']).to be_falsey expect(json_response['only_allow_merge_if_build_succeeds']).to be_falsey
end end
it 'sets a project as allowing merge only if build succeeds' do it 'sets a project as allowing merge only if merge_when_pipeline_succeeds' do
project = attributes_for(:project, { only_allow_merge_if_build_succeeds: true }) project = attributes_for(:project, { only_allow_merge_if_build_succeeds: true })
post v3_api("/projects/user/#{user.id}", admin), project post v3_api("/projects/user/#{user.id}", admin), project
expect(json_response['only_allow_merge_if_build_succeeds']).to be_truthy expect(json_response['only_allow_merge_if_build_succeeds']).to be_truthy
...@@ -669,7 +669,7 @@ describe API::V3::Projects, api: true do ...@@ -669,7 +669,7 @@ describe API::V3::Projects, api: true do
expect(json_response['shared_with_groups'][0]['group_id']).to eq(group.id) expect(json_response['shared_with_groups'][0]['group_id']).to eq(group.id)
expect(json_response['shared_with_groups'][0]['group_name']).to eq(group.name) expect(json_response['shared_with_groups'][0]['group_name']).to eq(group.name)
expect(json_response['shared_with_groups'][0]['group_access_level']).to eq(link.group_access) expect(json_response['shared_with_groups'][0]['group_access_level']).to eq(link.group_access)
expect(json_response['only_allow_merge_if_build_succeeds']).to eq(project.only_allow_merge_if_build_succeeds) expect(json_response['only_allow_merge_if_build_succeeds']).to eq(project.only_allow_merge_if_pipeline_succeeds)
expect(json_response['only_allow_merge_if_all_discussions_are_resolved']).to eq(project.only_allow_merge_if_all_discussions_are_resolved) expect(json_response['only_allow_merge_if_all_discussions_are_resolved']).to eq(project.only_allow_merge_if_all_discussions_are_resolved)
end end
......
...@@ -341,7 +341,7 @@ describe Ci::ProcessPipelineService, :services do ...@@ -341,7 +341,7 @@ describe Ci::ProcessPipelineService, :services do
expect(builds.pending.count).to eq(1) expect(builds.pending.count).to eq(1)
expect(all_builds.count).to eq(4) expect(all_builds.count).to eq(4)
# When pending build succeeds in stage test, we enqueue deploy stage. # When pending merge_when_pipeline_succeeds in stage test, we enqueue deploy stage.
# #
succeed_pending succeed_pending
process_pipeline process_pipeline
......
...@@ -5,7 +5,7 @@ describe MergeRequests::MergeWhenPipelineSucceedsService do ...@@ -5,7 +5,7 @@ describe MergeRequests::MergeWhenPipelineSucceedsService do
let(:project) { create(:project) } let(:project) { create(:project) }
let(:mr_merge_if_green_enabled) do let(:mr_merge_if_green_enabled) do
create(:merge_request, merge_when_build_succeeds: true, merge_user: user, create(:merge_request, merge_when_pipeline_succeeds: true, merge_user: user,
source_branch: "master", target_branch: 'feature', source_branch: "master", target_branch: 'feature',
source_project: project, target_project: project, state: "opened") source_project: project, target_project: project, state: "opened")
end end
...@@ -36,7 +36,7 @@ describe MergeRequests::MergeWhenPipelineSucceedsService do ...@@ -36,7 +36,7 @@ describe MergeRequests::MergeWhenPipelineSucceedsService do
it 'sets the params, merge_user, and flag' do it 'sets the params, merge_user, and flag' do
expect(merge_request).to be_valid expect(merge_request).to be_valid
expect(merge_request.merge_when_build_succeeds).to be_truthy expect(merge_request.merge_when_pipeline_succeeds).to be_truthy
expect(merge_request.merge_params).to eq commit_message: 'Awesome message' expect(merge_request.merge_params).to eq commit_message: 'Awesome message'
expect(merge_request.merge_user).to be user expect(merge_request.merge_user).to be user
end end
...@@ -62,7 +62,7 @@ describe MergeRequests::MergeWhenPipelineSucceedsService do ...@@ -62,7 +62,7 @@ describe MergeRequests::MergeWhenPipelineSucceedsService do
end end
it 'updates the merge params' do it 'updates the merge params' do
expect(SystemNoteService).not_to receive(:merge_when_build_succeeds) expect(SystemNoteService).not_to receive(:merge_when_pipeline_succeeds)
service.execute(mr_merge_if_green_enabled) service.execute(mr_merge_if_green_enabled)
expect(mr_merge_if_green_enabled.merge_params).to have_key(:new_key) expect(mr_merge_if_green_enabled.merge_params).to have_key(:new_key)
...@@ -82,7 +82,7 @@ describe MergeRequests::MergeWhenPipelineSucceedsService do ...@@ -82,7 +82,7 @@ describe MergeRequests::MergeWhenPipelineSucceedsService do
sha: merge_request_head, status: 'success') sha: merge_request_head, status: 'success')
end end
it "merges all merge requests with merge when build succeeds enabled" do it "merges all merge requests with merge when the pipeline succeeds enabled" do
expect(MergeWorker).to receive(:perform_async) expect(MergeWorker).to receive(:perform_async)
service.trigger(triggering_pipeline) service.trigger(triggering_pipeline)
end end
...@@ -114,7 +114,7 @@ describe MergeRequests::MergeWhenPipelineSucceedsService do ...@@ -114,7 +114,7 @@ describe MergeRequests::MergeWhenPipelineSucceedsService do
context 'when the merge request is not mergeable' do context 'when the merge request is not mergeable' do
let(:mr_conflict) do let(:mr_conflict) do
create(:merge_request, merge_when_build_succeeds: true, merge_user: user, create(:merge_request, merge_when_pipeline_succeeds: true, merge_user: user,
source_branch: 'master', target_branch: 'feature-conflict', source_branch: 'master', target_branch: 'feature-conflict',
source_project: project, target_project: project) source_project: project, target_project: project)
end end
...@@ -143,8 +143,8 @@ describe MergeRequests::MergeWhenPipelineSucceedsService do ...@@ -143,8 +143,8 @@ describe MergeRequests::MergeWhenPipelineSucceedsService do
service.cancel(mr_merge_if_green_enabled) service.cancel(mr_merge_if_green_enabled)
end end
it "resets all the merge_when_build_succeeds params" do it "resets all the pipeline succeeds params" do
expect(mr_merge_if_green_enabled.merge_when_build_succeeds).to be_falsey expect(mr_merge_if_green_enabled.merge_when_pipeline_succeeds).to be_falsey
expect(mr_merge_if_green_enabled.merge_params).to eq({}) expect(mr_merge_if_green_enabled.merge_params).to eq({})
expect(mr_merge_if_green_enabled.merge_user).to be nil expect(mr_merge_if_green_enabled.merge_user).to be nil
end end
......
...@@ -18,7 +18,7 @@ describe MergeRequests::RefreshService, services: true do ...@@ -18,7 +18,7 @@ describe MergeRequests::RefreshService, services: true do
source_branch: 'master', source_branch: 'master',
target_branch: 'feature', target_branch: 'feature',
target_project: @project, target_project: @project,
merge_when_build_succeeds: true, merge_when_pipeline_succeeds: true,
merge_user: @user) merge_user: @user)
@fork_merge_request = create(:merge_request, @fork_merge_request = create(:merge_request,
...@@ -62,7 +62,7 @@ describe MergeRequests::RefreshService, services: true do ...@@ -62,7 +62,7 @@ describe MergeRequests::RefreshService, services: true do
it { expect(@merge_request.notes).not_to be_empty } it { expect(@merge_request.notes).not_to be_empty }
it { expect(@merge_request).to be_open } it { expect(@merge_request).to be_open }
it { expect(@merge_request.merge_when_build_succeeds).to be_falsey } it { expect(@merge_request.merge_when_pipeline_succeeds).to be_falsey }
it { expect(@merge_request.diff_head_sha).to eq(@newrev) } it { expect(@merge_request.diff_head_sha).to eq(@newrev) }
it { expect(@fork_merge_request).to be_open } it { expect(@fork_merge_request).to be_open }
it { expect(@fork_merge_request.notes).to be_empty } it { expect(@fork_merge_request.notes).to be_empty }
......
...@@ -1050,22 +1050,22 @@ describe NotificationService, services: true do ...@@ -1050,22 +1050,22 @@ describe NotificationService, services: true do
should_not_email(@u_lazy_participant) should_not_email(@u_lazy_participant)
end end
it "notifies the merger when merge_when_build_succeeds is true" do it "notifies the merger when the pipeline succeeds is true" do
merge_request.merge_when_build_succeeds = true merge_request.merge_when_pipeline_succeeds = true
notification.merge_mr(merge_request, @u_watcher) notification.merge_mr(merge_request, @u_watcher)
should_email(@u_watcher) should_email(@u_watcher)
end end
it "does not notify the merger when merge_when_build_succeeds is false" do it "does not notify the merger when the pipeline succeeds is false" do
merge_request.merge_when_build_succeeds = false merge_request.merge_when_pipeline_succeeds = false
notification.merge_mr(merge_request, @u_watcher) notification.merge_mr(merge_request, @u_watcher)
should_not_email(@u_watcher) should_not_email(@u_watcher)
end end
it "notifies the merger when merge_when_build_succeeds is false but they've opted into notifications about their activity" do it "notifies the merger when the pipeline succeeds is false but they've opted into notifications about their activity" do
merge_request.merge_when_build_succeeds = false merge_request.merge_when_pipeline_succeeds = false
@u_watcher.notified_of_own_activity = true @u_watcher.notified_of_own_activity = true
notification.merge_mr(merge_request, @u_watcher) notification.merge_mr(merge_request, @u_watcher)
......
...@@ -215,13 +215,13 @@ describe SystemNoteService, services: true do ...@@ -215,13 +215,13 @@ describe SystemNoteService, services: true do
end end
end end
describe '.merge_when_build_succeeds' do describe '.merge_when_pipeline_succeeds' do
let(:pipeline) { build(:ci_pipeline_without_jobs )} let(:pipeline) { build(:ci_pipeline_without_jobs )}
let(:noteable) do let(:noteable) do
create(:merge_request, source_project: project, target_project: project) create(:merge_request, source_project: project, target_project: project)
end end
subject { described_class.merge_when_build_succeeds(noteable, project, author, noteable.diff_head_commit) } subject { described_class.merge_when_pipeline_succeeds(noteable, project, author, noteable.diff_head_commit) }
it_behaves_like 'a system note' it_behaves_like 'a system note'
...@@ -230,12 +230,12 @@ describe SystemNoteService, services: true do ...@@ -230,12 +230,12 @@ describe SystemNoteService, services: true do
end end
end end
describe '.cancel_merge_when_build_succeeds' do describe '.cancel_merge_when_pipeline_succeeds' do
let(:noteable) do let(:noteable) do
create(:merge_request, source_project: project, target_project: project) create(:merge_request, source_project: project, target_project: project)
end end
subject { described_class.cancel_merge_when_build_succeeds(noteable, project, author) } subject { described_class.cancel_merge_when_pipeline_succeeds(noteable, project, author) }
it_behaves_like 'a system note' it_behaves_like 'a system note'
......
...@@ -680,7 +680,7 @@ describe TodoService, services: true do ...@@ -680,7 +680,7 @@ describe TodoService, services: true do
end end
it 'creates a pending todo for merge_user' do it 'creates a pending todo for merge_user' do
mr_unassigned.update(merge_when_build_succeeds: true, merge_user: admin) mr_unassigned.update(merge_when_pipeline_succeeds: true, merge_user: admin)
service.merge_request_build_failed(mr_unassigned) service.merge_request_build_failed(mr_unassigned)
should_create_todo(user: admin, author: admin, target: mr_unassigned, action: Todo::BUILD_FAILED) should_create_todo(user: admin, author: admin, target: mr_unassigned, action: Todo::BUILD_FAILED)
...@@ -700,7 +700,7 @@ describe TodoService, services: true do ...@@ -700,7 +700,7 @@ describe TodoService, services: true do
describe '#merge_request_became_unmergeable' do describe '#merge_request_became_unmergeable' do
it 'creates a pending todo for a merge_user' do it 'creates a pending todo for a merge_user' do
mr_unassigned.update(merge_when_build_succeeds: true, merge_user: admin) mr_unassigned.update(merge_when_pipeline_succeeds: true, merge_user: admin)
service.merge_request_became_unmergeable(mr_unassigned) service.merge_request_became_unmergeable(mr_unassigned)
should_create_todo(user: admin, author: admin, target: mr_unassigned, action: Todo::UNMERGEABLE) should_create_todo(user: admin, author: admin, target: mr_unassigned, action: Todo::UNMERGEABLE)
......
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