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

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

25 lines
791 B
Ruby
Raw Normal View History

2020-03-13 15:44:24 +05:30
# frozen_string_literal: true
module API
module Entities
class CommitDetail < Commit
2022-09-01 20:07:04 +05:30
include ::API::Helpers::Presentable
expose :stats, using: Entities::CommitStats, if: :include_stats
2023-01-13 00:05:48 +05:30
expose :status_for, as: :status, documentation: { type: 'string', example: 'success' }
expose :project_id, documentation: { type: 'integer', example: 1 }
2020-03-13 15:44:24 +05:30
2023-01-13 00:05:48 +05:30
expose :last_pipeline, documentation: { type: ::API::Entities::Ci::PipelineBasic.to_s } do |commit, options|
2020-03-13 15:44:24 +05:30
pipeline = commit.last_pipeline if can_read_pipeline?
2020-10-24 23:57:45 +05:30
::API::Entities::Ci::PipelineBasic.represent(pipeline, options)
2020-03-13 15:44:24 +05:30
end
private
def can_read_pipeline?
Ability.allowed?(options[:current_user], :read_pipeline, object.last_pipeline)
end
end
end
end