Commit 85349c96 authored by Sean McGivern's avatar Sean McGivern

Merge branch '27886_rebasing_fix' into 'master'

Mark as WIP based on MR commits only

Closes #27886

See merge request !9085
parents 54c4e4d7 c7b425a3
...@@ -144,7 +144,11 @@ module MergeRequests ...@@ -144,7 +144,11 @@ module MergeRequests
return unless @commits.present? return unless @commits.present?
merge_requests_for_source_branch.each do |merge_request| merge_requests_for_source_branch.each do |merge_request|
wip_commit = @commits.detect(&:work_in_progress?) commit_shas = merge_request.commits_sha
wip_commit = @commits.detect do |commit|
commit.work_in_progress? && commit_shas.include?(commit.sha)
end
if wip_commit && !merge_request.work_in_progress? if wip_commit && !merge_request.work_in_progress?
merge_request.update(title: merge_request.wip_title) merge_request.update(title: merge_request.wip_title)
......
...@@ -287,41 +287,64 @@ describe MergeRequests::RefreshService, services: true do ...@@ -287,41 +287,64 @@ describe MergeRequests::RefreshService, services: true do
it 'references the commit that caused the Work in Progress status' do it 'references the commit that caused the Work in Progress status' do
refresh_service.execute(@oldrev, @newrev, 'refs/heads/master') refresh_service.execute(@oldrev, @newrev, 'refs/heads/master')
allow(refresh_service).to receive(:find_new_commits) allow(refresh_service).to receive(:find_new_commits)
refresh_service.instance_variable_set("@commits", [ refresh_service.instance_variable_set("@commits", [
instance_double( double(
Commit,
id: 'aaaaaaa', id: 'aaaaaaa',
sha: '38008cb17ce1466d8fec2dfa6f6ab8dcfe5cf49e',
short_id: 'aaaaaaa', short_id: 'aaaaaaa',
title: 'Fix issue', title: 'Fix issue',
work_in_progress?: false work_in_progress?: false
), ),
instance_double( double(
Commit,
id: 'bbbbbbb', id: 'bbbbbbb',
sha: '498214de67004b1da3d820901307bed2a68a8ef6',
short_id: 'bbbbbbb', short_id: 'bbbbbbb',
title: 'fixup! Fix issue', title: 'fixup! Fix issue',
work_in_progress?: true, work_in_progress?: true,
to_reference: 'bbbbbbb' to_reference: 'bbbbbbb'
), ),
instance_double( double(
Commit,
id: 'ccccccc', id: 'ccccccc',
sha: '1b12f15a11fc6e62177bef08f47bc7b5ce50b141',
short_id: 'ccccccc', short_id: 'ccccccc',
title: 'fixup! Fix issue', title: 'fixup! Fix issue',
work_in_progress?: true, work_in_progress?: true,
to_reference: 'ccccccc' to_reference: 'ccccccc'
), ),
]) ])
refresh_service.execute(@oldrev, @newrev, 'refs/heads/wip') refresh_service.execute(@oldrev, @newrev, 'refs/heads/wip')
reload_mrs reload_mrs
expect(@merge_request.notes.last.note).to eq( expect(@merge_request.notes.last.note).to eq(
"marked as a **Work In Progress** from bbbbbbb" "marked as a **Work In Progress** from bbbbbbb"
) )
end end
it 'does not mark as WIP based on commits that do not belong to an MR' do
allow(refresh_service).to receive(:find_new_commits)
refresh_service.instance_variable_set("@commits", [
double(
id: 'aaaaaaa',
sha: 'aaaaaaa',
short_id: 'aaaaaaa',
title: 'Fix issue',
work_in_progress?: false
),
double(
id: 'bbbbbbb',
sha: 'bbbbbbbb',
short_id: 'bbbbbbb',
title: 'fixup! Fix issue',
work_in_progress?: true,
to_reference: 'bbbbbbb'
)
])
refresh_service.execute(@oldrev, @newrev, 'refs/heads/master')
reload_mrs
expect(@merge_request.work_in_progress?).to be_falsey
end
end end
def reload_mrs def reload_mrs
......
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