Commit 40ae45a9 authored by Dmitry Gruzd's avatar Dmitry Gruzd

Merge branch '330278-remove-wip-support-from-mrs-and-commits' into 'master'

Remove WIP support from Merge Requests

See merge request gitlab-org/gitlab!79693
parents e8a9e822 5f00c459
...@@ -561,9 +561,7 @@ class MergeRequest < ApplicationRecord ...@@ -561,9 +561,7 @@ class MergeRequest < ApplicationRecord
end end
end end
# WIP is deprecated in favor of Draft. Currently both options are supported DRAFT_REGEX = /\A*#{Gitlab::Regex.merge_request_draft}+\s*/i.freeze
# https://gitlab.com/gitlab-org/gitlab/-/issues/227426
DRAFT_REGEX = /\A*#{Regexp.union(Gitlab::Regex.merge_request_wip, Gitlab::Regex.merge_request_draft)}+\s*/i.freeze
def self.work_in_progress?(title) def self.work_in_progress?(title)
!!(title =~ DRAFT_REGEX) !!(title =~ DRAFT_REGEX)
......
...@@ -443,7 +443,7 @@ RSpec.describe Projects::MergeRequestsController do ...@@ -443,7 +443,7 @@ RSpec.describe Projects::MergeRequestsController do
context 'when the merge request is not mergeable' do context 'when the merge request is not mergeable' do
before do before do
merge_request.update!(title: "WIP: #{merge_request.title}") merge_request.update!(title: "Draft: #{merge_request.title}")
post :merge, params: base_params post :merge, params: base_params
end end
......
...@@ -2,13 +2,13 @@ ...@@ -2,13 +2,13 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe 'Merge request > User resolves Work in Progress', :js do RSpec.describe 'Merge request > User resolves Draft', :js do
let(:project) { create(:project, :public, :repository) } let(:project) { create(:project, :public, :repository) }
let(:user) { project.creator } let(:user) { project.creator }
let(:merge_request) do let(:merge_request) do
create(:merge_request_with_diffs, source_project: project, create(:merge_request_with_diffs, source_project: project,
author: user, author: user,
title: 'WIP: Bug NS-04', title: 'Draft: Bug NS-04',
merge_params: { force_remove_source_branch: '1' }) merge_params: { force_remove_source_branch: '1' })
end end
......
...@@ -1369,17 +1369,17 @@ RSpec.describe MergeRequest, factory_default: :keep do ...@@ -1369,17 +1369,17 @@ RSpec.describe MergeRequest, factory_default: :keep do
subject { build_stubbed(:merge_request) } subject { build_stubbed(:merge_request) }
[ [
'WIP:', 'WIP: ', '[WIP]', '[WIP] ', ' [WIP] WIP: [WIP] WIP:',
'draft:', 'Draft: ', '[Draft]', '[DRAFT] ' 'draft:', 'Draft: ', '[Draft]', '[DRAFT] '
].each do |wip_prefix| ].each do |draft_prefix|
it "detects the '#{wip_prefix}' prefix" do it "detects the '#{draft_prefix}' prefix" do
subject.title = "#{wip_prefix}#{subject.title}" subject.title = "#{draft_prefix}#{subject.title}"
expect(subject.work_in_progress?).to eq true expect(subject.work_in_progress?).to eq true
end end
end end
[ [
'WIP:', 'WIP: ', '[WIP]', '[WIP] ', ' [WIP] WIP: [WIP] WIP:',
"WIP ", "(WIP)", "WIP ", "(WIP)",
"draft", "Draft", "Draft -", "draft - ", "Draft ", "draft " "draft", "Draft", "Draft -", "draft - ", "Draft ", "draft "
].each do |draft_prefix| ].each do |draft_prefix|
...@@ -1390,10 +1390,10 @@ RSpec.describe MergeRequest, factory_default: :keep do ...@@ -1390,10 +1390,10 @@ RSpec.describe MergeRequest, factory_default: :keep do
end end
end end
it "detects merge request title just saying 'wip'" do it "doesn't detect merge request title just saying 'wip'" do
subject.title = "wip" subject.title = "wip"
expect(subject.work_in_progress?).to eq true expect(subject.work_in_progress?).to eq false
end end
it "does not detect merge request title just saying 'draft'" do it "does not detect merge request title just saying 'draft'" do
...@@ -1459,29 +1459,30 @@ RSpec.describe MergeRequest, factory_default: :keep do ...@@ -1459,29 +1459,30 @@ RSpec.describe MergeRequest, factory_default: :keep do
describe "#wipless_title" do describe "#wipless_title" do
subject { build_stubbed(:merge_request) } subject { build_stubbed(:merge_request) }
[ ['draft:', 'Draft: ', '[Draft]', '[DRAFT] '].each do |draft_prefix|
'WIP:', 'WIP: ', '[WIP]', '[WIP] ', '[WIP] WIP: [WIP] WIP:', it "removes a '#{draft_prefix}' prefix" do
'draft:', 'Draft: ', '[Draft]', '[DRAFT] '
].each do |wip_prefix|
it "removes the '#{wip_prefix}' prefix" do
wipless_title = subject.title wipless_title = subject.title
subject.title = "#{wip_prefix}#{subject.title}" subject.title = "#{draft_prefix}#{subject.title}"
expect(subject.wipless_title).to eq wipless_title expect(subject.wipless_title).to eq wipless_title
end end
it "is satisfies the #work_in_progress? method" do it "is satisfies the #work_in_progress? method" do
subject.title = "#{wip_prefix}#{subject.title}" subject.title = "#{draft_prefix}#{subject.title}"
subject.title = subject.wipless_title subject.title = subject.wipless_title
expect(subject.work_in_progress?).to eq false expect(subject.work_in_progress?).to eq false
end end
end end
it 'removes only WIP prefix from the MR title' do [
subject.title = 'WIP: Implement feature called WIP' 'WIP:', 'WIP: ', '[WIP]', '[WIP] ', '[WIP] WIP: [WIP] WIP:'
].each do |wip_prefix|
it "doesn't remove a '#{wip_prefix}' prefix" do
subject.title = "#{wip_prefix}#{subject.title}"
expect(subject.wipless_title).to eq 'Implement feature called WIP' expect(subject.wipless_title).to eq subject.title
end
end end
it 'removes only draft prefix from the MR title' do it 'removes only draft prefix from the MR title' do
......
...@@ -61,19 +61,19 @@ RSpec.describe MergeRequests::CreateService, :clean_gitlab_redis_shared_state do ...@@ -61,19 +61,19 @@ RSpec.describe MergeRequests::CreateService, :clean_gitlab_redis_shared_state do
expect(merge_request.reload).to be_preparing expect(merge_request.reload).to be_preparing
end end
describe 'when marked with /wip' do describe 'when marked with /draft' do
context 'in title and in description' do context 'in title and in description' do
let(:opts) do let(:opts) do
{ {
title: 'WIP: Awesome merge_request', title: 'Draft: Awesome merge_request',
description: "well this is not done yet\n/wip", description: "well this is not done yet\n/draft",
source_branch: 'feature', source_branch: 'feature',
target_branch: 'master', target_branch: 'master',
assignees: [user2] assignees: [user2]
} }
end end
it 'sets MR to WIP' do it 'sets MR to draft' do
expect(merge_request.work_in_progress?).to be(true) expect(merge_request.work_in_progress?).to be(true)
end end
end end
...@@ -89,7 +89,7 @@ RSpec.describe MergeRequests::CreateService, :clean_gitlab_redis_shared_state do ...@@ -89,7 +89,7 @@ RSpec.describe MergeRequests::CreateService, :clean_gitlab_redis_shared_state do
} }
end end
it 'sets MR to WIP' do it 'sets MR to draft' do
expect(merge_request.work_in_progress?).to be(true) expect(merge_request.work_in_progress?).to be(true)
end end
end end
......
...@@ -102,16 +102,16 @@ RSpec.describe MergeRequests::UpdateService, :mailer do ...@@ -102,16 +102,16 @@ RSpec.describe MergeRequests::UpdateService, :mailer do
MergeRequests::UpdateService.new(project: project, current_user: user, params: opts).execute(merge_request2) MergeRequests::UpdateService.new(project: project, current_user: user, params: opts).execute(merge_request2)
end end
it 'tracks Draft/WIP marking' do it 'tracks Draft marking' do
expect(Gitlab::UsageDataCounters::MergeRequestActivityUniqueCounter) expect(Gitlab::UsageDataCounters::MergeRequestActivityUniqueCounter)
.to receive(:track_marked_as_draft_action).once.with(user: user) .to receive(:track_marked_as_draft_action).once.with(user: user)
opts[:title] = "WIP: #{opts[:title]}" opts[:title] = "Draft: #{opts[:title]}"
MergeRequests::UpdateService.new(project: project, current_user: user, params: opts).execute(merge_request2) MergeRequests::UpdateService.new(project: project, current_user: user, params: opts).execute(merge_request2)
end end
it 'tracks Draft/WIP un-marking' do it 'tracks Draft un-marking' do
expect(Gitlab::UsageDataCounters::MergeRequestActivityUniqueCounter) expect(Gitlab::UsageDataCounters::MergeRequestActivityUniqueCounter)
.to receive(:track_unmarked_as_draft_action).once.with(user: user) .to receive(:track_unmarked_as_draft_action).once.with(user: user)
......
...@@ -325,11 +325,11 @@ RSpec.describe Notes::CreateService do ...@@ -325,11 +325,11 @@ RSpec.describe Notes::CreateService do
expect(issuable.work_in_progress?).to eq(can_use_quick_action) expect(issuable.work_in_progress?).to eq(can_use_quick_action)
} }
), ),
# Remove WIP status # Remove draft status
QuickAction.new( QuickAction.new(
action_text: "/draft", action_text: "/draft",
before_action: -> { before_action: -> {
issuable.reload.update!(title: "WIP: title") issuable.reload.update!(title: "Draft: title")
}, },
expectation: ->(noteable, can_use_quick_action) { expectation: ->(noteable, can_use_quick_action) {
expect(noteable.work_in_progress?).not_to eq(can_use_quick_action) expect(noteable.work_in_progress?).not_to eq(can_use_quick_action)
......
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