Class: Suggestion
Constant Summary
Constants included
from Suggestible
Suggestible::MAX_LINES_CONTEXT
ApplicationRecord::MAX_PLUCK
HasCheckConstraints::NOT_NULL_CHECK_PATTERN
ResetOnColumnErrors::MAX_RESET_PERIOD
Instance Attribute Summary
Attributes included from Importable
#importing, #user_contributions
Instance Method Summary
collapse
#diff_lines, #fetch_from_content, #from_line, #to_line
===, cached_column_list, #create_or_load_association, current_transaction, declarative_enum, default_select_columns, delete_all_returning, #deleted_from_database?, id_in, id_not_in, iid_in, nullable_column?, primary_key_in, #readable_by?, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, #to_ability_name, underscore, where_exists, where_not_exists, with_fast_read_statement_timeout, without_order
#sharding_organization
#reset_on_union_error, #reset_on_unknown_attribute_error
#serializable_hash
Instance Method Details
#appliable?(cached: true) ⇒ Boolean
46
47
48
|
# File 'app/models/suggestion.rb', line 46
def appliable?(cached: true)
inapplicable_reason(cached: cached).nil?
end
|
#branch ⇒ Object
28
29
30
|
# File 'app/models/suggestion.rb', line 28
def branch
noteable.source_branch
end
|
#diff_file ⇒ Object
16
17
18
|
# File 'app/models/suggestion.rb', line 16
def diff_file
note.latest_diff_file
end
|
#file_path ⇒ Object
32
33
34
|
# File 'app/models/suggestion.rb', line 32
def file_path
position.file_path
end
|
#from_line_index ⇒ Object
from_line_index and to_line_index represents diff/blob line numbers in index-like way (N-1).
38
39
40
|
# File 'app/models/suggestion.rb', line 38
def from_line_index
from_line - 1
end
|
#inapplicable_reason(cached: true) ⇒ Object
50
51
52
53
54
55
56
57
58
59
60
|
# File 'app/models/suggestion.rb', line 50
def inapplicable_reason(cached: true)
strong_memoize("inapplicable_reason_#{cached}") do
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?
next _("This file was modified for readability, and can't accept suggestions. Edit it directly.") if file_path.end_with? "ipynb"
end
end
|
#outdated?(cached: true) ⇒ Boolean
Overwrites outdated column
63
64
65
66
67
68
|
# File 'app/models/suggestion.rb', line 63
def outdated?(cached: true)
return super() if cached
return true unless diff_file
from_content != fetch_from_content
end
|
#single_line? ⇒ Boolean
70
71
72
|
# File 'app/models/suggestion.rb', line 70
def single_line?
lines_above == 0 && lines_below == 0
end
|
#source_project ⇒ Object
20
21
22
|
# File 'app/models/suggestion.rb', line 20
def source_project
noteable.source_project
end
|
#target_line ⇒ Object
74
75
76
|
# File 'app/models/suggestion.rb', line 74
def target_line
position.new_line
end
|
#target_project ⇒ Object
24
25
26
|
# File 'app/models/suggestion.rb', line 24
def target_project
noteable.target_project
end
|
#to_line_index ⇒ Object
42
43
44
|
# File 'app/models/suggestion.rb', line 42
def to_line_index
to_line - 1
end
|