diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-02-04 14:46:54 -0800 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-02-04 14:46:54 -0800 |
commit | fc13ea713751d853693396aa77b51bbaa71c015b (patch) | |
tree | fed1ae727be1e6d8a219b8208d167c5365fce603 /lib | |
parent | 61d07eabfc7b9ad44b0d50f73003cabe28a04b42 (diff) | |
parent | b60d06eb2c91a61b91a214dac0f0f526b146f8d7 (diff) | |
download | gitlab-ce-fc13ea713751d853693396aa77b51bbaa71c015b.tar.gz |
Merge pull request #8712 from jvanbaarsen/add-merge-request-files-endpoint
Added a way to retrieve MR files
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/entities.rb | 16 | ||||
-rw-r--r-- | lib/api/merge_requests.rb | 16 |
2 files changed, 27 insertions, 5 deletions
diff --git a/lib/api/entities.rb b/lib/api/entities.rb index 58339908fd2..fa76a54c2d8 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -147,6 +147,11 @@ module API expose :state, :created_at, :updated_at end + class RepoDiff < Grape::Entity + expose :old_path, :new_path, :a_mode, :b_mode, :diff + expose :new_file, :renamed_file, :deleted_file + end + class Milestone < ProjectEntity expose :due_date end @@ -166,6 +171,12 @@ module API expose :milestone, using: Entities::Milestone end + class MergeRequestChanges < MergeRequest + expose :diffs, as: :changes, using: Entities::RepoDiff do |compare, _| + compare.diffs + end + end + class SSHKey < Grape::Entity expose :id, :title, :key, :created_at end @@ -236,11 +247,6 @@ module API expose :name, :color end - class RepoDiff < Grape::Entity - expose :old_path, :new_path, :a_mode, :b_mode, :diff - expose :new_file, :renamed_file, :deleted_file - end - class Compare < Grape::Entity expose :commit, using: Entities::RepoCommit do |compare, options| Commit.decorate(compare.commits).last diff --git a/lib/api/merge_requests.rb b/lib/api/merge_requests.rb index 2a5b10c6f52..a0ebd8d0c1b 100644 --- a/lib/api/merge_requests.rb +++ b/lib/api/merge_requests.rb @@ -75,6 +75,22 @@ module API present merge_request, with: Entities::MergeRequest end + # Show MR changes + # + # Parameters: + # id (required) - The ID of a project + # merge_request_id (required) - The ID of MR + # + # Example: + # GET /projects/:id/merge_request/:merge_request_id/changes + # + get ':id/merge_request/:merge_request_id/changes' do + merge_request = user_project.merge_requests. + find(params[:merge_request_id]) + authorize! :read_merge_request, merge_request + present merge_request, with: Entities::MergeRequestChanges + end + # Create MR # # Parameters: |