2020-03-13 15:44:24 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module API
|
|
|
|
module Entities
|
|
|
|
class CommitDetail < Commit
|
|
|
|
expose :stats, using: Entities::CommitStats, if: :stats
|
|
|
|
expose :status
|
|
|
|
expose :project_id
|
|
|
|
|
|
|
|
expose :last_pipeline do |commit, options|
|
|
|
|
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
|