debian-mirror-gitlab/app/services/note_summary.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

29 lines
824 B
Ruby
Raw Normal View History

2018-11-18 11:00:15 +05:30
# frozen_string_literal: true
2017-08-17 22:00:37 +05:30
class NoteSummary
attr_reader :note
attr_reader :metadata
2022-07-23 23:45:48 +05:30
def initialize(noteable, project, author, body, action: nil, commit_count: nil, created_at: nil)
2019-07-31 22:56:46 +05:30
@note = { noteable: noteable,
2022-07-23 23:45:48 +05:30
created_at: created_at || noteable.system_note_timestamp,
2019-07-31 22:56:46 +05:30
project: project, author: author, note: body }
2017-08-17 22:00:37 +05:30
@metadata = { action: action, commit_count: commit_count }.compact
2019-12-21 20:55:43 +05:30
if action == 'description' && noteable.saved_description_version
@metadata[:description_version] = noteable.saved_description_version
end
2017-08-17 22:00:37 +05:30
set_commit_params if note[:noteable].is_a?(Commit)
end
def metadata?
metadata.present?
end
def set_commit_params
note.merge!(noteable_type: 'Commit', commit_id: note[:noteable].id)
note[:noteable] = nil
end
end