add referenced merge_requests endpoint
What does this MR do?
we have a process, that resets various repos on local-dev instanced based on the MR's related to an issue number. QA/dev - just enters the issue-id - via gitlab api we fetch the related mr's and reset the respective repos to that mr's branch.
doing it right now via some ugly hack:
related_mr_url = "http://gitlab.krone.at/KRN/MGMT/issues/#{issue_id}/referenced_merge_requests"
#puts "Fetching url: #{related_mr_url}"
out = RestClient::Request.execute( { :method => :get, :url => related_mr_url, :headers => {"PRIVATE-TOKEN" => ENV['KRN_GITLAB_TOKEN']} })
jso = JSON.parse out
if jso["html"]
mrs = jso["html"].scan(/href="\/(.*?)\/merge_requests\/(.*)"[^\>]*\>([^\<]+)\</)
mrs.each do | mr |
mrequest = client.merge_request(mr[0], mr[1])
end
end
this does not only feel ugly, buts a real bad thing.
this MR add's a new endpoint:
/api/v4/projects/:id/issues/:iid/referenced_merge_requests
just returning the merge requests:
[
{
"id": 29,
"iid": 4,
"project_id": 6,
"title": "Provident eius eos blanditiis consequatur neque odit.",
"description": "Ut consequatur ipsa aspernatur quisquam voluptatum fugit. Qui harum corporis quo fuga ut incidunt veritatis. Autem necessitatibus et harum occaecati nihil ea.\r\n\r\ntwitter/flight#8",
"state": "opened",
"created_at": "2018-09-18T14:36:15.510Z",
"updated_at": "2018-09-19T07:45:13.089Z",
"target_branch": "v2.x",
"source_branch": "so_long_jquery",
"upvotes": 0,
"downvotes": 0,
"author": {
"id": 14,
"name": "Verna Hills",
"username": "lawanda_reinger",
"state": "active",
"avatar_url": "https://www.gravatar.com/avatar/de68a91aeab1cff563795fb98a0c2cc0?s=80&d=identicon",
"web_url": "http://localhost:4001/lawanda_reinger"
},
"assignee": {
"id": 19,
"name": "Jody Baumbach",
"username": "felipa.kuvalis",
"state": "active",
"avatar_url": "https://www.gravatar.com/avatar/6541fc75fc4e87e203529bd275fafd07?s=80&d=identicon",
"web_url": "http://localhost:4001/felipa.kuvalis"
},
"source_project_id": 6,
"target_project_id": 6,
"labels": [],
"work_in_progress": false,
"milestone": {
"id": 27,
"iid": 2,
"project_id": 6,
"title": "v1.0",
"description": "Et tenetur voluptatem minima doloribus vero dignissimos vitae.",
"state": "active",
"created_at": "2018-09-18T14:35:44.353Z",
"updated_at": "2018-09-18T14:35:44.353Z",
"due_date": null,
"start_date": null,
"web_url": "http://localhost:4001/twitter/flight/milestones/2"
},
"merge_when_pipeline_succeeds": false,
"merge_status": "cannot_be_merged",
"sha": "3b7b528e9353295c1c125dad281ac5b5deae5f12",
"merge_commit_sha": null,
"user_notes_count": 9,
"discussion_locked": null,
"should_remove_source_branch": null,
"force_remove_source_branch": false,
"web_url": "http://localhost:4001/twitter/flight/merge_requests/4",
"time_stats": {
"time_estimate": 0,
"total_time_spent": 0,
"human_time_estimate": null,
"human_total_time_spent": null
},
"squash": false
},
{
"id": 26,
"iid": 1,
"project_id": 6,
"title": "Facere eum necessitatibus sequi aut veniam consectetur aperiam quidem laudantium nemo.",
"description": "Itaque quibusdam explicabo ut autem. Sit dicta nihil maiores est ut nemo rem veritatis. Qui rem non nihil quod culpa.\r\n\r\n\r\ntwitter/flight#8",
"state": "opened",
"created_at": "2018-09-18T14:36:14.643Z",
"updated_at": "2018-09-19T07:45:35.226Z",
"target_branch": "alunny/publish_lib",
"source_branch": "remove-from",
"upvotes": 0,
"downvotes": 0,
"author": {
"id": 14,
"name": "Verna Hills",
"username": "lawanda_reinger",
"state": "active",
"avatar_url": "https://www.gravatar.com/avatar/de68a91aeab1cff563795fb98a0c2cc0?s=80&d=identicon",
"web_url": "http://localhost:4001/lawanda_reinger"
},
"assignee": {
"id": 1,
"name": "Administrator",
"username": "root",
"state": "active",
"avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
"web_url": "http://localhost:4001/root"
},
"source_project_id": 6,
"target_project_id": 6,
"labels": [],
"work_in_progress": false,
"milestone": {
"id": 30,
"iid": 5,
"project_id": 6,
"title": "v4.0",
"description": "Qui voluptatum omnis praesentium ullam nesciunt.",
"state": "active",
"created_at": "2018-09-18T14:35:44.432Z",
"updated_at": "2018-09-18T14:35:44.432Z",
"due_date": null,
"start_date": null,
"web_url": "http://localhost:4001/twitter/flight/milestones/5"
},
"merge_when_pipeline_succeeds": false,
"merge_status": "cannot_be_merged",
"sha": "daa75b9b17918f51f43866ff533987fda71375ea",
"merge_commit_sha": null,
"user_notes_count": 9,
"discussion_locked": null,
"should_remove_source_branch": null,
"force_remove_source_branch": false,
"web_url": "http://localhost:4001/twitter/flight/merge_requests/1",
"time_stats": {
"time_estimate": 0,
"total_time_spent": 0,
"human_time_estimate": null,
"human_total_time_spent": null
},
"squash": false
}
]
What are the relevant issue numbers?
Closes gitlab-org/gitlab-ce#39157
/cc @smcgivern
Does this MR meet the acceptance criteria?
if the MR itself is OK, i am going to add tests/docs and stuff, also going to add it to narkoz/gitlab
gem
Edited by Rémy Coutable