Skip to content
GitLab
Menu
Why GitLab
Pricing
Contact Sales
Explore
Why GitLab
Pricing
Contact Sales
Explore
Sign in
Get free trial
Primary navigation
Search or go to…
Project
GitLab FOSS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Privacy statement
Keyboard shortcuts
?
What's new
4
Snippets
Groups
Projects
Show more breadcrumbs
GitLab.org
GitLab FOSS
Commits
49ec98d1
Commit
49ec98d1
authored
8 years ago
by
Douglas Barbosa Alexandre
Browse files
Options
Downloads
Patches
Plain Diff
Recreates the label priorities when moving project to another group
parent
301264be
No related branches found
No related tags found
1 merge request
!6425
Add group level labels
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/services/labels/transfer_service.rb
+2
-1
2 additions, 1 deletion
app/services/labels/transfer_service.rb
spec/services/labels/transfer_service_spec.rb
+10
-0
10 additions, 0 deletions
spec/services/labels/transfer_service_spec.rb
with
12 additions
and
1 deletion
app/services/labels/transfer_service.rb
+
2
−
1
View file @
49ec98d1
...
...
@@ -14,7 +14,7 @@ def execute
return
unless
group
.
present?
Label
.
transaction
do
labels_to_transfer
=
Label
.
where
(
id:
label_links
.
select
(
:label_id
)
.
uniq
)
labels_to_transfer
=
Label
.
where
(
id:
label_links
.
select
(
:label_id
))
labels_to_transfer
.
find_each
do
|
label
|
new_label_id
=
find_or_create_label!
(
label
)
...
...
@@ -22,6 +22,7 @@ def execute
next
if
new_label_id
==
label
.
id
LabelLink
.
where
(
label_id:
label
.
id
).
update_all
(
label_id:
new_label_id
)
LabelPriority
.
where
(
project_id:
project
.
id
,
label_id:
label
.
id
).
update_all
(
label_id:
new_label_id
)
end
end
end
...
...
This diff is collapsed.
Click to expand it.
spec/services/labels/transfer_service_spec.rb
+
10
−
0
View file @
49ec98d1
...
...
@@ -26,6 +26,16 @@
expect
{
service
.
execute
}.
to
change
(
project
.
labels
,
:count
).
by
(
2
)
end
it
'recreates label priorities related to the missing group labels'
do
create
(
:label_priority
,
project:
project
,
label:
group_label_1
,
priority:
1
)
service
.
execute
new_project_label
=
project
.
labels
.
find_by
(
title:
group_label_1
.
title
)
expect
(
new_project_label
.
id
).
not_to
eq
group_label_1
.
id
expect
(
new_project_label
.
priorities
).
not_to
be_empty
end
it
'does not recreate missing group labels that are not applied to issues or merge requests'
do
service
.
execute
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment