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
d009d38e
Commit
d009d38e
authored
Oct 18, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
User Labes::CreateService to create labels
parent
6c189dcc
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
17 additions
and
20 deletions
+17
-20
app/models/project.rb
app/models/project.rb
+2
-1
app/services/boards/lists/generate_service.rb
app/services/boards/lists/generate_service.rb
+1
-2
app/services/issuable_base_service.rb
app/services/issuable_base_service.rb
+2
-2
app/services/labels/transfer_service.rb
app/services/labels/transfer_service.rb
+2
-6
lib/gitlab/fogbugz_import/importer.rb
lib/gitlab/fogbugz_import/importer.rb
+2
-2
lib/gitlab/github_import/label_formatter.rb
lib/gitlab/github_import/label_formatter.rb
+4
-3
lib/gitlab/google_code_import/importer.rb
lib/gitlab/google_code_import/importer.rb
+2
-2
lib/gitlab/issues_labels.rb
lib/gitlab/issues_labels.rb
+2
-2
No files found.
app/models/project.rb
View file @
d009d38e
...
@@ -733,7 +733,8 @@ class Project < ActiveRecord::Base
...
@@ -733,7 +733,8 @@ class Project < ActiveRecord::Base
def
create_labels
def
create_labels
Label
.
templates
.
each
do
|
label
|
Label
.
templates
.
each
do
|
label
|
self
.
labels
.
create!
(
label
.
attributes
.
symbolize_keys
.
except
(
:id
,
:template
))
params
=
label
.
attributes
.
except
(
'id'
,
'template'
,
'created_at'
,
'updated_at'
)
Labels
::
CreateService
.
new
(
owner
,
self
,
params
).
execute
end
end
end
end
...
...
app/services/boards/lists/generate_service.rb
View file @
d009d38e
...
@@ -19,8 +19,7 @@ module Boards
...
@@ -19,8 +19,7 @@ module Boards
end
end
def
find_or_create_label
(
params
)
def
find_or_create_label
(
params
)
project
.
labels
.
create_with
(
color:
params
[
:color
])
::
Labels
::
CreateService
.
new
(
current_user
,
project
,
params
).
execute
.
find_or_create_by
(
name:
params
[
:name
])
end
end
def
label_params
def
label_params
...
...
app/services/issuable_base_service.rb
View file @
d009d38e
...
@@ -88,8 +88,8 @@ class IssuableBaseService < BaseService
...
@@ -88,8 +88,8 @@ class IssuableBaseService < BaseService
return
unless
labels
return
unless
labels
params
[
:label_ids
]
=
labels
.
split
(
','
).
map
do
|
label_name
|
params
[
:label_ids
]
=
labels
.
split
(
','
).
map
do
|
label_name
|
label
=
available_labels
.
find_by
(
title:
label_name
)
service
=
Labels
::
CreateService
.
new
(
current_user
,
project
,
title:
label_name
.
strip
)
label
||=
project
.
labels
.
create
(
title:
label_name
.
strip
,
color:
Label
::
DEFAULT_COLOR
)
label
=
service
.
execute
label
.
id
label
.
id
end
end
...
...
app/services/labels/transfer_service.rb
View file @
d009d38e
...
@@ -41,13 +41,9 @@ module Labels
...
@@ -41,13 +41,9 @@ module Labels
LabelLink
.
where
(
"label_links.id IN (
#{
union
.
to_sql
}
)"
)
LabelLink
.
where
(
"label_links.id IN (
#{
union
.
to_sql
}
)"
)
end
end
def
labels
@labels
||=
LabelsFinder
.
new
(
current_user
,
project_id:
project
.
id
).
execute
end
def
find_or_create_label!
(
label
)
def
find_or_create_label!
(
label
)
new_label
=
labels
.
find_by
(
title:
label
.
title
)
params
=
label
.
attributes
.
slice
(
'title'
,
'description'
,
'color'
)
new_label
||=
project
.
labels
.
create!
(
label
.
attributes
.
slice
(
"title"
,
"description"
,
"color"
))
new_label
=
CreateService
.
new
(
current_user
,
project
,
params
).
execute
new_label
.
id
new_label
.
id
end
end
...
...
lib/gitlab/fogbugz_import/importer.rb
View file @
d009d38e
...
@@ -74,8 +74,8 @@ module Gitlab
...
@@ -74,8 +74,8 @@ module Gitlab
end
end
def
create_label
(
name
)
def
create_label
(
name
)
color
=
nice_label_color
(
name
)
params
=
{
title:
name
,
color:
nice_label_color
(
name
)
}
Label
.
create!
(
project_id:
project
.
id
,
title:
name
,
color:
color
)
::
Labels
::
CreateService
.
new
(
project
.
owner
,
project
,
params
).
execute
end
end
def
user_info
(
person_id
)
def
user_info
(
person_id
)
...
...
lib/gitlab/github_import/label_formatter.rb
View file @
d009d38e
...
@@ -14,9 +14,10 @@ module Gitlab
...
@@ -14,9 +14,10 @@ module Gitlab
end
end
def
create!
def
create!
project
.
labels
.
find_or_create_by!
(
title:
title
)
do
|
label
|
params
=
attributes
.
except
(
:project
)
label
.
color
=
color
service
=
::
Labels
::
CreateService
.
new
(
project
.
owner
,
project
,
params
)
end
service
.
execute
end
end
private
private
...
...
lib/gitlab/google_code_import/importer.rb
View file @
d009d38e
...
@@ -233,8 +233,8 @@ module Gitlab
...
@@ -233,8 +233,8 @@ module Gitlab
end
end
def
create_label
(
name
)
def
create_label
(
name
)
color
=
nice_label_color
(
name
)
params
=
{
name:
name
,
color:
nice_label_color
(
name
)
}
project
.
labels
.
create!
(
name:
name
,
color:
color
)
::
Labels
::
CreateService
.
new
(
project
.
owner
,
project
,
params
).
execute
end
end
def
format_content
(
raw_content
)
def
format_content
(
raw_content
)
...
...
lib/gitlab/issues_labels.rb
View file @
d009d38e
...
@@ -18,8 +18,8 @@ module Gitlab
...
@@ -18,8 +18,8 @@ module Gitlab
{
title:
"enhancement"
,
color:
green
}
{
title:
"enhancement"
,
color:
green
}
]
]
labels
.
each
do
|
label
|
labels
.
each
do
|
params
|
project
.
labels
.
create
(
label
)
::
Labels
::
CreateService
.
new
(
project
.
owner
,
project
).
execute
(
params
)
end
end
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