2016-08-03 04:32:29 -04:00
|
|
|
module API
|
|
|
|
# MergeRequestDiff API
|
|
|
|
class MergeRequestDiffs < Grape::API
|
2017-01-16 23:45:07 -05:00
|
|
|
include PaginationParams
|
|
|
|
|
2016-08-03 04:32:29 -04:00
|
|
|
before { authenticate! }
|
|
|
|
|
|
|
|
resource :projects do
|
2016-08-03 04:58:09 -04:00
|
|
|
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
|
2016-08-03 05:35:20 -04:00
|
|
|
requires :id, type: String, desc: 'The ID of a project'
|
|
|
|
requires :merge_request_id, type: Integer, desc: 'The ID of a merge request'
|
2017-01-16 23:45:07 -05:00
|
|
|
use :pagination
|
2016-08-03 04:58:09 -04:00
|
|
|
end
|
2016-08-03 04:32:29 -04:00
|
|
|
get ":id/merge_requests/:merge_request_id/versions" do
|
2017-01-03 13:03:13 -05:00
|
|
|
merge_request = find_merge_request_with_access(params[:merge_request_id])
|
2016-08-03 04:32:29 -04:00
|
|
|
|
2017-01-16 23:45:07 -05:00
|
|
|
present paginate(merge_request.merge_request_diffs), with: Entities::MergeRequestDiff
|
2016-08-03 04:32:29 -04:00
|
|
|
end
|
2016-08-12 07:44:49 -04:00
|
|
|
|
|
|
|
desc 'Get a single merge request diff version' do
|
|
|
|
detail 'This feature was introduced in GitLab 8.12.'
|
|
|
|
success Entities::MergeRequestDiffFull
|
|
|
|
end
|
|
|
|
|
|
|
|
params do
|
|
|
|
requires :id, type: String, desc: 'The ID of a project'
|
|
|
|
requires :merge_request_id, type: Integer, desc: 'The ID of a merge request'
|
|
|
|
requires :version_id, type: Integer, desc: 'The ID of a merge request diff version'
|
|
|
|
end
|
|
|
|
|
|
|
|
get ":id/merge_requests/:merge_request_id/versions/:version_id" do
|
2017-01-03 13:03:13 -05:00
|
|
|
merge_request = find_merge_request_with_access(params[:merge_request_id])
|
2016-08-12 07:44:49 -04:00
|
|
|
|
|
|
|
present merge_request.merge_request_diffs.find(params[:version_id]), with: Entities::MergeRequestDiffFull
|
|
|
|
end
|
2016-08-03 04:32:29 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|