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
Léo-Paul Géneau
gitlab-ce
Commits
26087ae9
Commit
26087ae9
authored
Jan 31, 2018
by
Mateusz Bajorski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed typos and improved reference checking
parent
a0adf877
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
23 deletions
+23
-23
app/services/quick_actions/interpret_service.rb
app/services/quick_actions/interpret_service.rb
+9
-9
changelogs/unreleased/add-copy-metadata-command.yml
changelogs/unreleased/add-copy-metadata-command.yml
+1
-1
doc/user/project/quick_actions.md
doc/user/project/quick_actions.md
+1
-1
spec/services/quick_actions/interpret_service_spec.rb
spec/services/quick_actions/interpret_service_spec.rb
+12
-12
No files found.
app/services/quick_actions/interpret_service.rb
View file @
26087ae9
...
@@ -269,22 +269,22 @@ module QuickActions
...
@@ -269,22 +269,22 @@ module QuickActions
end
end
desc
'Copy labels and milestone from other issue or merge request'
desc
'Copy labels and milestone from other issue or merge request'
explanation
do
|
issu
e
able_id
|
explanation
do
|
issuable_id
|
"Copy labels and milestone from issue or merge_request
\"
#{
issu
e
able_id
}
\"
."
"Copy labels and milestone from issue or merge_request
\"
#{
issuable_id
}
\"
."
end
end
params
'
< #issue | !merge_request >
'
params
'
#issue | !merge_request
'
condition
do
condition
do
issuable
.
persisted?
&&
issuable
.
persisted?
&&
current_user
.
can?
(
:"update_
#{
issuable
.
to_ability_name
}
"
,
issuable
)
current_user
.
can?
(
:"update_
#{
issuable
.
to_ability_name
}
"
,
issuable
)
end
end
command
:copy_metadata
do
|
issu
e
able_id
|
command
:copy_metadata
do
|
issuable_id
|
reference_type
=
issueable_id
.
include?
(
"#"
)
?
:issue
:
:merge_reque
st
source_issuable
=
extract_references
(
issuable_id
,
:issue
).
fir
st
issue
=
extract_references
(
issueable_id
,
reference_type
).
first
source_issuable
=
extract_references
(
issuable_id
,
:merge_request
).
first
if
!
source_issuable
.
present?
if
issue
.
present?
&&
issu
e
.
project
.
id
==
issuable
.
project
.
id
if
source_issuable
.
present?
&&
source_issuabl
e
.
project
.
id
==
issuable
.
project
.
id
@updates
[
:add_label_ids
]
=
issu
e
.
labels
.
map
(
&
:id
)
@updates
[
:add_label_ids
]
=
source_issuabl
e
.
labels
.
map
(
&
:id
)
@updates
[
:milestone_id
]
=
issue
.
milestone
.
id
if
issu
e
.
milestone
@updates
[
:milestone_id
]
=
source_issuable
.
milestone
.
id
if
source_issuabl
e
.
milestone
end
end
end
end
...
...
changelogs/unreleased/add-
inherit
-command.yml
→
changelogs/unreleased/add-
copy-metadata
-command.yml
View file @
26087ae9
---
---
title
:
Add
Inherit
quick action
title
:
Add
Copy metadata
quick action
merge_request
:
16473
merge_request
:
16473
author
:
Mateusz Bajorski
author
:
Mateusz Bajorski
type
:
added
type
:
added
doc/user/project/quick_actions.md
View file @
26087ae9
...
@@ -41,4 +41,4 @@ do.
...
@@ -41,4 +41,4 @@ do.
|
`/move path/to/project`
| Moves issue to another project |
|
`/move path/to/project`
| Moves issue to another project |
|
`/tableflip`
| Append the comment with
`(╯°□°)╯︵ ┻━┻`
|
|
`/tableflip`
| Append the comment with
`(╯°□°)╯︵ ┻━┻`
|
|
`/shrug`
| Append the comment with
`¯\_(ツ)_/¯`
|
|
`/shrug`
| Append the comment with
`¯\_(ツ)_/¯`
|
|
<code>
/copy_metadata
<
#issue
|
!merge_request
>
</code>
|
copy_metadata
labels and milestone from other issue or merge request |
|
<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 @
26087ae9
...
@@ -308,15 +308,15 @@ describe QuickActions::InterpretService do
...
@@ -308,15 +308,15 @@ describe QuickActions::InterpretService do
shared_examples
'copy_metadata command'
do
shared_examples
'copy_metadata command'
do
it
'fetches issue or merge request and copies labels and milestone if content contains /copy_metadata reference'
do
it
'fetches issue or merge request and copies labels and milestone if content contains /copy_metadata reference'
do
issueable_father
# populate the issue
source_issuable
# populate the issue
todo_label
# populate this label
todo_label
# populate this label
inreview_label
# populate this label
inreview_label
# populate this label
_
,
updates
=
service
.
execute
(
content
,
issuable
)
_
,
updates
=
service
.
execute
(
content
,
issuable
)
expect
(
updates
[
:add_label_ids
]).
to
match_array
([
inreview_label
.
id
,
todo_label
.
id
])
expect
(
updates
[
:add_label_ids
]).
to
match_array
([
inreview_label
.
id
,
todo_label
.
id
])
if
issueable_father
.
milestone
if
source_issuable
.
milestone
expect
(
updates
[
:milestone_id
]).
to
eq
(
issueable_father
.
milestone
.
id
)
expect
(
updates
[
:milestone_id
]).
to
eq
(
source_issuable
.
milestone
.
id
)
else
else
expect
(
updates
).
not_to
have_key
(
:milestone_id
)
expect
(
updates
).
not_to
have_key
(
:milestone_id
)
end
end
...
@@ -784,17 +784,17 @@ describe QuickActions::InterpretService do
...
@@ -784,17 +784,17 @@ describe QuickActions::InterpretService do
end
end
it_behaves_like
'copy_metadata command'
do
it_behaves_like
'copy_metadata command'
do
let
(
:
issueable_father
)
{
create
(
:labeled_issue
,
project:
project
,
labels:
[
inreview_label
,
todo_label
])
}
let
(
:
source_issuable
)
{
create
(
:labeled_issue
,
project:
project
,
labels:
[
inreview_label
,
todo_label
])
}
let
(
:content
)
{
"/copy_metadata
#{
issueable_father
.
to_reference
}
"
}
let
(
:content
)
{
"/copy_metadata
#{
source_issuable
.
to_reference
}
"
}
let
(
:issuable
)
{
issue
}
let
(
:issuable
)
{
issue
}
end
end
context
'when the parent issu
e
able has a milestone'
do
context
'when the parent issuable has a milestone'
do
it_behaves_like
'copy_metadata command'
do
it_behaves_like
'copy_metadata command'
do
let
(
:
issueable_father
)
{
create
(
:labeled_issue
,
project:
project
,
labels:
[
todo_label
,
inreview_label
],
milestone:
milestone
)
}
let
(
:
source_issuable
)
{
create
(
:labeled_issue
,
project:
project
,
labels:
[
todo_label
,
inreview_label
],
milestone:
milestone
)
}
let
(
:content
)
{
"/copy_metadata
#{
issueable_father
.
to_reference
(
project
)
}
"
}
let
(
:content
)
{
"/copy_metadata
#{
source_issuable
.
to_reference
(
project
)
}
"
}
let
(
:issuable
)
{
issue
}
let
(
:issuable
)
{
issue
}
end
end
end
end
...
@@ -802,8 +802,8 @@ describe QuickActions::InterpretService do
...
@@ -802,8 +802,8 @@ describe QuickActions::InterpretService do
context
'cross project references'
do
context
'cross project references'
do
it_behaves_like
'empty command'
do
it_behaves_like
'empty command'
do
let
(
:other_project
)
{
create
(
:project
,
:public
)
}
let
(
:other_project
)
{
create
(
:project
,
:public
)
}
let
(
:
issueable_father
)
{
create
(
:labeled_issue
,
project:
other_project
,
labels:
[
todo_label
,
inreview_label
])
}
let
(
:
source_issuable
)
{
create
(
:labeled_issue
,
project:
other_project
,
labels:
[
todo_label
,
inreview_label
])
}
let
(
:content
)
{
"/copy_metadata
#{
issueable_father
.
to_reference
(
project
)
}
"
}
let
(
:content
)
{
"/copy_metadata
#{
source_issuable
.
to_reference
(
project
)
}
"
}
let
(
:issuable
)
{
issue
}
let
(
:issuable
)
{
issue
}
end
end
...
@@ -814,9 +814,9 @@ describe QuickActions::InterpretService do
...
@@ -814,9 +814,9 @@ describe QuickActions::InterpretService do
it_behaves_like
'empty command'
do
it_behaves_like
'empty command'
do
let
(
:other_project
)
{
create
(
:project
,
:private
)
}
let
(
:other_project
)
{
create
(
:project
,
:private
)
}
let
(
:
issueable_father
)
{
create
(
:issue
,
project:
other_project
)
}
let
(
:
source_issuable
)
{
create
(
:issue
,
project:
other_project
)
}
let
(
:content
)
{
"/copy_metadata
#{
issueable_father
.
to_reference
(
project
)
}
"
}
let
(
:content
)
{
"/copy_metadata
#{
source_issuable
.
to_reference
(
project
)
}
"
}
let
(
:issuable
)
{
issue
}
let
(
:issuable
)
{
issue
}
end
end
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