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
Boxiang Sun
gitlab-ce
Commits
d9715266
Commit
d9715266
authored
Aug 12, 2016
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow setting labels, milestones and assignee based on name
parent
463ae8f5
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
3 deletions
+9
-3
app/services/slash_commands/interpret_service.rb
app/services/slash_commands/interpret_service.rb
+9
-3
No files found.
app/services/slash_commands/interpret_service.rb
View file @
d9715266
...
@@ -74,6 +74,8 @@ module SlashCommands
...
@@ -74,6 +74,8 @@ module SlashCommands
end
end
command
:assign
,
:reassign
do
|
assignee_param
|
command
:assign
,
:reassign
do
|
assignee_param
|
user
=
extract_references
(
assignee_param
,
:user
).
first
user
=
extract_references
(
assignee_param
,
:user
).
first
user
||=
User
.
find_by
(
username:
assignee_param
)
user
||=
User
.
find_by
(
name:
assignee_param
)
@updates
[
:assignee_id
]
=
user
.
id
if
user
@updates
[
:assignee_id
]
=
user
.
id
if
user
end
end
...
@@ -95,6 +97,7 @@ module SlashCommands
...
@@ -95,6 +97,7 @@ module SlashCommands
end
end
command
:milestone
do
|
milestone_param
|
command
:milestone
do
|
milestone_param
|
milestone
=
extract_references
(
milestone_param
,
:milestone
).
first
milestone
=
extract_references
(
milestone_param
,
:milestone
).
first
milestone
||=
project
.
milestones
.
find_by
(
title:
milestone_param
.
strip
)
@updates
[
:milestone_id
]
=
milestone
.
id
if
milestone
@updates
[
:milestone_id
]
=
milestone
.
id
if
milestone
end
end
...
@@ -204,12 +207,15 @@ module SlashCommands
...
@@ -204,12 +207,15 @@ module SlashCommands
command
:cc
,
noop:
true
command
:cc
,
noop:
true
def
find_label_ids
(
labels_param
)
def
find_label_ids
(
labels_param
)
extract_references
(
labels_param
,
:label
).
map
(
&
:id
)
label_ids_by_reference
=
extract_references
(
labels_param
,
:label
).
map
(
&
:id
)
labels_ids_by_name
=
@project
.
labels
.
where
(
name:
labels_param
.
split
).
select
(
:id
)
label_ids_by_reference
|
labels_ids_by_name
end
end
def
extract_references
(
cmd_
arg
,
type
)
def
extract_references
(
arg
,
type
)
ext
=
Gitlab
::
ReferenceExtractor
.
new
(
project
,
current_user
)
ext
=
Gitlab
::
ReferenceExtractor
.
new
(
project
,
current_user
)
ext
.
analyze
(
cmd_
arg
,
author:
current_user
)
ext
.
analyze
(
arg
,
author:
current_user
)
ext
.
references
(
type
)
ext
.
references
(
type
)
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