debian-mirror-gitlab/lib/api/merge_request_diffs.rb

47 lines
1.6 KiB
Ruby
Raw Normal View History

2018-12-05 23:21:45 +05:30
# frozen_string_literal: true
2016-09-29 09:46:39 +05:30
module API
# MergeRequestDiff API
2020-07-28 23:09:34 +05:30
class MergeRequestDiffs < Grape::API::Instance
2017-08-17 22:00:37 +05:30
include PaginationParams
2016-09-29 09:46:39 +05:30
before { authenticate! }
2017-08-17 22:00:37 +05:30
params do
requires :id, type: String, desc: 'The ID of a project'
end
2018-12-23 12:14:25 +05:30
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
2016-09-29 09:46:39 +05:30
desc 'Get a list of merge request diff versions' do
detail 'This feature was introduced in GitLab 8.12.'
success Entities::MergeRequestDiff
end
params do
2017-08-17 22:00:37 +05:30
requires :merge_request_iid, type: Integer, desc: 'The IID of a merge request'
use :pagination
2016-09-29 09:46:39 +05:30
end
2017-08-17 22:00:37 +05:30
get ":id/merge_requests/:merge_request_iid/versions" do
merge_request = find_merge_request_with_access(params[:merge_request_iid])
2016-09-29 09:46:39 +05:30
2018-03-17 18:26:18 +05:30
present paginate(merge_request.merge_request_diffs.order_id_desc), with: Entities::MergeRequestDiff
2016-09-29 09:46:39 +05:30
end
desc 'Get a single merge request diff version' do
detail 'This feature was introduced in GitLab 8.12.'
success Entities::MergeRequestDiffFull
end
params do
2017-08-17 22:00:37 +05:30
requires :merge_request_iid, type: Integer, desc: 'The IID of a merge request'
2016-09-29 09:46:39 +05:30
requires :version_id, type: Integer, desc: 'The ID of a merge request diff version'
end
2017-08-17 22:00:37 +05:30
get ":id/merge_requests/:merge_request_iid/versions/:version_id" do
merge_request = find_merge_request_with_access(params[:merge_request_iid])
2016-09-29 09:46:39 +05:30
present merge_request.merge_request_diffs.find(params[:version_id]), with: Entities::MergeRequestDiffFull
end
end
end
end