diff options
author | Simon Knox <psimyn@gmail.com> | 2017-12-08 23:13:14 +1100 |
---|---|---|
committer | Simon Knox <psimyn@gmail.com> | 2017-12-08 23:13:14 +1100 |
commit | 078ac22567b50a375a59faffad6d441e2d04c22b (patch) | |
tree | 8aaf6cf6112609aa8f9498a8d319e54593b68a69 /app/models/diff_note.rb | |
parent | e47c613d225a256e163af177c886624d81902014 (diff) | |
parent | 9429e8ac60a10436a0469d7d206d3f74a2c966c7 (diff) | |
download | gitlab-ce-psimyn-issue-note-rename.tar.gz |
Merge branch 'master' of gitlab.com:gitlab-org/gitlab-ce into psimyn-issue-note-renamepsimyn-issue-note-rename
Diffstat (limited to 'app/models/diff_note.rb')
-rw-r--r-- | app/models/diff_note.rb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/app/models/diff_note.rb b/app/models/diff_note.rb index ae5f138a920..b53d44cda95 100644 --- a/app/models/diff_note.rb +++ b/app/models/diff_note.rb @@ -17,6 +17,7 @@ class DiffNote < Note validates :noteable_type, inclusion: { in: NOTEABLE_TYPES } validate :positions_complete validate :verify_supported + validate :diff_refs_match_commit, if: :for_commit? before_validation :set_original_position, on: :create before_validation :update_position, on: :create, if: :on_text? @@ -135,6 +136,12 @@ class DiffNote < Note errors.add(:position, "is invalid") end + def diff_refs_match_commit + return if self.original_position.diff_refs == self.commit.diff_refs + + errors.add(:commit_id, 'does not match the diff refs') + end + def keep_around_commits project.repository.keep_around(self.original_position.base_sha) project.repository.keep_around(self.original_position.start_sha) |