Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
shoshoi authored Mar 31, 2023
2 parents 3210fd3 + dfffe94 commit 20dcfdf
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 1 deletion.
6 changes: 5 additions & 1 deletion .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions lib/gitlab/client/merge_requests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 22 additions & 0 deletions spec/fixtures/merge_request_diffs.json
Original file line number Diff line number Diff line change
@@ -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
}
]
16 changes: 16 additions & 0 deletions spec/gitlab/client/merge_requests_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit 20dcfdf

Please sign in to comment.