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
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
def
create_labels
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
...
...
app/services/boards/lists/generate_service.rb
View file @
d009d38e
...
...
@@ -19,8 +19,7 @@ module Boards
end
def
find_or_create_label
(
params
)
project
.
labels
.
create_with
(
color:
params
[
:color
])
.
find_or_create_by
(
name:
params
[
:name
])
::
Labels
::
CreateService
.
new
(
current_user
,
project
,
params
).
execute
end
def
label_params
...
...
app/services/issuable_base_service.rb
View file @
d009d38e
...
...
@@ -88,8 +88,8 @@ class IssuableBaseService < BaseService
return
unless
labels
params
[
:label_ids
]
=
labels
.
split
(
','
).
map
do
|
label_name
|
label
=
available_labels
.
find_by
(
title:
label_name
)
label
||=
project
.
labels
.
create
(
title:
label_name
.
strip
,
color:
Label
::
DEFAULT_COLOR
)
service
=
Labels
::
CreateService
.
new
(
current_user
,
project
,
title:
label_name
.
strip
)
label
=
service
.
execute
label
.
id
end
...
...
app/services/labels/transfer_service.rb
View file @
d009d38e
...
...
@@ -41,13 +41,9 @@ module Labels
LabelLink
.
where
(
"label_links.id IN (
#{
union
.
to_sql
}
)"
)
end
def
labels
@labels
||=
LabelsFinder
.
new
(
current_user
,
project_id:
project
.
id
).
execute
end
def
find_or_create_label!
(
label
)
new_label
=
labels
.
find_by
(
title:
label
.
title
)
new_label
||=
project
.
labels
.
create!
(
label
.
attributes
.
slice
(
"title"
,
"description"
,
"color"
))
params
=
label
.
attributes
.
slice
(
'title'
,
'description'
,
'color'
)
new_label
=
CreateService
.
new
(
current_user
,
project
,
params
).
execute
new_label
.
id
end
...
...
lib/gitlab/fogbugz_import/importer.rb
View file @
d009d38e
...
...
@@ -74,8 +74,8 @@ module Gitlab
end
def
create_label
(
name
)
color
=
nice_label_color
(
name
)
Label
.
create!
(
project_id:
project
.
id
,
title:
name
,
color:
color
)
params
=
{
title:
name
,
color:
nice_label_color
(
name
)
}
::
Labels
::
CreateService
.
new
(
project
.
owner
,
project
,
params
).
execute
end
def
user_info
(
person_id
)
...
...
lib/gitlab/github_import/label_formatter.rb
View file @
d009d38e
...
...
@@ -14,9 +14,10 @@ module Gitlab
end
def
create!
project
.
labels
.
find_or_create_by!
(
title:
title
)
do
|
label
|
label
.
color
=
color
end
params
=
attributes
.
except
(
:project
)
service
=
::
Labels
::
CreateService
.
new
(
project
.
owner
,
project
,
params
)
service
.
execute
end
private
...
...
lib/gitlab/google_code_import/importer.rb
View file @
d009d38e
...
...
@@ -233,8 +233,8 @@ module Gitlab
end
def
create_label
(
name
)
color
=
nice_label_color
(
name
)
project
.
labels
.
create!
(
name:
name
,
color:
color
)
params
=
{
name:
name
,
color:
nice_label_color
(
name
)
}
::
Labels
::
CreateService
.
new
(
project
.
owner
,
project
,
params
).
execute
end
def
format_content
(
raw_content
)
...
...
lib/gitlab/issues_labels.rb
View file @
d009d38e
...
...
@@ -18,8 +18,8 @@ module Gitlab
{
title:
"enhancement"
,
color:
green
}
]
labels
.
each
do
|
label
|
project
.
labels
.
create
(
label
)
labels
.
each
do
|
params
|
::
Labels
::
CreateService
.
new
(
project
.
owner
,
project
).
execute
(
params
)
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