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
e2d94e07
Commit
e2d94e07
authored
Feb 20, 2013
by
Andrew8xx8
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
State machine added for merge_status field
parent
1b7b17d1
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
36 deletions
+35
-36
app/models/merge_request.rb
app/models/merge_request.rb
+28
-35
app/views/merge_requests/_show.html.haml
app/views/merge_requests/_show.html.haml
+1
-1
spec/models/merge_request_spec.rb
spec/models/merge_request_spec.rb
+6
-0
No files found.
app/models/merge_request.rb
View file @
e2d94e07
...
@@ -53,9 +53,25 @@ class MergeRequest < ActiveRecord::Base
...
@@ -53,9 +53,25 @@ class MergeRequest < ActiveRecord::Base
BROKEN_DIFF
=
"--broken-diff"
BROKEN_DIFF
=
"--broken-diff"
UNCHECKED
=
1
state_machine
:merge_status
,
initial: :unchecked
do
CAN_BE_MERGED
=
2
event
:mark_as_unchecked
do
CANNOT_BE_MERGED
=
3
transition
[
:can_be_merged
,
:cannot_be_merged
]
=>
:unchecked
end
event
:mark_as_mergeable
do
transition
unchecked: :can_be_merged
end
event
:mark_as_unmergeable
do
transition
unchecked: :cannot_be_merged
end
state
:unchecked
state
:can_be_merged
state
:cannot_be_merged
end
serialize
:st_commits
serialize
:st_commits
serialize
:st_diffs
serialize
:st_diffs
...
@@ -84,13 +100,9 @@ class MergeRequest < ActiveRecord::Base
...
@@ -84,13 +100,9 @@ class MergeRequest < ActiveRecord::Base
end
end
end
end
# DEPRECATED: Please use human_merge_status_name instead
def
human_merge_status
def
human_merge_status
merge_statuses
=
{
human_merge_status_name
CAN_BE_MERGED
=>
"can_be_merged"
,
CANNOT_BE_MERGED
=>
"cannot_be_merged"
,
UNCHECKED
=>
"unchecked"
}
merge_statuses
[
self
.
merge_status
]
end
end
def
validate_branches
def
validate_branches
...
@@ -104,26 +116,12 @@ class MergeRequest < ActiveRecord::Base
...
@@ -104,26 +116,12 @@ class MergeRequest < ActiveRecord::Base
self
.
reloaded_diffs
self
.
reloaded_diffs
end
end
def
unchecked?
merge_status
==
UNCHECKED
end
def
mark_as_unchecked
self
.
merge_status
=
UNCHECKED
self
.
save
end
def
can_be_merged?
merge_status
==
CAN_BE_MERGED
end
def
check_if_can_be_merged
def
check_if_can_be_merged
self
.
merge_status
=
if
Gitlab
::
Satellite
::
MergeAction
.
new
(
self
.
author
,
self
).
can_be_merged?
if
Gitlab
::
Satellite
::
MergeAction
.
new
(
self
.
author
,
self
).
can_be_merged?
CAN_BE_MERGED
mark_as_mergeable
else
else
CANNOT_BE_MERGED
mark_as_unmergeable
end
end
self
.
save
end
end
def
diffs
def
diffs
...
@@ -178,11 +176,6 @@ class MergeRequest < ActiveRecord::Base
...
@@ -178,11 +176,6 @@ class MergeRequest < ActiveRecord::Base
commits
.
any?
&&
opened?
commits
.
any?
&&
opened?
end
end
def
mark_as_unmergable
self
.
merge_status
=
CANNOT_BE_MERGED
self
.
save
end
def
reloaded_commits
def
reloaded_commits
if
opened?
&&
unmerged_commits
.
any?
if
opened?
&&
unmerged_commits
.
any?
self
.
st_commits
=
unmerged_commits
self
.
st_commits
=
unmerged_commits
...
@@ -217,7 +210,7 @@ class MergeRequest < ActiveRecord::Base
...
@@ -217,7 +210,7 @@ class MergeRequest < ActiveRecord::Base
true
true
end
end
rescue
rescue
self
.
mark_as_unmerg
able
mark_as_unmerge
able
false
false
end
end
...
...
app/views/merge_requests/_show.html.haml
View file @
e2d94e07
...
@@ -29,7 +29,7 @@
...
@@ -29,7 +29,7 @@
$
(
function
(){
$
(
function
(){
merge_request
=
new
MergeRequest
({
merge_request
=
new
MergeRequest
({
url_to_automerge_check
:
"
#{
automerge_check_project_merge_request_path
(
@project
,
@merge_request
)
}
"
,
url_to_automerge_check
:
"
#{
automerge_check_project_merge_request_path
(
@project
,
@merge_request
)
}
"
,
check_enable
:
#{
@merge_request
.
merge_status
==
MergeRequest
::
UNCHECKED
?
"true"
:
"false"
}
,
check_enable
:
#{
@merge_request
.
unchecked?
?
"true"
:
"false"
}
,
url_to_ci_check
:
"
#{
ci_status_project_merge_request_path
(
@project
,
@merge_request
)
}
"
,
url_to_ci_check
:
"
#{
ci_status_project_merge_request_path
(
@project
,
@merge_request
)
}
"
,
ci_enable
:
#{
@project
.
gitlab_ci?
?
"true"
:
"false"
}
,
ci_enable
:
#{
@project
.
gitlab_ci?
?
"true"
:
"false"
}
,
current_status
:
"
#{
@merge_request
.
human_merge_status
}
"
,
current_status
:
"
#{
@merge_request
.
human_merge_status
}
"
,
...
...
spec/models/merge_request_spec.rb
View file @
e2d94e07
...
@@ -32,6 +32,12 @@ describe MergeRequest do
...
@@ -32,6 +32,12 @@ describe MergeRequest do
it
{
should_not
allow_mass_assignment_of
(
:project_id
)
}
it
{
should_not
allow_mass_assignment_of
(
:project_id
)
}
end
end
describe
"Respond to"
do
it
{
should
respond_to
(
:unchecked?
)
}
it
{
should
respond_to
(
:can_be_merged?
)
}
it
{
should
respond_to
(
:cannot_be_merged?
)
}
end
describe
'modules'
do
describe
'modules'
do
it
{
should
include_module
(
Issuable
)
}
it
{
should
include_module
(
Issuable
)
}
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