2018-07-19 14:43:13 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-05-26 14:51:24 -04:00
|
|
|
# TODO: Inherit from TreeEntity, when `Tree` implements `id` and `name` like `Gitlab::Git::Tree`.
|
|
|
|
class TreeRootEntity < Grape::Entity
|
2017-08-15 15:53:41 -04:00
|
|
|
include RequestAwareEntity
|
|
|
|
|
2017-05-26 14:51:24 -04:00
|
|
|
expose :path
|
2017-08-15 15:53:41 -04:00
|
|
|
|
2017-05-26 14:51:24 -04:00
|
|
|
expose :trees, using: TreeEntity
|
|
|
|
expose :blobs, using: BlobEntity
|
|
|
|
expose :submodules, using: SubmoduleEntity
|
2017-08-15 15:53:41 -04:00
|
|
|
|
|
|
|
expose :parent_tree_url do |tree|
|
|
|
|
path = tree.path.sub(%r{\A/}, '')
|
|
|
|
next unless path.present?
|
|
|
|
|
|
|
|
path_segments = path.split('/')
|
|
|
|
path_segments.pop
|
|
|
|
parent_tree_path = path_segments.join('/')
|
|
|
|
|
|
|
|
project_tree_path(request.project, File.join(request.ref, parent_tree_path))
|
|
|
|
end
|
2017-11-01 12:08:06 -04:00
|
|
|
|
|
|
|
expose :last_commit_path do |tree|
|
|
|
|
logs_file_project_ref_path(request.project, request.ref, tree.path)
|
|
|
|
end
|
2017-05-26 14:51:24 -04:00
|
|
|
end
|