BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
883be9c6
Commit
883be9c6
authored
Jul 28, 2017
by
Sean McGivern
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'merge-issuable-reopened-into-opened-state' into 'master'
Merge issuable "reopened" state into "opened" See merge request !12972
parents
58c058c9
6ef87a20
Hide whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
65 additions
and
49 deletions
+65
-49
mr_widget_store.js
...cripts/vue_merge_request_widget/stores/mr_widget_store.js
+1
-1
issuable_finder.rb
app/finders/issuable_finder.rb
+0
-1
issuable.rb
app/models/concerns/issuable.rb
+2
-3
issue.rb
app/models/issue.rb
+2
-3
merge_request.rb
app/models/merge_request.rb
+6
-7
drone_ci_service.rb
app/models/project_services/drone_ci_service.rb
+1
-1
reopen_service.rb
app/services/issues/reopen_service.rb
+3
-3
base_service.rb
app/services/merge_requests/base_service.rb
+3
-3
reopen_service.rb
app/services/merge_requests/reopen_service.rb
+1
-1
merge-issuable-reopened-into-opened-state.yml
.../unreleased/merge-issuable-reopened-into-opened-state.yml
+4
-0
20170719150301_merge_issuable_reopened_into_opened_state.rb
...170719150301_merge_issuable_reopened_into_opened_state.rb
+32
-0
issues.rb
spec/factories/issues.rb
+1
-5
merge_requests.rb
spec/factories/merge_requests.rb
+1
-5
issuable_state_filter_spec.rb
spec/lib/banzai/filter/issuable_state_filter_spec.rb
+1
-9
issues_spec.rb
spec/requests/api/issues_spec.rb
+1
-1
issues_spec.rb
spec/requests/api/v3/issues_spec.rb
+1
-1
list_service_spec.rb
spec/services/boards/issues/list_service_spec.rb
+1
-1
move_service_spec.rb
spec/services/boards/issues/move_service_spec.rb
+1
-1
delete_merged_branches_service_spec.rb
spec/services/delete_merged_branches_service_spec.rb
+1
-1
get_urls_service_spec.rb
spec/services/merge_requests/get_urls_service_spec.rb
+1
-1
reopen_service_spec.rb
spec/services/merge_requests/reopen_service_spec.rb
+1
-1
No files found.
app/assets/javascripts/vue_merge_request_widget/stores/mr_widget_store.js
View file @
883be9c6
...
...
@@ -65,7 +65,7 @@ export default class MergeRequestStore {
this
.
mergeCheckPath
=
data
.
merge_check_path
;
this
.
mergeActionsContentPath
=
data
.
commit_change_content_path
;
this
.
isRemovingSourceBranch
=
this
.
isRemovingSourceBranch
||
false
;
this
.
isOpen
=
data
.
state
===
'opened'
||
data
.
state
===
'reopened'
||
false
;
this
.
isOpen
=
data
.
state
===
'opened'
;
this
.
hasMergeableDiscussionsState
=
data
.
mergeable_discussions_state
===
false
;
this
.
canRemoveSourceBranch
=
currentUser
.
can_remove_source_branch
||
false
;
this
.
canMerge
=
!!
data
.
merge_path
;
...
...
app/finders/issuable_finder.rb
View file @
883be9c6
...
...
@@ -81,7 +81,6 @@ class IssuableFinder
end
counts
[
:all
]
=
counts
.
values
.
sum
counts
[
:opened
]
+=
counts
[
:reopened
]
counts
end
...
...
app/models/concerns/issuable.rb
View file @
883be9c6
...
...
@@ -71,9 +71,8 @@ module Issuable
scope
:of_projects
,
->
(
ids
)
{
where
(
project_id:
ids
)
}
scope
:of_milestones
,
->
(
ids
)
{
where
(
milestone_id:
ids
)
}
scope
:with_milestone
,
->
(
title
)
{
left_joins_milestones
.
where
(
milestones:
{
title:
title
})
}
scope
:opened
,
->
{
with_state
(
:opened
,
:reopened
)
}
scope
:opened
,
->
{
with_state
(
:opened
)
}
scope
:only_opened
,
->
{
with_state
(
:opened
)
}
scope
:only_reopened
,
->
{
with_state
(
:reopened
)
}
scope
:closed
,
->
{
with_state
(
:closed
)
}
scope
:left_joins_milestones
,
->
{
joins
(
"LEFT OUTER JOIN milestones ON
#{
table_name
}
.milestone_id = milestones.id"
)
}
...
...
@@ -234,7 +233,7 @@ module Issuable
end
def
open?
opened?
||
reopened?
opened?
end
def
user_notes_count
...
...
app/models/issue.rb
View file @
883be9c6
...
...
@@ -62,15 +62,14 @@ class Issue < ActiveRecord::Base
state_machine
:state
,
initial: :opened
do
event
:close
do
transition
[
:
reopened
,
:
opened
]
=>
:closed
transition
[
:opened
]
=>
:closed
end
event
:reopen
do
transition
closed: :
re
opened
transition
closed: :opened
end
state
:opened
state
:reopened
state
:closed
before_transition
any
=>
:closed
do
|
issue
|
...
...
app/models/merge_request.rb
View file @
883be9c6
...
...
@@ -42,23 +42,23 @@ class MergeRequest < ActiveRecord::Base
state_machine
:state
,
initial: :opened
do
event
:close
do
transition
[
:
reopened
,
:
opened
]
=>
:closed
transition
[
:opened
]
=>
:closed
end
event
:mark_as_merged
do
transition
[
:
reopened
,
:
opened
,
:locked
]
=>
:merged
transition
[
:opened
,
:locked
]
=>
:merged
end
event
:reopen
do
transition
closed: :
re
opened
transition
closed: :opened
end
event
:lock_mr
do
transition
[
:
reopened
,
:
opened
]
=>
:locked
transition
[
:opened
]
=>
:locked
end
event
:unlock_mr
do
transition
locked: :
re
opened
transition
locked: :opened
end
after_transition
any
=>
:locked
do
|
merge_request
,
transition
|
...
...
@@ -72,7 +72,6 @@ class MergeRequest < ActiveRecord::Base
end
state
:opened
state
:reopened
state
:closed
state
:merged
state
:locked
...
...
@@ -368,7 +367,7 @@ class MergeRequest < ActiveRecord::Base
errors
.
add
:branch_conflict
,
"You can not use same project/branch for source and target"
end
if
opened?
||
reopened?
if
opened?
similar_mrs
=
self
.
target_project
.
merge_requests
.
where
(
source_branch:
source_branch
,
target_branch:
target_branch
,
source_project_id:
source_project
.
try
(
:id
)).
opened
similar_mrs
=
similar_mrs
.
where
(
'id not in (?)'
,
self
.
id
)
if
self
.
id
if
similar_mrs
.
any?
...
...
app/models/project_services/drone_ci_service.rb
View file @
883be9c6
...
...
@@ -114,7 +114,7 @@ class DroneCiService < CiService
end
def
merge_request_valid?
(
data
)
%w(opened reopened)
.
include?
(
data
[
:object_attributes
][
:state
])
&&
data
[
:object_attributes
][
:state
]
==
'opened'
&&
data
[
:object_attributes
][
:merge_status
]
==
'unchecked'
end
end
app/services/issues/reopen_service.rb
View file @
883be9c6
...
...
@@ -5,7 +5,7 @@ module Issues
if
issue
.
reopen
event_service
.
reopen_issue
(
issue
,
current_user
)
create_note
(
issue
)
create_note
(
issue
,
'reopened'
)
notification_service
.
reopen_issue
(
issue
,
current_user
)
execute_hooks
(
issue
,
'reopen'
)
invalidate_cache_counts
(
issue
,
users:
issue
.
assignees
)
...
...
@@ -16,8 +16,8 @@ module Issues
private
def
create_note
(
issue
)
SystemNoteService
.
change_status
(
issue
,
issue
.
project
,
current_user
,
issue
.
state
,
nil
)
def
create_note
(
issue
,
state
=
issue
.
state
)
SystemNoteService
.
change_status
(
issue
,
issue
.
project
,
current_user
,
state
,
nil
)
end
end
end
app/services/merge_requests/base_service.rb
View file @
883be9c6
module
MergeRequests
class
BaseService
<
::
IssuableBaseService
def
create_note
(
merge_request
)
SystemNoteService
.
change_status
(
merge_request
,
merge_request
.
target_project
,
current_user
,
merge_request
.
state
,
nil
)
def
create_note
(
merge_request
,
state
=
merge_request
.
state
)
SystemNoteService
.
change_status
(
merge_request
,
merge_request
.
target_project
,
current_user
,
state
,
nil
)
end
def
create_title_change_note
(
issuable
,
old_title
)
...
...
@@ -44,7 +44,7 @@ module MergeRequests
end
# Returns all origin and fork merge requests from `@project` satisfying passed arguments.
def
merge_requests_for
(
source_branch
,
mr_states:
[
:opened
,
:reopened
])
def
merge_requests_for
(
source_branch
,
mr_states:
[
:opened
])
MergeRequest
.
with_state
(
mr_states
)
.
where
(
source_branch:
source_branch
,
source_project_id:
@project
.
id
)
...
...
app/services/merge_requests/reopen_service.rb
View file @
883be9c6
...
...
@@ -5,7 +5,7 @@ module MergeRequests
if
merge_request
.
reopen
event_service
.
reopen_mr
(
merge_request
,
current_user
)
create_note
(
merge_request
)
create_note
(
merge_request
,
'reopened'
)
notification_service
.
reopen_mr
(
merge_request
,
current_user
)
execute_hooks
(
merge_request
,
'reopen'
)
merge_request
.
reload_diff
(
current_user
)
...
...
changelogs/unreleased/merge-issuable-reopened-into-opened-state.yml
0 → 100644
View file @
883be9c6
---
title
:
Merge issuable "reopened" state into "opened"
merge_request
:
author
:
db/post_migrate/20170719150301_merge_issuable_reopened_into_opened_state.rb
0 → 100644
View file @
883be9c6
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
class
MergeIssuableReopenedIntoOpenedState
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
disable_ddl_transaction!
class
Issue
<
ActiveRecord
::
Base
self
.
table_name
=
'issues'
include
EachBatch
end
class
MergeRequest
<
ActiveRecord
::
Base
self
.
table_name
=
'merge_requests'
include
EachBatch
end
def
up
[
Issue
,
MergeRequest
].
each
do
|
model
|
say
"Changing
#{
model
.
table_name
}
.state from 'reopened' to 'opened'"
model
.
where
(
state:
'reopened'
).
each_batch
do
|
batch
|
batch
.
update_all
(
state:
'opened'
)
end
end
end
end
spec/factories/issues.rb
View file @
883be9c6
...
...
@@ -16,12 +16,8 @@ FactoryGirl.define do
state
:closed
end
trait
:reopened
do
state
:reopened
end
factory
:closed_issue
,
traits:
[
:closed
]
factory
:reopened_issue
,
traits:
[
:
re
opened
]
factory
:reopened_issue
,
traits:
[
:opened
]
factory
:labeled_issue
do
transient
do
...
...
spec/factories/merge_requests.rb
View file @
883be9c6
...
...
@@ -44,10 +44,6 @@ FactoryGirl.define do
state
:opened
end
trait
:reopened
do
state
:reopened
end
trait
:locked
do
state
:locked
end
...
...
@@ -74,7 +70,7 @@ FactoryGirl.define do
factory
:merged_merge_request
,
traits:
[
:merged
]
factory
:closed_merge_request
,
traits:
[
:closed
]
factory
:reopened_merge_request
,
traits:
[
:
re
opened
]
factory
:reopened_merge_request
,
traits:
[
:opened
]
factory
:merge_request_with_diffs
,
traits:
[
:with_diffs
]
factory
:merge_request_with_diff_notes
do
after
(
:create
)
do
|
mr
|
...
...
spec/lib/banzai/filter/issuable_state_filter_spec.rb
View file @
883be9c6
...
...
@@ -107,14 +107,6 @@ describe Banzai::Filter::IssuableStateFilter do
expect
(
doc
.
css
(
'a'
).
last
.
text
).
to
eq
(
issue
.
to_reference
)
end
it
'ignores reopened issue references'
do
issue
=
create_issue
(
:reopened
)
link
=
create_link
(
issue
.
to_reference
,
issue:
issue
.
id
,
reference_type:
'issue'
)
doc
=
filter
(
link
,
context
)
expect
(
doc
.
css
(
'a'
).
last
.
text
).
to
eq
(
issue
.
to_reference
)
end
it
'appends state to closed issue references'
do
link
=
create_link
(
closed_issue
.
to_reference
,
issue:
closed_issue
.
id
,
reference_type:
'issue'
)
doc
=
filter
(
link
,
context
)
...
...
@@ -139,7 +131,7 @@ describe Banzai::Filter::IssuableStateFilter do
end
it
'ignores reopened merge request references'
do
merge_request
=
create_merge_request
(
:
re
opened
)
merge_request
=
create_merge_request
(
:opened
)
link
=
create_link
(
merge_request
.
to_reference
,
...
...
spec/requests/api/issues_spec.rb
View file @
883be9c6
...
...
@@ -1259,7 +1259,7 @@ describe API::Issues do
put
api
(
"/projects/
#{
project
.
id
}
/issues/
#{
closed_issue
.
iid
}
"
,
user
),
state_event:
'reopen'
expect
(
response
).
to
have_http_status
(
200
)
expect
(
json_response
[
'state'
]).
to
eq
'
re
opened'
expect
(
json_response
[
'state'
]).
to
eq
'opened'
end
context
'when an admin or owner makes the request'
do
...
...
spec/requests/api/v3/issues_spec.rb
View file @
883be9c6
...
...
@@ -1114,7 +1114,7 @@ describe API::V3::Issues do
put
v3_api
(
"/projects/
#{
project
.
id
}
/issues/
#{
closed_issue
.
id
}
"
,
user
),
state_event:
'reopen'
expect
(
response
).
to
have_http_status
(
200
)
expect
(
json_response
[
'state'
]).
to
eq
'
re
opened'
expect
(
json_response
[
'state'
]).
to
eq
'opened'
end
context
'when an admin or owner makes the request'
do
...
...
spec/services/boards/issues/list_service_spec.rb
View file @
883be9c6
...
...
@@ -20,7 +20,7 @@ describe Boards::Issues::ListService do
let!
(
:opened_issue1
)
{
create
(
:labeled_issue
,
project:
project
,
labels:
[
bug
])
}
let!
(
:opened_issue2
)
{
create
(
:labeled_issue
,
project:
project
,
labels:
[
p2
])
}
let!
(
:reopened_issue1
)
{
create
(
:issue
,
:
re
opened
,
project:
project
)
}
let!
(
:reopened_issue1
)
{
create
(
:issue
,
:opened
,
project:
project
)
}
let!
(
:list1_issue1
)
{
create
(
:labeled_issue
,
project:
project
,
labels:
[
p2
,
development
])
}
let!
(
:list1_issue2
)
{
create
(
:labeled_issue
,
project:
project
,
labels:
[
development
])
}
...
...
spec/services/boards/issues/move_service_spec.rb
View file @
883be9c6
...
...
@@ -73,7 +73,7 @@ describe Boards::Issues::MoveService do
issue
.
reload
expect
(
issue
.
labels
).
to
contain_exactly
(
bug
,
testing
)
expect
(
issue
).
to
be_
re
opened
expect
(
issue
).
to
be_opened
end
end
...
...
spec/services/delete_merged_branches_service_spec.rb
View file @
883be9c6
...
...
@@ -43,7 +43,7 @@ describe DeleteMergedBranchesService do
context
'open merge requests'
do
it
'does not delete branches from open merge requests'
do
fork_link
=
create
(
:forked_project_link
,
forked_from_project:
project
)
create
(
:merge_request
,
:
re
opened
,
source_project:
project
,
target_project:
project
,
source_branch:
'branch-merged'
,
target_branch:
'master'
)
create
(
:merge_request
,
:opened
,
source_project:
project
,
target_project:
project
,
source_branch:
'branch-merged'
,
target_branch:
'master'
)
create
(
:merge_request
,
:opened
,
source_project:
fork_link
.
forked_to_project
,
target_project:
project
,
target_branch:
'improve/awesome'
,
source_branch:
'master'
)
service
.
execute
...
...
spec/services/merge_requests/get_urls_service_spec.rb
View file @
883be9c6
...
...
@@ -78,7 +78,7 @@ describe MergeRequests::GetUrlsService do
end
context
'pushing to existing branch and merge request is reopened'
do
let!
(
:merge_request
)
{
create
(
:merge_request
,
:
re
opened
,
source_project:
project
,
source_branch:
source_branch
)
}
let!
(
:merge_request
)
{
create
(
:merge_request
,
:opened
,
source_project:
project
,
source_branch:
source_branch
)
}
let
(
:changes
)
{
existing_branch_changes
}
it_behaves_like
'show_merge_request_url'
end
...
...
spec/services/merge_requests/reopen_service_spec.rb
View file @
883be9c6
...
...
@@ -28,7 +28,7 @@ describe MergeRequests::ReopenService do
end
it
{
expect
(
merge_request
).
to
be_valid
}
it
{
expect
(
merge_request
).
to
be_
re
opened
}
it
{
expect
(
merge_request
).
to
be_opened
}
it
'executes hooks with reopen action'
do
expect
(
service
).
to
have_received
(
:execute_hooks
)
...
...
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