2020-01-31 13:09:11 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module API
|
|
|
|
module Entities
|
|
|
|
class CommitDetail < Commit
|
2022-08-30 14:09:50 -04:00
|
|
|
include ::API::Helpers::Presentable
|
|
|
|
|
|
|
|
expose :stats, using: Entities::CommitStats, if: :include_stats
|
|
|
|
expose :status_for, as: :status
|
2020-01-31 13:09:11 -05:00
|
|
|
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
|