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

53 lines
1.8 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
2021-01-03 14:25:43 +05:30
class MergeRequestDiffs < ::API::Base
2017-08-17 22:00:37 +05:30
include PaginationParams
2016-09-29 09:46:39 +05:30
before { authenticate! }
2021-01-29 00:20:46 +05:30
feature_category :code_review
2017-08-17 22:00:37 +05:30
params do
requires :id, type: String, desc: 'The ID of a project'
end
2019-02-15 15:39:39 +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
2021-02-11 23:33:58 +05:30
not_found!("Merge Request") unless can?(current_user, :read_merge_request, user_project)
2017-08-17 22:00:37 +05:30
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
2021-02-11 23:33:58 +05:30
not_found!("Merge Request") unless can?(current_user, :read_merge_request, user_project)
2017-08-17 22:00:37 +05:30
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