Backport changes from EE squash
Backport changes from the EE-only squash implementation, which would otherwise conflict when merge CE into EE. <https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/1024>
This commit is contained in:
parent
fd46fb1cd9
commit
7550f60dde
13 changed files with 76 additions and 29 deletions
|
@ -56,15 +56,24 @@
|
|||
&.right {
|
||||
float: right;
|
||||
padding-right: 0;
|
||||
|
||||
a {
|
||||
color: $gl-text-color;
|
||||
}
|
||||
}
|
||||
|
||||
.remove_source_checkbox {
|
||||
.modify-merge-commit-link {
|
||||
color: $gl-text-color;
|
||||
}
|
||||
|
||||
.merge-param-checkbox {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
a .fa-question-circle {
|
||||
color: $gl-text-color-secondary;
|
||||
|
||||
&:hover,
|
||||
&:focus {
|
||||
color: $link-hover-color;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -143,4 +143,16 @@ module MergeRequestsHelper
|
|||
def different_base?(version1, version2)
|
||||
version1 && version2 && version1.base_commit_sha != version2.base_commit_sha
|
||||
end
|
||||
|
||||
def merge_params(merge_request)
|
||||
{
|
||||
merge_when_build_succeeds: true,
|
||||
should_remove_source_branch: true,
|
||||
sha: merge_request.diff_head_sha
|
||||
}.merge(merge_params_ee(merge_request))
|
||||
end
|
||||
|
||||
def merge_params_ee(merge_request)
|
||||
{}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -913,11 +913,11 @@ class Repository
|
|||
end
|
||||
end
|
||||
|
||||
def merge(user, merge_request, options = {})
|
||||
def merge(user, source, merge_request, options = {})
|
||||
GitOperationService.new(user, self).with_branch(
|
||||
merge_request.target_branch) do |start_commit|
|
||||
our_commit = start_commit.sha
|
||||
their_commit = merge_request.diff_head_sha
|
||||
their_commit = source
|
||||
|
||||
raise 'Invalid merge target' unless our_commit
|
||||
raise 'Invalid merge source' unless their_commit
|
||||
|
|
|
@ -6,13 +6,17 @@ module MergeRequests
|
|||
# Executed when you do merge via GitLab UI
|
||||
#
|
||||
class MergeService < MergeRequests::BaseService
|
||||
attr_reader :merge_request
|
||||
attr_reader :merge_request, :source
|
||||
|
||||
def execute(merge_request)
|
||||
@merge_request = merge_request
|
||||
|
||||
return log_merge_error('Merge request is not mergeable', true) unless @merge_request.mergeable?
|
||||
|
||||
@source = find_merge_source
|
||||
|
||||
return log_merge_error('No source for merge', true) unless @source
|
||||
|
||||
merge_request.in_locked_state do
|
||||
if commit
|
||||
after_merge
|
||||
|
@ -34,7 +38,7 @@ module MergeRequests
|
|||
committer: committer
|
||||
}
|
||||
|
||||
commit_id = repository.merge(current_user, merge_request, options)
|
||||
commit_id = repository.merge(current_user, source, merge_request, options)
|
||||
|
||||
if commit_id
|
||||
merge_request.update(merge_commit_sha: commit_id)
|
||||
|
@ -73,9 +77,11 @@ module MergeRequests
|
|||
end
|
||||
|
||||
def merge_request_info
|
||||
project = merge_request.project
|
||||
merge_request.to_reference(full: true)
|
||||
end
|
||||
|
||||
"#{project.to_reference}#{merge_request.to_reference}"
|
||||
def find_merge_source
|
||||
merge_request.diff_head_sha
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -35,10 +35,10 @@
|
|||
The source branch will be removed.
|
||||
- elsif @merge_request.can_remove_source_branch?(current_user)
|
||||
.accept-control.checkbox
|
||||
= label_tag :should_remove_source_branch, class: "remove_source_checkbox" do
|
||||
= label_tag :should_remove_source_branch, class: "merge-param-checkbox" do
|
||||
= check_box_tag :should_remove_source_branch
|
||||
Remove source branch
|
||||
.accept-control.right
|
||||
.accept-control
|
||||
= link_to "#", class: "modify-merge-commit-link js-toggle-button" do
|
||||
= icon('edit')
|
||||
Modify commit message
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
- if remove_source_branch_button || user_can_cancel_automatic_merge
|
||||
.clearfix.prepend-top-10
|
||||
- if remove_source_branch_button
|
||||
= link_to merge_namespace_project_merge_request_path(@merge_request.target_project.namespace, @merge_request.target_project, @merge_request, merge_when_build_succeeds: true, should_remove_source_branch: true, sha: @merge_request.diff_head_sha), remote: true, method: :post, class: "btn btn-grouped btn-primary btn-sm remove_source_branch" do
|
||||
= link_to merge_namespace_project_merge_request_path(@merge_request.target_project.namespace, @merge_request.target_project, @merge_request, merge_params(@merge_request)), remote: true, method: :post, class: "btn btn-grouped btn-primary btn-sm remove_source_branch" do
|
||||
= icon('times')
|
||||
Remove Source Branch When Merged
|
||||
|
||||
|
|
|
@ -43,6 +43,8 @@
|
|||
|
||||
= render 'shared/issuable/form/branch_chooser', issuable: issuable, form: form
|
||||
|
||||
= render 'shared/issuable/form/merge_params', issuable: issuable
|
||||
|
||||
- if @merge_request_for_resolving_discussions
|
||||
.form-group
|
||||
.col-sm-10.col-sm-offset-2
|
||||
|
|
|
@ -19,12 +19,3 @@
|
|||
- if issuable.new_record?
|
||||
|
||||
= link_to 'Change branches', mr_change_branches_path(issuable)
|
||||
|
||||
- if issuable.can_remove_source_branch?(current_user)
|
||||
.form-group
|
||||
.col-sm-10.col-sm-offset-2
|
||||
.checkbox
|
||||
= label_tag 'merge_request[force_remove_source_branch]' do
|
||||
= hidden_field_tag 'merge_request[force_remove_source_branch]', '0', id: nil
|
||||
= check_box_tag 'merge_request[force_remove_source_branch]', '1', issuable.force_remove_source_branch?
|
||||
Remove source branch when merge request is accepted.
|
||||
|
|
16
app/views/shared/issuable/form/_merge_params.html.haml
Normal file
16
app/views/shared/issuable/form/_merge_params.html.haml
Normal file
|
@ -0,0 +1,16 @@
|
|||
- issuable = local_assigns.fetch(:issuable)
|
||||
|
||||
- return unless issuable.is_a?(MergeRequest)
|
||||
- return if issuable.closed_without_fork?
|
||||
|
||||
-# This check is duplicated below, to avoid conflicts with EE.
|
||||
- return unless issuable.can_remove_source_branch?(current_user)
|
||||
|
||||
.form-group
|
||||
.col-sm-10.col-sm-offset-2
|
||||
- if issuable.can_remove_source_branch?(current_user)
|
||||
.checkbox
|
||||
= label_tag 'merge_request[force_remove_source_branch]' do
|
||||
= hidden_field_tag 'merge_request[force_remove_source_branch]', '0', id: nil
|
||||
= check_box_tag 'merge_request[force_remove_source_branch]', '1', issuable.force_remove_source_branch?
|
||||
Remove source branch when merge request is accepted.
|
|
@ -1640,7 +1640,9 @@ describe Gitlab::Diff::PositionTracer, lib: true do
|
|||
}
|
||||
|
||||
merge_request = create(:merge_request, source_branch: second_create_file_commit.sha, target_branch: branch_name, source_project: project)
|
||||
repository.merge(current_user, merge_request, options)
|
||||
|
||||
repository.merge(current_user, merge_request.diff_head_sha, merge_request, options)
|
||||
|
||||
project.commit(branch_name)
|
||||
end
|
||||
|
||||
|
|
|
@ -15,7 +15,12 @@ describe Repository, models: true do
|
|||
|
||||
let(:merge_commit) do
|
||||
merge_request = create(:merge_request, source_branch: 'feature', target_branch: 'master', source_project: project)
|
||||
merge_commit_id = repository.merge(user, merge_request, commit_options)
|
||||
|
||||
merge_commit_id = repository.merge(user,
|
||||
merge_request.diff_head_sha,
|
||||
merge_request,
|
||||
commit_options)
|
||||
|
||||
repository.commit(merge_commit_id)
|
||||
end
|
||||
|
||||
|
@ -1082,8 +1087,11 @@ describe Repository, models: true do
|
|||
|
||||
it 'sets the `in_progress_merge_commit_sha` flag for the given merge request' do
|
||||
merge_request = create(:merge_request, source_branch: 'feature', target_branch: 'master', source_project: project)
|
||||
merge_commit_id = repository.merge(user, merge_request, commit_options)
|
||||
repository.commit(merge_commit_id)
|
||||
|
||||
merge_commit_id = repository.merge(user,
|
||||
merge_request.diff_head_sha,
|
||||
merge_request,
|
||||
commit_options)
|
||||
|
||||
expect(merge_request.in_progress_merge_commit_sha).to eq(merge_commit_id)
|
||||
end
|
||||
|
|
|
@ -89,7 +89,7 @@ describe MergeRequests::RefreshService, services: true do
|
|||
# Merge master -> feature branch
|
||||
author = { email: 'test@gitlab.com', time: Time.now, name: "Me" }
|
||||
commit_options = { message: 'Test message', committer: author, author: author }
|
||||
@project.repository.merge(@user, @merge_request, commit_options)
|
||||
@project.repository.merge(@user, @merge_request.diff_head_sha, @merge_request, commit_options)
|
||||
commit = @project.repository.commit('feature')
|
||||
service.new(@project, @user).execute(@oldrev, commit.id, 'refs/heads/feature')
|
||||
reload_mrs
|
||||
|
|
|
@ -36,7 +36,8 @@ module TestEnv
|
|||
'conflict-non-utf8' => 'd0a293c',
|
||||
'conflict-too-large' => '39fa04f',
|
||||
'deleted-image-test' => '6c17798',
|
||||
'wip' => 'b9238ee'
|
||||
'wip' => 'b9238ee',
|
||||
'csv' => '3dd0896'
|
||||
}
|
||||
|
||||
# gitlab-test-fork is a fork of gitlab-fork, but we don't necessarily
|
||||
|
|
Loading…
Reference in a new issue