diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-14 18:09:44 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-14 18:09:44 +0300 |
commit | 874ead9c3a50de4c4ca4551eaf5b7eb976d26b50 (patch) | |
tree | 637ee9f2da5e251bc08ebf3e972209d51966bf7c /app/models/diff_note_position.rb | |
parent | 2e4c4055181eec9186458dd5dd3219c937032ec7 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/diff_note_position.rb')
-rw-r--r-- | app/models/diff_note_position.rb | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/app/models/diff_note_position.rb b/app/models/diff_note_position.rb new file mode 100644 index 00000000000..78e4fbc49eb --- /dev/null +++ b/app/models/diff_note_position.rb @@ -0,0 +1,36 @@ +# frozen_string_literal: true + +class DiffNotePosition < ApplicationRecord + belongs_to :note + + enum diff_content_type: { + text: 0, + image: 1 + } + + enum diff_type: { + head: 0 + } + + def position + Gitlab::Diff::Position.new( + old_path: old_path, + new_path: new_path, + old_line: old_line, + new_line: new_line, + position_type: diff_content_type, + diff_refs: Gitlab::Diff::DiffRefs.new( + base_sha: base_sha, + start_sha: start_sha, + head_sha: head_sha + ) + ) + end + + def position=(position) + position_attrs = position.to_h + position_attrs[:diff_content_type] = position_attrs.delete(:position_type) + + assign_attributes(position_attrs) + end +end |