summaryrefslogtreecommitdiff
path: root/app/models/suggestion.rb
diff options
context:
space:
mode:
authorOswaldo Ferreira <oswaldo@gitlab.com>2019-01-10 10:38:15 -0200
committerOswaldo Ferreira <oswaldo@gitlab.com>2019-01-11 21:35:07 -0200
commit6e293681180870e16cb102817dd588b0357cabca (patch)
tree9c0bc2528d35e32f00287ec6509baa2e15874182 /app/models/suggestion.rb
parent49f538c766f3b4f8fb7436afd472f88291a7c76e (diff)
downloadgitlab-ce-6e293681180870e16cb102817dd588b0357cabca.tar.gz
Adjust applied suggestion reverting previous changes
1. Avoid suggestions being applied on the same file from reverting previous changes 2. Gracefully use and handle file changes error when updating the file (though, it does not totally solves the sync problem for multiple suggestion applications at once)
Diffstat (limited to 'app/models/suggestion.rb')
-rw-r--r--app/models/suggestion.rb12
1 files changed, 10 insertions, 2 deletions
diff --git a/app/models/suggestion.rb b/app/models/suggestion.rb
index c76b8e71507..7eee4fbbe5f 100644
--- a/app/models/suggestion.rb
+++ b/app/models/suggestion.rb
@@ -5,8 +5,7 @@ class Suggestion < ApplicationRecord
validates :note, presence: true
validates :commit_id, presence: true, if: :applied?
- delegate :original_position, :position, :diff_file,
- :noteable, to: :note
+ delegate :original_position, :position, :noteable, to: :note
def project
noteable.source_project
@@ -16,6 +15,15 @@ class Suggestion < ApplicationRecord
noteable.source_branch
end
+ def file_path
+ position.file_path
+ end
+
+ def diff_file
+ repository = project.repository
+ position.diff_file(repository)
+ end
+
# For now, suggestions only serve as a way to send patches that
# will change a single line (being able to apply multiple in the same place),
# which explains `from_line` and `to_line` being the same line.