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
Jérome Perrin
gitlab-ce
Commits
db377437
Commit
db377437
authored
Apr 20, 2018
by
Sean McGivern
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make /copy_metadata only handle the first issuable passed
parent
78aebc49
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
13 deletions
+24
-13
app/services/quick_actions/interpret_service.rb
app/services/quick_actions/interpret_service.rb
+7
-7
doc/user/project/quick_actions.md
doc/user/project/quick_actions.md
+4
-4
spec/services/quick_actions/interpret_service_spec.rb
spec/services/quick_actions/interpret_service_spec.rb
+13
-2
No files found.
app/services/quick_actions/interpret_service.rb
View file @
db377437
...
...
@@ -269,21 +269,21 @@ module QuickActions
end
desc
'Copy labels and milestone from other issue or merge request'
explanation
do
|
issuable_id
|
"Copy labels and milestone from
issue or merge_request
#{
issuable_id
}
."
explanation
do
|
source_issuable
|
"Copy labels and milestone from
#{
source_issuable
.
to_reference
}
."
end
params
'#issue | !merge_request'
condition
do
issuable
.
persisted?
&&
current_user
.
can?
(
:"update_
#{
issuable
.
to_ability_name
}
"
,
issuable
)
end
command
:copy_metadata
do
|
issuable_id
|
source_issuable
=
extract_references
(
issuable_id
,
:issue
).
first
source_issuable
||=
extract_references
(
issuable_id
,
:merge_request
).
first
parse_params
do
|
issuable_param
|
extract_references
(
issuable_param
,
:issue
).
first
||
extract_references
(
issuable_param
,
:merge_request
).
first
end
command
:copy_metadata
do
|
source_issuable
|
if
source_issuable
.
present?
&&
source_issuable
.
project
.
id
==
issuable
.
project
.
id
@updates
[
:add_label_ids
]
=
source_issuable
.
labels
.
map
(
&
:id
)
@updates
[
:milestone_id
]
=
source_issuable
.
milestone
.
id
if
source_issuable
.
milestone
end
end
...
...
doc/user/project/quick_actions.md
View file @
db377437
...
...
@@ -38,7 +38,7 @@ do.
|
`/award :emoji:`
| Toggle award for :emoji: |
|
`/board_move ~column`
| Move issue to column on the board |
|
`/duplicate #issue`
| Closes this issue and marks it as a duplicate of another issue |
|
`/move path/to/project`
| Moves issue to another project |
|
`/tableflip`
| Append the comment with
`(╯°□°)╯︵ ┻━┻`
|
|
`/shrug`
| Append the comment with
`¯\_(ツ)_/¯`
|
|
<code>
/copy_metadata #issue
|
!merge_request
</code>
| Copy labels and milestone from other issue or merge request |
|
`/move path/to/project`
| Moves issue to another project |
|
`/tableflip`
| Append the comment with
`(╯°□°)╯︵ ┻━┻`
|
|
`/shrug`
| Append the comment with
`¯\_(ツ)_/¯`
|
|
<code>
/copy_metadata #issue
|
!merge_request
</code>
| Copy labels and milestone from other issue or merge request |
spec/services/quick_actions/interpret_service_spec.rb
View file @
db377437
...
...
@@ -775,8 +775,8 @@ describe QuickActions::InterpretService do
end
context
'/copy_metadata command'
do
let
!
(
:todo_label
)
{
create
(
:label
,
project:
project
,
title:
'To Do'
)
}
let
!
(
:inreview_label
)
{
create
(
:label
,
project:
project
,
title:
'In Review'
)
}
let
(
:todo_label
)
{
create
(
:label
,
project:
project
,
title:
'To Do'
)
}
let
(
:inreview_label
)
{
create
(
:label
,
project:
project
,
title:
'In Review'
)
}
it_behaves_like
'empty command'
do
let
(
:content
)
{
'/copy_metadata'
}
...
...
@@ -799,6 +799,17 @@ describe QuickActions::InterpretService do
end
end
context
'when more than one issuable is passed'
do
it_behaves_like
'copy_metadata command'
do
let
(
:source_issuable
)
{
create
(
:labeled_issue
,
project:
project
,
labels:
[
inreview_label
,
todo_label
])
}
let
(
:other_label
)
{
create
(
:label
,
project:
project
,
title:
'Other'
)
}
let
(
:other_source_issuable
)
{
create
(
:labeled_issue
,
project:
project
,
labels:
[
other_label
])
}
let
(
:content
)
{
"/copy_metadata
#{
source_issuable
.
to_reference
}
#{
other_source_issuable
.
to_reference
}
"
}
let
(
:issuable
)
{
issue
}
end
end
context
'cross project references'
do
it_behaves_like
'empty command'
do
let
(
:other_project
)
{
create
(
:project
,
:public
)
}
...
...
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