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
7e11ca86
Commit
7e11ca86
authored
Oct 03, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reuse LabelsFinder on Issueable#add_labels_by_names
parent
3db22610
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
11 additions
and
16 deletions
+11
-16
app/models/concerns/issuable.rb
app/models/concerns/issuable.rb
+3
-9
lib/api/merge_requests.rb
lib/api/merge_requests.rb
+2
-2
lib/gitlab/fogbugz_import/importer.rb
lib/gitlab/fogbugz_import/importer.rb
+1
-1
lib/gitlab/google_code_import/importer.rb
lib/gitlab/google_code_import/importer.rb
+1
-1
spec/lib/gitlab/google_code_import/importer_spec.rb
spec/lib/gitlab/google_code_import/importer_spec.rb
+4
-3
No files found.
app/models/concerns/issuable.rb
View file @
7e11ca86
...
...
@@ -234,19 +234,13 @@ module Issuable
labels
.
delete_all
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
}
)"
)
def
add_labels_by_names
(
label_names
,
current_user
)
available_labels
=
LabelsFinder
.
new
(
current_user
,
project_id:
project
.
id
).
execute
label_names
.
each
do
|
label_name
|
title
=
label_name
.
strip
label
=
available_labels
.
find_by
(
title:
title
)
label
=
project
.
labels
.
build
(
title:
title
,
color:
Label
::
DEFAULT_COLOR
)
if
label
.
nil?
label
||=
project
.
labels
.
build
(
title:
title
,
color:
Label
::
DEFAULT_COLOR
)
self
.
labels
<<
label
end
...
...
lib/api/merge_requests.rb
View file @
7e11ca86
...
...
@@ -91,7 +91,7 @@ module API
if
merge_request
.
valid?
# Find or create labels and attach to issue
if
params
[
:labels
].
present?
merge_request
.
add_labels_by_names
(
params
[
:labels
].
split
(
","
))
merge_request
.
add_labels_by_names
(
params
[
:labels
].
split
(
","
)
,
current_user
)
end
present
merge_request
,
with:
Entities
::
MergeRequest
,
current_user:
current_user
...
...
@@ -201,7 +201,7 @@ module API
# Find or create labels and attach to issue
unless
params
[
:labels
].
nil?
merge_request
.
remove_labels
merge_request
.
add_labels_by_names
(
params
[
:labels
].
split
(
","
))
merge_request
.
add_labels_by_names
(
params
[
:labels
].
split
(
","
)
,
current_user
)
end
present
merge_request
,
with:
Entities
::
MergeRequest
,
current_user:
current_user
...
...
lib/gitlab/fogbugz_import/importer.rb
View file @
7e11ca86
...
...
@@ -129,7 +129,7 @@ module Gitlab
assignee_id:
assignee_id
,
state:
bug
[
'fOpen'
]
==
'true'
?
'opened'
:
'closed'
)
issue
.
add_labels_by_names
(
labels
)
issue
.
add_labels_by_names
(
labels
,
project
.
creator
)
if
issue
.
iid
!=
bug
[
'ixBug'
]
issue
.
update_attribute
(
:iid
,
bug
[
'ixBug'
])
...
...
lib/gitlab/google_code_import/importer.rb
View file @
7e11ca86
...
...
@@ -100,7 +100,7 @@ module Gitlab
state:
raw_issue
[
"state"
]
==
"closed"
?
"closed"
:
"opened"
)
issue
.
add_labels_by_names
(
labels
)
issue
.
add_labels_by_names
(
labels
,
project
.
creator
)
if
issue
.
iid
!=
raw_issue
[
"id"
]
issue
.
update_attribute
(
:iid
,
raw_issue
[
"id"
])
...
...
spec/lib/gitlab/google_code_import/importer_spec.rb
View file @
7e11ca86
...
...
@@ -15,6 +15,7 @@ describe Gitlab::GoogleCodeImport::Importer, lib: true do
subject
{
described_class
.
new
(
project
)
}
before
do
project
.
team
<<
[
project
.
creator
,
:master
]
project
.
create_import_data
(
data:
import_data
)
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