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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
cb599a09
Commit
cb599a09
authored
Dec 12, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow close of broken MR
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
432018f8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
2 deletions
+21
-2
app/controllers/projects/merge_requests_controller.rb
app/controllers/projects/merge_requests_controller.rb
+15
-0
app/models/merge_request.rb
app/models/merge_request.rb
+5
-1
app/views/projects/merge_requests/show/_mr_title.html.haml
app/views/projects/merge_requests/show/_mr_title.html.haml
+1
-1
No files found.
app/controllers/projects/merge_requests_controller.rb
View file @
cb599a09
...
@@ -79,6 +79,21 @@ class Projects::MergeRequestsController < Projects::ApplicationController
...
@@ -79,6 +79,21 @@ class Projects::MergeRequestsController < Projects::ApplicationController
end
end
def
update
def
update
# If we close MergeRequest we want to ignore validation
# so we can close broken one (Ex. fork project removed)
if
params
[
:merge_request
]
==
{
"state_event"
=>
"close"
}
@merge_request
.
allow_broken
=
true
if
@merge_request
.
close
opts
=
{
notice:
'Merge request was successfully closed.'
}
else
opts
=
{
alert:
'Failed to close merge request.'
}
end
redirect_to
[
@merge_request
.
target_project
,
@merge_request
],
opts
return
end
if
@merge_request
.
update_attributes
(
params
[
:merge_request
].
merge
(
author_id_of_changes:
current_user
.
id
))
if
@merge_request
.
update_attributes
(
params
[
:merge_request
].
merge
(
author_id_of_changes:
current_user
.
id
))
@merge_request
.
reload_code
@merge_request
.
reload_code
@merge_request
.
mark_as_unchecked
@merge_request
.
mark_as_unchecked
...
...
app/models/merge_request.rb
View file @
cb599a09
...
@@ -35,6 +35,10 @@ class MergeRequest < ActiveRecord::Base
...
@@ -35,6 +35,10 @@ class MergeRequest < ActiveRecord::Base
attr_accessor
:should_remove_source_branch
attr_accessor
:should_remove_source_branch
# When this attribute is true some MR validation is ignored
# It allows us to close or modify broken merge requests
attr_accessor
:allow_broken
state_machine
:state
,
initial: :opened
do
state_machine
:state
,
initial: :opened
do
event
:close
do
event
:close
do
transition
[
:reopened
,
:opened
]
=>
:closed
transition
[
:reopened
,
:opened
]
=>
:closed
...
@@ -80,7 +84,7 @@ class MergeRequest < ActiveRecord::Base
...
@@ -80,7 +84,7 @@ class MergeRequest < ActiveRecord::Base
serialize
:st_commits
serialize
:st_commits
serialize
:st_diffs
serialize
:st_diffs
validates
:source_project
,
presence:
true
validates
:source_project
,
presence:
true
,
unless: :allow_broken
validates
:source_branch
,
presence:
true
validates
:source_branch
,
presence:
true
validates
:target_project
,
presence:
true
validates
:target_project
,
presence:
true
validates
:target_branch
,
presence:
true
validates
:target_branch
,
presence:
true
...
...
app/views/projects/merge_requests/show/_mr_title.html.haml
View file @
cb599a09
...
@@ -24,7 +24,7 @@
...
@@ -24,7 +24,7 @@
%li
=
link_to
"Email Patches"
,
project_merge_request_path
(
@project
,
@merge_request
,
format: :patch
)
%li
=
link_to
"Email Patches"
,
project_merge_request_path
(
@project
,
@merge_request
,
format: :patch
)
%li
=
link_to
"Plain Diff"
,
project_merge_request_path
(
@project
,
@merge_request
,
format: :diff
)
%li
=
link_to
"Plain Diff"
,
project_merge_request_path
(
@project
,
@merge_request
,
format: :diff
)
=
link_to
'Close'
,
project_merge_request_path
(
@project
,
@merge_request
,
merge_request:
{
state_event: :close
}),
method: :put
,
class:
"btn grouped btn-close"
,
title:
"Close merge request"
=
link_to
'Close'
,
project_merge_request_path
(
@project
,
@merge_request
,
merge_request:
{
state_event: :close
}),
method: :put
,
class:
"btn grouped btn-close"
,
title:
"Close merge request"
=
link_to
edit_project_merge_request_path
(
@project
,
@merge_request
),
class:
"btn grouped"
,
id
:"edit_merge_request"
do
=
link_to
edit_project_merge_request_path
(
@project
,
@merge_request
),
class:
"btn grouped"
,
id
:"edit_merge_request"
do
%i
.icon-edit
%i
.icon-edit
...
...
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