Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the merge_request_dependencies endpoint #698

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions lib/gitlab/client/merge_requests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,18 @@ def merge_request_pipelines(project, id)
get("/projects/#{url_encode project}/merge_requests/#{id}/pipelines")
end

# Shows information about the merge request dependencies that must be resolved before merging.
#
# @example
# Gitlab.merge_request_dependencies(5, 36)
#
# @param [Integer, String] project The ID or name of a project.
# @param [Integer] id The ID of a merge request.
# @return [Array<Gitlab::ObjectifiedHash>]
def merge_request_dependencies(project, id)
get("/projects/#{url_encode project}/merge_requests/#{id}/blocks")
end

# Create a new pipeline for a merge request.
# A pipeline created via this endpoint doesnt run a regular branch/tag pipeline.
# It requires .gitlab-ci.yml to be configured with only: [merge_requests] to create jobs.
Expand Down
1 change: 1 addition & 0 deletions spec/fixtures/merge_request_dependencies.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"id":1234,"blocking_merge_request":{"id":2,"target_branch":"master","source_branch":"api2","project_id":3,"title":"New feature 2","closed":false,"merged":false,"author":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-10-19T05:56:05Z"},"assignee":{"id":2,"email":"jack@example.com","name":"Jack Smith","blocked":false,"created_at":"2012-10-19T05:56:14Z"}},"blocked_merge_request":{"id":1,"target_branch":"master","source_branch":"api","project_id":3,"title":"New feature","closed":false,"merged":false,"author":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-10-19T05:56:05Z"},"assignee":{"id":2,"email":"jack@example.com","name":"Jack Smith","blocked":false,"created_at":"2012-10-19T05:56:14Z"}}}]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thought (non-blocking): Is there any reason to have the fixtures minimized, and not pretty-formatted? I would find them easier to maintain.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly to reduce file sizes. They're rarely maintained after being added, and I don't see a problem with prettifying and minimizing them again in any modern editor.

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 @@ -77,6 +77,22 @@
end
end

describe '.merge_request_dependencies' do
before do
stub_get('/projects/3/merge_requests/1/blocks', 'merge_request_dependencies')
@pipelines = Gitlab.merge_request_dependencies(3, 1)
end

it 'gets the correct resource' do
expect(a_get('/projects/3/merge_requests/1/blocks')).to have_been_made
end

it 'returns information about merge request dependencies' do
expect(@pipelines.first.id).to eq(1234)
expect(@pipelines.first.keys).to include('blocking_merge_request', 'blocked_merge_request')
end
end

describe '.create_merge_request_pipeline' do
before do
stub_post('/projects/3/merge_requests/2/pipelines', 'pipeline_create')
Expand Down