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
7a8a6823
Commit
7a8a6823
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
d0764227
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
63 additions
and
4 deletions
+63
-4
doc/api/merge_requests.md
doc/api/merge_requests.md
+40
-2
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 @
7a8a6823
...
@@ -411,6 +411,7 @@ Parameters:
...
@@ -411,6 +411,7 @@ Parameters:
-
`merge_request_iid`
(required) - The internal ID of the merge request
-
`merge_request_iid`
(required) - The internal ID of the merge request
-
`render_html`
(optional) - If
`true`
response includes rendered HTML for title and description
-
`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_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
```
json
{
{
...
@@ -464,6 +465,7 @@ Parameters:
...
@@ -464,6 +465,7 @@ Parameters:
},
},
"merge_when_pipeline_succeeds"
:
true
,
"merge_when_pipeline_succeeds"
:
true
,
"merge_status"
:
"can_be_merged"
,
"merge_status"
:
"can_be_merged"
,
"merge_error"
:
null
,
"sha"
:
"8888888888888888888888888888888888888888"
,
"sha"
:
"8888888888888888888888888888888888888888"
,
"merge_commit_sha"
:
null
,
"merge_commit_sha"
:
null
,
"user_notes_count"
:
1
,
"user_notes_count"
:
1
,
...
@@ -509,6 +511,7 @@ Parameters:
...
@@ -509,6 +511,7 @@ Parameters:
"start_sha"
:
"c380d3acebd181f13629a25d2e2acca46ffe1e00"
"start_sha"
:
"c380d3acebd181f13629a25d2e2acca46ffe1e00"
},
},
"diverged_commits_count"
:
2
,
"diverged_commits_count"
:
2
,
"rebase_in_progress"
:
false
,
"approvals_before_merge"
:
null
"approvals_before_merge"
:
null
}
}
```
```
...
@@ -786,6 +789,7 @@ order for it to take effect:
...
@@ -786,6 +789,7 @@ order for it to take effect:
},
},
"merge_when_pipeline_succeeds"
:
true
,
"merge_when_pipeline_succeeds"
:
true
,
"merge_status"
:
"can_be_merged"
,
"merge_status"
:
"can_be_merged"
,
"merge_error"
:
null
,
"sha"
:
"8888888888888888888888888888888888888888"
,
"sha"
:
"8888888888888888888888888888888888888888"
,
"merge_commit_sha"
:
null
,
"merge_commit_sha"
:
null
,
"user_notes_count"
:
1
,
"user_notes_count"
:
1
,
...
@@ -914,6 +918,7 @@ Must include at least one non-required attribute from above.
...
@@ -914,6 +918,7 @@ Must include at least one non-required attribute from above.
},
},
"merge_when_pipeline_succeeds"
:
true
,
"merge_when_pipeline_succeeds"
:
true
,
"merge_status"
:
"can_be_merged"
,
"merge_status"
:
"can_be_merged"
,
"merge_error"
:
null
,
"sha"
:
"8888888888888888888888888888888888888888"
,
"sha"
:
"8888888888888888888888888888888888888888"
,
"merge_commit_sha"
:
null
,
"merge_commit_sha"
:
null
,
"user_notes_count"
:
1
,
"user_notes_count"
:
1
,
...
@@ -1058,6 +1063,7 @@ Parameters:
...
@@ -1058,6 +1063,7 @@ Parameters:
},
},
"merge_when_pipeline_succeeds"
:
true
,
"merge_when_pipeline_succeeds"
:
true
,
"merge_status"
:
"can_be_merged"
,
"merge_status"
:
"can_be_merged"
,
"merge_error"
:
null
,
"sha"
:
"8888888888888888888888888888888888888888"
,
"sha"
:
"8888888888888888888888888888888888888888"
,
"merge_commit_sha"
:
null
,
"merge_commit_sha"
:
null
,
"user_notes_count"
:
1
,
"user_notes_count"
:
1
,
...
@@ -1174,6 +1180,7 @@ Parameters:
...
@@ -1174,6 +1180,7 @@ Parameters:
},
},
"merge_when_pipeline_succeeds"
:
false
,
"merge_when_pipeline_succeeds"
:
false
,
"merge_status"
:
"can_be_merged"
,
"merge_status"
:
"can_be_merged"
,
"merge_error"
:
null
,
"sha"
:
"8888888888888888888888888888888888888888"
,
"sha"
:
"8888888888888888888888888888888888888888"
,
"merge_commit_sha"
:
null
,
"merge_commit_sha"
:
null
,
"user_notes_count"
:
1
,
"user_notes_count"
:
1
,
...
@@ -1245,8 +1252,39 @@ curl --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/a
...
@@ -1245,8 +1252,39 @@ curl --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/a
```
```
This is an asynchronous request. The API will return an empty
`202 Accepted`
This is an asynchronous request. The API will return an empty
`202 Accepted`
response if the request is enqueued successfully. You should poll the
response if the request is enqueued successfully.
[
Get single MR
](
#get-single-mr
)
endpoint to determine success or failure.
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
## Comments on merge requests
...
...
lib/api/entities.rb
View file @
7a8a6823
...
@@ -717,6 +717,10 @@ module API
...
@@ -717,6 +717,10 @@ module API
expose
:diff_refs
,
using:
Entities
::
DiffRefs
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
]
}
expose
:diverged_commits_count
,
as: :diverged_commits_count
,
if:
->
(
_
,
options
)
{
options
[
:include_diverged_commits_count
]
}
def
build_available?
(
options
)
def
build_available?
(
options
)
...
...
lib/api/merge_requests.rb
View file @
7a8a6823
...
@@ -254,6 +254,7 @@ module API
...
@@ -254,6 +254,7 @@ module API
requires
:merge_request_iid
,
type:
Integer
,
desc:
'The IID of a merge request'
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
: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_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
end
desc
'Get a single merge request'
do
desc
'Get a single merge request'
do
success
Entities
::
MergeRequest
success
Entities
::
MergeRequest
...
@@ -261,7 +262,13 @@ module API
...
@@ -261,7 +262,13 @@ module API
get
':id/merge_requests/:merge_request_iid'
do
get
':id/merge_requests/:merge_request_iid'
do
merge_request
=
find_merge_request_with_access
(
params
[
:merge_request_iid
])
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
end
desc
'Get the participants of a merge request'
do
desc
'Get the participants of a merge request'
do
...
...
spec/requests/api/merge_requests_spec.rb
View file @
7a8a6823
...
@@ -359,6 +359,8 @@ describe API::MergeRequests do
...
@@ -359,6 +359,8 @@ describe API::MergeRequests do
expect
(
json_response
[
'should_close_merge_request'
]).
to
be_falsy
expect
(
json_response
[
'should_close_merge_request'
]).
to
be_falsy
expect
(
json_response
[
'force_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
[
'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
end
it
'exposes description and title html when render_html is true'
do
it
'exposes description and title html when render_html is true'
do
...
@@ -369,6 +371,14 @@ describe API::MergeRequests do
...
@@ -369,6 +371,14 @@ describe API::MergeRequests do
expect
(
json_response
).
to
include
(
'title_html'
,
'description_html'
)
expect
(
json_response
).
to
include
(
'title_html'
,
'description_html'
)
end
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
context
'merge_request_metrics'
do
before
do
before
do
merge_request
.
metrics
.
update!
(
merged_by:
user
,
merge_request
.
metrics
.
update!
(
merged_by:
user
,
...
@@ -1203,7 +1213,7 @@ describe API::MergeRequests do
...
@@ -1203,7 +1213,7 @@ describe API::MergeRequests do
end
end
describe
'PUT :id/merge_requests/:merge_request_iid/rebase'
do
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
Sidekiq
::
Testing
.
fake!
do
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/rebase"
,
user
)
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/rebase"
,
user
)
end
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