debian-mirror-gitlab/lib/api/entities/compare.rb

33 lines
913 B
Ruby
Raw Normal View History

2020-03-13 15:44:24 +05:30
# frozen_string_literal: true
module API
module Entities
class Compare < Grape::Entity
expose :commit, using: Entities::Commit do |compare, _|
compare.commits.last
end
2023-01-13 00:05:48 +05:30
expose :commits, documentation: { is_array: true }, using: Entities::Commit do |compare, _|
2020-03-13 15:44:24 +05:30
compare.commits
end
2023-01-13 00:05:48 +05:30
expose :diffs, documentation: { is_array: true }, using: Entities::Diff do |compare, _|
2020-03-13 15:44:24 +05:30
compare.diffs.diffs.to_a
end
2023-01-13 00:05:48 +05:30
expose :compare_timeout, documentation: { type: 'boolean' } do |compare, _|
2020-03-13 15:44:24 +05:30
compare.diffs.diffs.overflow?
end
2023-01-13 00:05:48 +05:30
expose :same, as: :compare_same_ref, documentation: { type: 'boolean' }
2021-11-11 11:23:49 +05:30
2023-01-13 00:05:48 +05:30
expose :web_url,
documentation: {
example: "https://gitlab.example.com/gitlab/gitlab-foss/-/compare/main...feature"
} do |compare, _|
2021-11-11 11:23:49 +05:30
Gitlab::UrlBuilder.build(compare)
end
2020-03-13 15:44:24 +05:30
end
end
end