2018-09-29 18:34:47 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-08-03 04:32:29 -04:00
|
|
|
module API
|
|
|
|
# MergeRequestDiff API
|
2020-10-14 20:08:42 -04:00
|
|
|
class MergeRequestDiffs < ::API::Base
|
2017-01-16 23:45:07 -05:00
|
|
|
include PaginationParams
|
|
|
|
|
2016-08-03 04:32:29 -04:00
|
|
|
before { authenticate! }
|
|
|
|
|
2020-10-29 14:09:11 -04:00
|
|
|
feature_category :code_review
|
|
|
|
|
2017-03-15 14:09:24 -04:00
|
|
|
params do
|
|
|
|
requires :id, type: String, desc: 'The ID of a project'
|
|
|
|
end
|
2018-11-08 07:18:17 -05:00
|
|
|
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS 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
|
2017-02-28 00:26:09 -05:00
|
|
|
requires :merge_request_iid, type: Integer, desc: 'The IID of a merge request'
|
2017-01-16 23:45:07 -05:00
|
|
|
use :pagination
|
2016-08-03 04:58:09 -04:00
|
|
|
end
|
2017-02-28 00:26:09 -05:00
|
|
|
get ":id/merge_requests/:merge_request_iid/versions" do
|
2021-02-11 10:09:11 -05:00
|
|
|
not_found!("Merge Request") unless can?(current_user, :read_merge_request, user_project)
|
|
|
|
|
2017-02-28 00:26:09 -05:00
|
|
|
merge_request = find_merge_request_with_access(params[:merge_request_iid])
|
2016-08-03 04:32:29 -04:00
|
|
|
|
2017-08-15 06:27:37 -04:00
|
|
|
present paginate(merge_request.merge_request_diffs.order_id_desc), 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
|
2017-02-28 00:26:09 -05:00
|
|
|
requires :merge_request_iid, type: Integer, desc: 'The IID of a merge request'
|
2016-08-12 07:44:49 -04:00
|
|
|
requires :version_id, type: Integer, desc: 'The ID of a merge request diff version'
|
|
|
|
end
|
|
|
|
|
2017-02-28 00:26:09 -05:00
|
|
|
get ":id/merge_requests/:merge_request_iid/versions/:version_id" do
|
2021-02-11 10:09:11 -05:00
|
|
|
not_found!("Merge Request") unless can?(current_user, :read_merge_request, user_project)
|
|
|
|
|
2017-02-28 00:26:09 -05:00
|
|
|
merge_request = find_merge_request_with_access(params[:merge_request_iid])
|
2016-08-12 07:44:49 -04:00
|
|
|
|
2021-04-07 23:09:23 -04:00
|
|
|
present_cached merge_request.merge_request_diffs.find(params[:version_id]), with: Entities::MergeRequestDiffFull, cache_context: nil
|
2016-08-12 07:44:49 -04:00
|
|
|
end
|
2016-08-03 04:32:29 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|