diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index 8623274ae..afc0d1c5b 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -3,11 +3,15 @@ on: schedule: - cron: '30 1 * * *' +permissions: + issues: write + pull-requests: write + jobs: stale: runs-on: ubuntu-latest steps: - - uses: actions/stale@v4 + - uses: actions/stale@v8 with: stale-issue-message: > This issue has been automatically marked as stale because it has not had diff --git a/lib/gitlab/client/merge_requests.rb b/lib/gitlab/client/merge_requests.rb index 62443cd53..cd30154cb 100644 --- a/lib/gitlab/client/merge_requests.rb +++ b/lib/gitlab/client/merge_requests.rb @@ -344,6 +344,18 @@ def delete_merge_request(project, merge_request_id) delete("/projects/#{url_encode project}/merge_requests/#{merge_request_id}") end + # Gets a list of merge request diffs + # + # @example + # Gitlab.merge_request_diffs(5, 1) + # Gitlab.merge_request_diffs('gitlab', 1) + # @param [Integer, String] project The ID or name of a project. + # @param [Integer] id The ID of a merge request. + # @return [Gitlab::ObjectifiedHash] A list of the merge request diffs. + def merge_request_diffs(project, merge_request_id) + get("/projects/#{url_encode project}/merge_requests/#{merge_request_id}/diffs") + end + # Gets a list of merge request diff versions # # @example diff --git a/spec/fixtures/merge_request_diffs.json b/spec/fixtures/merge_request_diffs.json new file mode 100644 index 000000000..c960dbc9e --- /dev/null +++ b/spec/fixtures/merge_request_diffs.json @@ -0,0 +1,22 @@ +[ + { + "old_path": "README", + "new_path": "README", + "a_mode": "100644", + "b_mode": "100644", + "diff": "--- a/README\ +++ b/README\ @@ -1 +1 @@\ -Title\ +README", + "new_file": false, + "renamed_file": false, + "deleted_file": false + }, + { + "old_path": "VERSION", + "new_path": "VERSION", + "a_mode": "100644", + "b_mode": "100644", + "diff": "--- a/VERSION\ +++ b/VERSION\ @@ -1 +1 @@\ -1.9.7\ +1.9.8", + "new_file": false, + "renamed_file": false, + "deleted_file": false + } +] \ No newline at end of file diff --git a/spec/gitlab/client/merge_requests_spec.rb b/spec/gitlab/client/merge_requests_spec.rb index a24fe2e63..a3da49b5e 100644 --- a/spec/gitlab/client/merge_requests_spec.rb +++ b/spec/gitlab/client/merge_requests_spec.rb @@ -403,6 +403,22 @@ end end + describe '.merge_request_diffs' do + before do + stub_get('/projects/3/merge_requests/105/diffs', 'merge_request_diffs') + @versions = Gitlab.merge_request_diffs(3, 105) + end + + it 'gets the correct resource' do + expect(a_get('/projects/3/merge_requests/105/diffs')).to have_been_made + end + + it 'returns an array of the diffs' do + expect(@versions.length).to eq(2) + expect(@versions.first.old_path).to eq('README') + end + end + describe '.merge_request_diff_versions' do before do stub_get('/projects/3/merge_requests/105/versions', 'merge_request_diff_versions')