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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
20b6974a
Commit
20b6974a
authored
Sep 26, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Issuable#add_labels_by_names to validate if label exists on group
parent
b654229d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
2 deletions
+12
-2
app/models/concerns/issuable.rb
app/models/concerns/issuable.rb
+12
-2
No files found.
app/models/concerns/issuable.rb
View file @
20b6974a
...
...
@@ -235,9 +235,19 @@ module Issuable
end
def
add_labels_by_names
(
label_names
)
label_ids
=
[]
label_ids
<<
project
.
group
.
labels
.
select
(
:id
)
if
project
.
group
.
present?
label_ids
<<
project
.
labels
.
select
(
:id
)
union
=
Gitlab
::
SQL
::
Union
.
new
(
label_ids
)
available_labels
=
Label
.
where
(
"labels.id IN (
#{
union
.
to_sql
}
)"
)
label_names
.
each
do
|
label_name
|
label
=
project
.
labels
.
create_with
(
color:
Label
::
DEFAULT_COLOR
).
find_or_create_by
(
title:
label_name
.
strip
)
title
=
label_name
.
strip
label
=
available_labels
.
find_by
(
title:
title
)
label
=
project
.
labels
.
build
(
title:
title
,
color:
Label
::
DEFAULT_COLOR
)
if
label
.
nil?
self
.
labels
<<
label
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