summaryrefslogtreecommitdiff
path: root/lib/api/entities/compare.rb
blob: 75a36d9bb01811bb1e7ca0fa80f1f332352e1cf4 (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
29
# frozen_string_literal: true

module API
  module Entities
    class Compare < Grape::Entity
      expose :commit, using: Entities::Commit do |compare, _|
        compare.commits.last
      end

      expose :commits, using: Entities::Commit do |compare, _|
        compare.commits
      end

      expose :diffs, using: Entities::Diff do |compare, _|
        compare.diffs.diffs.to_a
      end

      expose :compare_timeout do |compare, _|
        compare.diffs.diffs.overflow?
      end

      expose :same, as: :compare_same_ref

      expose :web_url do |compare, _|
        Gitlab::UrlBuilder.build(compare)
      end
    end
  end
end