2020-01-31 13:09:11 -05:00
|
|
|
# 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|
|
2020-06-26 14:09:03 -04:00
|
|
|
pipeline = commit.last_pipeline if can_read_pipeline?
|
2020-08-13 14:10:36 -04:00
|
|
|
::API::Entities::Ci::PipelineBasic.represent(pipeline, options)
|
2020-01-31 13:09:11 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def can_read_pipeline?
|
2020-06-26 14:09:03 -04:00
|
|
|
Ability.allowed?(options[:current_user], :read_pipeline, object.last_pipeline)
|
2020-01-31 13:09:11 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|