BigW Consortium Gitlab

merge_request_diffs.rb 1.48 KB
Newer Older
1 2 3
module API
  # MergeRequestDiff API
  class MergeRequestDiffs < Grape::API
4 5
    include PaginationParams

6 7
    before { authenticate! }

8 9 10 11
    params do
      requires :id, type: String, desc: 'The ID of a project'
    end
    resource :projects, requirements: { id: %r{[^/]+} } do
12 13 14 15 16 17
      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
18
        requires :merge_request_iid, type: Integer, desc: 'The IID of a merge request'
19
        use :pagination
20
      end
21 22
      get ":id/merge_requests/:merge_request_iid/versions" do
        merge_request = find_merge_request_with_access(params[:merge_request_iid])
23

24
        present paginate(merge_request.merge_request_diffs), with: Entities::MergeRequestDiff
25
      end
26 27 28 29 30 31 32

      desc 'Get a single merge request diff version' do
        detail 'This feature was introduced in GitLab 8.12.'
        success Entities::MergeRequestDiffFull
      end

      params do
33
        requires :merge_request_iid, type: Integer, desc: 'The IID of a merge request'
34 35 36
        requires :version_id, type: Integer, desc: 'The ID of a merge request diff version'
      end

37 38
      get ":id/merge_requests/:merge_request_iid/versions/:version_id" do
        merge_request = find_merge_request_with_access(params[:merge_request_iid])
39 40 41

        present merge_request.merge_request_diffs.find(params[:version_id]), with: Entities::MergeRequestDiffFull
      end
42 43 44
    end
  end
end