summaryrefslogtreecommitdiff
path: root/app/serializers/commit_entity.rb
blob: 396e95a03c80b48f0c14a89426c8492fa1b2e3db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# frozen_string_literal: true

class CommitEntity < API::Entities::Commit
  include MarkupHelper
  include RequestAwareEntity

  expose :author, using: UserEntity

  expose :author_gravatar_url do |commit|
    GravatarService.new.execute(commit.author_email) # rubocop: disable CodeReuse/ServiceClass
  end

  expose :commit_url do |commit, options|
    project_commit_url(request.project, commit, params: options.fetch(:commit_url_params, {}))
  end

  expose :commit_path do |commit, options|
    project_commit_path(request.project, commit, params: options.fetch(:commit_url_params, {}))
  end

  expose :description_html, if: { type: :full } do |commit|
    markdown_field(commit, :description)
  end

  expose :title_html, if: { type: :full } do |commit|
    markdown_field(commit, :title)
  end
end