summaryrefslogtreecommitdiff
path: root/app/models/suggestion.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-08-20 18:42:06 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-08-20 18:42:06 +0000
commit6e4e1050d9dba2b7b2523fdd1768823ab85feef4 (patch)
tree78be5963ec075d80116a932011d695dd33910b4e /app/models/suggestion.rb
parent1ce776de4ae122aba3f349c02c17cebeaa8ecf07 (diff)
downloadgitlab-ce-6e4e1050d9dba2b7b2523fdd1768823ab85feef4.tar.gz
Add latest changes from gitlab-org/gitlab@13-3-stable-ee
Diffstat (limited to 'app/models/suggestion.rb')
-rw-r--r--app/models/suggestion.rb22
1 files changed, 15 insertions, 7 deletions
diff --git a/app/models/suggestion.rb b/app/models/suggestion.rb
index 94f3a140098..8c72bd5ae7e 100644
--- a/app/models/suggestion.rb
+++ b/app/models/suggestion.rb
@@ -43,12 +43,12 @@ class Suggestion < ApplicationRecord
def inapplicable_reason(cached: true)
strong_memoize("inapplicable_reason_#{cached}") do
- next :applied if applied?
- next :merge_request_merged if noteable.merged?
- next :merge_request_closed if noteable.closed?
- next :source_branch_deleted unless noteable.source_branch_exists?
- next :outdated if outdated?(cached: cached) || !note.active?
- next :same_content unless different_content?
+ next _("Can't apply this suggestion.") if applied?
+ next _("This merge request was merged. To apply this suggestion, edit this file directly.") if noteable.merged?
+ next _("This merge request is closed. To apply this suggestion, edit this file directly.") if noteable.closed?
+ next _("Can't apply as the source branch was deleted.") unless noteable.source_branch_exists?
+ next outdated_reason if outdated?(cached: cached) || !note.active?
+ next _("This suggestion already matches its content.") unless different_content?
end
end
@@ -61,7 +61,7 @@ class Suggestion < ApplicationRecord
end
def single_line?
- lines_above.zero? && lines_below.zero?
+ lines_above == 0 && lines_below == 0
end
def target_line
@@ -73,4 +73,12 @@ class Suggestion < ApplicationRecord
def different_content?
from_content != to_content
end
+
+ def outdated_reason
+ if single_line?
+ _("Can't apply as this line was changed in a more recent version.")
+ else
+ _("Can't apply as these lines were changed in a more recent version.")
+ end
+ end
end