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
0
Merge Requests
0
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
Kazuhiko Shiozaki
gitlab-ce
Commits
85145d1d
Commit
85145d1d
authored
May 29, 2015
by
Stan Hu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Disable changing of the source branch in merge request update API
parent
467d7f67
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
12 additions
and
8 deletions
+12
-8
CHANGELOG
CHANGELOG
+1
-0
app/services/merge_requests/update_service.rb
app/services/merge_requests/update_service.rb
+2
-1
doc/api/merge_requests.md
doc/api/merge_requests.md
+1
-3
lib/api/merge_requests.rb
lib/api/merge_requests.rb
+6
-2
spec/requests/api/merge_requests_spec.rb
spec/requests/api/merge_requests_spec.rb
+2
-2
No files found.
CHANGELOG
View file @
85145d1d
Please view this file on the master branch, on stable branches it's out of date.
v 7.12.0 (unreleased)
- Disable changing of the source branch in merge request update API (Stan Hu)
- Shorten merge request WIP text.
- Add option to disallow users from registering any application to use GitLab as an OAuth provider
- Support editing target branch of merge request (Stan Hu)
...
...
app/services/merge_requests/update_service.rb
View file @
85145d1d
...
...
@@ -5,10 +5,11 @@ require_relative 'close_service'
module
MergeRequests
class
UpdateService
<
MergeRequests
::
BaseService
def
execute
(
merge_request
)
# We don't allow change of source/target projects
# We don't allow change of source/target projects
and source branch
# after merge request was created
params
.
except!
(
:source_project_id
)
params
.
except!
(
:target_project_id
)
params
.
except!
(
:source_branch
)
state
=
params
[
:state_event
]
...
...
doc/api/merge_requests.md
View file @
85145d1d
...
...
@@ -221,7 +221,7 @@ If an error occurs, an error number and a message explaining the reason is retur
## Update MR
Updates an existing merge request. You can change
branches
, title, or even close the MR.
Updates an existing merge request. You can change
the target branch
, title, or even close the MR.
```
PUT /projects/:id/merge_request/:merge_request_id
...
...
@@ -231,7 +231,6 @@ Parameters:
-
`id`
(required) - The ID of a project
-
`merge_request_id`
(required) - ID of MR
-
`source_branch`
- The source branch
-
`target_branch`
- The target branch
-
`assignee_id`
- Assignee user ID
-
`title`
- Title of MR
...
...
@@ -242,7 +241,6 @@ Parameters:
{
"id"
:
1
,
"target_branch"
:
"master"
,
"source_branch"
:
"test1"
,
"project_id"
:
3
,
"title"
:
"test1"
,
"description"
:
"description1"
,
...
...
lib/api/merge_requests.rb
View file @
85145d1d
...
...
@@ -137,7 +137,6 @@ module API
# Parameters:
# id (required) - The ID of a project
# merge_request_id (required) - ID of MR
# source_branch - The source branch
# target_branch - The target branch
# assignee_id - Assignee user ID
# title - Title of MR
...
...
@@ -148,10 +147,15 @@ module API
# PUT /projects/:id/merge_request/:merge_request_id
#
put
":id/merge_request/:merge_request_id"
do
attrs
=
attributes_for_keys
[
:
source_branch
,
:
target_branch
,
:assignee_id
,
:title
,
:state_event
,
:description
]
attrs
=
attributes_for_keys
[
:target_branch
,
:assignee_id
,
:title
,
:state_event
,
:description
]
merge_request
=
user_project
.
merge_requests
.
find
(
params
[
:merge_request_id
])
authorize!
:modify_merge_request
,
merge_request
# Ensure source_branch is not specified
if
params
[
:source_branch
].
present?
render_api_error!
(
'Source branch cannot be changed'
,
400
)
end
# Validate label names in advance
if
(
errors
=
validate_label_params
(
params
)).
any?
render_api_error!
({
labels:
errors
},
400
)
...
...
spec/requests/api/merge_requests_spec.rb
View file @
85145d1d
...
...
@@ -349,10 +349,10 @@ describe API::API, api: true do
expect
(
json_response
[
'description'
]).
to
eq
(
'New description'
)
end
it
"should return 4
22 when source_branch and target_branch are renamed the same
"
do
it
"should return 4
00 when source_branch is specified
"
do
put
api
(
"/projects/
#{
project
.
id
}
/merge_request/
#{
merge_request
.
id
}
"
,
user
),
source_branch:
"master"
,
target_branch:
"master"
expect
(
response
.
status
).
to
eq
(
4
22
)
expect
(
response
.
status
).
to
eq
(
4
00
)
end
it
"should return merge_request with renamed target_branch"
do
...
...
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