Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
04ceb69f
Commit
04ceb69f
authored
Nov 28, 2018
by
Nick Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow the status of a rebase to be determined
parent
9f287298
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
64 additions
and
5 deletions
+64
-5
doc/api/merge_requests.md
doc/api/merge_requests.md
+41
-3
lib/api/entities.rb
lib/api/entities.rb
+4
-0
lib/api/merge_requests.rb
lib/api/merge_requests.rb
+8
-1
spec/requests/api/merge_requests_spec.rb
spec/requests/api/merge_requests_spec.rb
+11
-1
No files found.
doc/api/merge_requests.md
View file @
04ceb69f
...
...
@@ -408,6 +408,7 @@ Parameters:
-
`merge_request_iid`
(required) - The internal ID of the merge request
-
`render_html`
(optional) - If
`true`
response includes rendered HTML for title and description
-
`include_diverged_commits_count`
(optional) - If
`true`
response includes the commits behind the target branch
-
`include_rebase_in_progress`
(optional) - If
`true`
response includes whether a rebase operation is in progress
```
json
{
...
...
@@ -461,6 +462,7 @@ Parameters:
},
"merge_when_pipeline_succeeds"
:
true
,
"merge_status"
:
"can_be_merged"
,
"merge_error"
:
null
,
"sha"
:
"8888888888888888888888888888888888888888"
,
"merge_commit_sha"
:
null
,
"user_notes_count"
:
1
,
...
...
@@ -505,7 +507,8 @@ Parameters:
"head_sha"
:
"2be7ddb704c7b6b83732fdd5b9f09d5a397b5f8f"
,
"start_sha"
:
"c380d3acebd181f13629a25d2e2acca46ffe1e00"
},
"diverged_commits_count"
:
2
"diverged_commits_count"
:
2
,
"rebase_in_progress"
:
false
}
```
...
...
@@ -773,6 +776,7 @@ POST /projects/:id/merge_requests
},
"merge_when_pipeline_succeeds"
:
true
,
"merge_status"
:
"can_be_merged"
,
"merge_error"
:
null
,
"sha"
:
"8888888888888888888888888888888888888888"
,
"merge_commit_sha"
:
null
,
"user_notes_count"
:
1
,
...
...
@@ -900,6 +904,7 @@ Must include at least one non-required attribute from above.
},
"merge_when_pipeline_succeeds"
:
true
,
"merge_status"
:
"can_be_merged"
,
"merge_error"
:
null
,
"sha"
:
"8888888888888888888888888888888888888888"
,
"merge_commit_sha"
:
null
,
"user_notes_count"
:
1
,
...
...
@@ -1043,6 +1048,7 @@ Parameters:
},
"merge_when_pipeline_succeeds"
:
true
,
"merge_status"
:
"can_be_merged"
,
"merge_error"
:
null
,
"sha"
:
"8888888888888888888888888888888888888888"
,
"merge_commit_sha"
:
null
,
"user_notes_count"
:
1
,
...
...
@@ -1158,6 +1164,7 @@ Parameters:
},
"merge_when_pipeline_succeeds"
:
false
,
"merge_status"
:
"can_be_merged"
,
"merge_error"
:
null
,
"sha"
:
"8888888888888888888888888888888888888888"
,
"merge_commit_sha"
:
null
,
"user_notes_count"
:
1
,
...
...
@@ -1228,8 +1235,39 @@ curl --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/a
```
This is an asynchronous request. The API will return an empty
`202 Accepted`
response if the request is enqueued successfully. You should poll the
[
Get single MR
](
#get-single-mr
)
endpoint to determine success or failure.
response if the request is enqueued successfully.
You can poll the
[
Get single MR
](
#get-single-mr
)
endpoint with the
`include_rebase_in_progress`
parameter to check the status of the
asynchronous request.
If the rebase operation is ongoing, the response will include the following:
```
json
{
"rebase_in_progress"
:
true
"merge_error"
:
null
}
```
Once the rebase operation has completed successfully, the response will include
the following:
```
json
{
"rebase_in_progress"
:
false
,
"merge_error"
:
null
,
}
```
If the rebase operation fails, the response will include the following:
```
json
{
"rebase_in_progress"
:
false
,
"merge_error"
:
"Rebase failed. Please rebase locally"
,
}
```
## Comments on merge requests
...
...
lib/api/entities.rb
View file @
04ceb69f
...
...
@@ -710,6 +710,10 @@ module API
expose
:diff_refs
,
using:
Entities
::
DiffRefs
# Allow the status of a rebase to be determined
expose
:merge_error
expose
:rebase_in_progress?
,
as: :rebase_in_progress
,
if:
->
(
_
,
options
)
{
options
[
:include_rebase_in_progress
]
}
expose
:diverged_commits_count
,
as: :diverged_commits_count
,
if:
->
(
_
,
options
)
{
options
[
:include_diverged_commits_count
]
}
def
build_available?
(
options
)
...
...
lib/api/merge_requests.rb
View file @
04ceb69f
...
...
@@ -252,6 +252,7 @@ module API
requires
:merge_request_iid
,
type:
Integer
,
desc:
'The IID of a merge request'
optional
:render_html
,
type:
Boolean
,
desc:
'Returns the description and title rendered HTML'
optional
:include_diverged_commits_count
,
type:
Boolean
,
desc:
'Returns the commits count behind the target branch'
optional
:include_rebase_in_progress
,
type:
Boolean
,
desc:
'Returns whether a rebase operation is ongoing '
end
desc
'Get a single merge request'
do
success
Entities
::
MergeRequest
...
...
@@ -259,7 +260,13 @@ module API
get
':id/merge_requests/:merge_request_iid'
do
merge_request
=
find_merge_request_with_access
(
params
[
:merge_request_iid
])
present
merge_request
,
with:
Entities
::
MergeRequest
,
current_user:
current_user
,
project:
user_project
,
render_html:
params
[
:render_html
],
include_diverged_commits_count:
params
[
:include_diverged_commits_count
]
present
merge_request
,
with:
Entities
::
MergeRequest
,
current_user:
current_user
,
project:
user_project
,
render_html:
params
[
:render_html
],
include_diverged_commits_count:
params
[
:include_diverged_commits_count
],
include_rebase_in_progress:
params
[
:include_rebase_in_progress
]
end
desc
'Get the participants of a merge request'
do
...
...
spec/requests/api/merge_requests_spec.rb
View file @
04ceb69f
...
...
@@ -359,6 +359,8 @@ describe API::MergeRequests do
expect
(
json_response
[
'should_close_merge_request'
]).
to
be_falsy
expect
(
json_response
[
'force_close_merge_request'
]).
to
be_falsy
expect
(
json_response
[
'changes_count'
]).
to
eq
(
merge_request
.
merge_request_diff
.
real_size
)
expect
(
json_response
[
'merge_error'
]).
to
eq
(
merge_request
.
merge_error
)
expect
(
json_response
).
not_to
include
(
'rebase_in_progress'
)
end
it
'exposes description and title html when render_html is true'
do
...
...
@@ -369,6 +371,14 @@ describe API::MergeRequests do
expect
(
json_response
).
to
include
(
'title_html'
,
'description_html'
)
end
it
'exposes rebase_in_progress when include_rebase_in_progress is true'
do
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
"
,
user
),
include_rebase_in_progress:
true
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
json_response
).
to
include
(
'rebase_in_progress'
)
end
context
'merge_request_metrics'
do
before
do
merge_request
.
metrics
.
update!
(
merged_by:
user
,
...
...
@@ -1182,7 +1192,7 @@ describe API::MergeRequests do
end
describe
'PUT :id/merge_requests/:merge_request_iid/rebase'
do
it
'enques a rebase of the merge request against the target branch'
do
it
'enque
ue
s a rebase of the merge request against the target branch'
do
Sidekiq
::
Testing
.
fake!
do
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/rebase"
,
user
)
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment