Commit df3caf52 authored by Sean McGivern's avatar Sean McGivern

Merge branch '330278-migrate-wip_-methods-to-draft_methods' into 'master'

Alias wip* methods to -> draft*

See merge request gitlab-org/gitlab!79797
parents 7c92ae6f 90065a2b
...@@ -580,7 +580,7 @@ module Issuable ...@@ -580,7 +580,7 @@ module Issuable
## ##
# Overridden in MergeRequest # Overridden in MergeRequest
# #
def wipless_title_changed(old_title) def draftless_title_changed(old_title)
old_title != title old_title != title
end end
end end
......
...@@ -563,16 +563,22 @@ class MergeRequest < ApplicationRecord ...@@ -563,16 +563,22 @@ class MergeRequest < ApplicationRecord
DRAFT_REGEX = /\A*#{Gitlab::Regex.merge_request_draft}+\s*/i.freeze DRAFT_REGEX = /\A*#{Gitlab::Regex.merge_request_draft}+\s*/i.freeze
def self.work_in_progress?(title) def self.draft?(title)
!!(title =~ DRAFT_REGEX) !!(title =~ DRAFT_REGEX)
end end
def self.wipless_title(title) def self.draftless_title(title)
title.sub(DRAFT_REGEX, "") title.sub(DRAFT_REGEX, "")
end end
def self.wip_title(title) def self.draft_title(title)
work_in_progress?(title) ? title : "Draft: #{title}" draft?(title) ? title : "Draft: #{title}"
end
class << self
alias_method :work_in_progress?, :draft?
alias_method :wipless_title, :draftless_title
alias_method :wip_title, :draft_title
end end
def self.participant_includes def self.participant_includes
...@@ -585,9 +591,10 @@ class MergeRequest < ApplicationRecord ...@@ -585,9 +591,10 @@ class MergeRequest < ApplicationRecord
# Verifies if title has changed not taking into account Draft prefix # Verifies if title has changed not taking into account Draft prefix
# for merge requests. # for merge requests.
def wipless_title_changed(old_title) def draftless_title_changed(old_title)
self.class.wipless_title(old_title) != self.wipless_title self.class.draftless_title(old_title) != self.draftless_title
end end
alias_method :wipless_title_changed, :draftless_title_changed
def hook_attrs def hook_attrs
Gitlab::HookData::MergeRequestBuilder.new(self).build Gitlab::HookData::MergeRequestBuilder.new(self).build
...@@ -1086,18 +1093,20 @@ class MergeRequest < ApplicationRecord ...@@ -1086,18 +1093,20 @@ class MergeRequest < ApplicationRecord
@closed_event ||= target_project.events.where(target_id: self.id, target_type: "MergeRequest", action: :closed).last @closed_event ||= target_project.events.where(target_id: self.id, target_type: "MergeRequest", action: :closed).last
end end
def work_in_progress? def draft?
self.class.work_in_progress?(title) self.class.draft?(title)
end end
alias_method :draft?, :work_in_progress? alias_method :work_in_progress?, :draft?
def wipless_title def draftless_title
self.class.wipless_title(self.title) self.class.draftless_title(self.title)
end end
alias_method :wipless_title, :draftless_title
def wip_title def draft_title
self.class.wip_title(self.title) self.class.draft_title(self.title)
end end
alias_method :wip_title, :draft_title
def mergeable?(skip_ci_check: false, skip_discussions_check: false) def mergeable?(skip_ci_check: false, skip_discussions_check: false)
return false unless mergeable_state?(skip_ci_check: skip_ci_check, return false unless mergeable_state?(skip_ci_check: skip_ci_check,
......
...@@ -71,7 +71,7 @@ module Issuable ...@@ -71,7 +71,7 @@ module Issuable
def create_title_change_note(old_title) def create_title_change_note(old_title)
create_draft_note(old_title) create_draft_note(old_title)
if issuable.wipless_title_changed(old_title) if issuable.draftless_title_changed(old_title)
SystemNoteService.change_title(issuable, issuable.project, current_user, old_title) SystemNoteService.change_title(issuable, issuable.project, current_user, old_title)
end end
end end
......
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