summaryrefslogtreecommitdiff
path: root/app/models/merge_request.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/merge_request.rb')
-rw-r--r--app/models/merge_request.rb22
1 files changed, 15 insertions, 7 deletions
diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb
index b9acb539404..9939167e74f 100644
--- a/app/models/merge_request.rb
+++ b/app/models/merge_request.rb
@@ -167,20 +167,22 @@ class MergeRequest < ApplicationRecord
end
event :mark_as_checking do
- transition [:unchecked, :cannot_be_merged_recheck] => :checking
+ transition unchecked: :checking
+ transition cannot_be_merged_recheck: :cannot_be_merged_rechecking
end
event :mark_as_mergeable do
- transition [:unchecked, :cannot_be_merged_recheck, :checking] => :can_be_merged
+ transition [:unchecked, :cannot_be_merged_recheck, :checking, :cannot_be_merged_rechecking] => :can_be_merged
end
event :mark_as_unmergeable do
- transition [:unchecked, :cannot_be_merged_recheck, :checking] => :cannot_be_merged
+ transition [:unchecked, :cannot_be_merged_recheck, :checking, :cannot_be_merged_rechecking] => :cannot_be_merged
end
state :unchecked
state :cannot_be_merged_recheck
state :checking
+ state :cannot_be_merged_rechecking
state :can_be_merged
state :cannot_be_merged
@@ -189,7 +191,7 @@ class MergeRequest < ApplicationRecord
end
# rubocop: disable CodeReuse/ServiceClass
- after_transition unchecked: :cannot_be_merged do |merge_request, transition|
+ after_transition [:unchecked, :checking] => :cannot_be_merged do |merge_request, transition|
if merge_request.notify_conflict?
NotificationService.new.merge_request_unmergeable(merge_request)
TodoService.new.merge_request_became_unmergeable(merge_request)
@@ -202,6 +204,12 @@ class MergeRequest < ApplicationRecord
end
end
+ # Returns current merge_status except it returns `cannot_be_merged_rechecking` as `checking`
+ # to avoid exposing unnecessary internal state
+ def public_merge_status
+ cannot_be_merged_rechecking? ? 'checking' : merge_status
+ end
+
validates :source_project, presence: true, unless: [:allow_broken, :importing?, :closed_without_fork?]
validates :source_branch, presence: true
validates :target_project, presence: true
@@ -569,13 +577,13 @@ class MergeRequest < ApplicationRecord
merge_request_diff&.real_size || diff_stats&.real_size || diffs.real_size
end
- def modified_paths(past_merge_request_diff: nil)
+ def modified_paths(past_merge_request_diff: nil, fallback_on_overflow: false)
if past_merge_request_diff
- past_merge_request_diff.modified_paths
+ past_merge_request_diff.modified_paths(fallback_on_overflow: fallback_on_overflow)
elsif compare
diff_stats&.paths || compare.modified_paths
else
- merge_request_diff.modified_paths
+ merge_request_diff.modified_paths(fallback_on_overflow: fallback_on_overflow)
end
end