BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
470b3cb5
Commit
470b3cb5
authored
Apr 19, 2018
by
Jan Provaznik
Committed by
Sean McGivern
Apr 19, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix label links update on project transfer
parent
0517e1d8
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
3 deletions
+23
-3
transfer_service.rb
app/services/labels/transfer_service.rb
+8
-3
label-links-on-project-transfer.yml
changelogs/unreleased/label-links-on-project-transfer.yml
+5
-0
transfer_service_spec.rb
spec/services/labels/transfer_service_spec.rb
+10
-0
No files found.
app/services/labels/transfer_service.rb
View file @
470b3cb5
...
...
@@ -64,9 +64,14 @@ module Labels
end
def
update_label_links
(
labels
,
old_label_id
:,
new_label_id
:)
LabelLink
.
joins
(
:label
)
.
merge
(
labels
)
.
where
(
label_id:
old_label_id
)
# use 'labels' relation to get label_link ids only of issues/MRs
# in the project being transferred.
# IDs are fetched in a separate query because MySQL doesn't
# allow referring of 'label_links' table in UPDATE query:
# https://gitlab.com/gitlab-org/gitlab-ce/-/jobs/62435068
link_ids
=
labels
.
pluck
(
'label_links.id'
)
LabelLink
.
where
(
id:
link_ids
,
label_id:
old_label_id
)
.
update_all
(
label_id:
new_label_id
)
end
...
...
changelogs/unreleased/label-links-on-project-transfer.yml
0 → 100644
View file @
470b3cb5
---
title
:
Fix label links update on project transfer
merge_request
:
author
:
type
:
fixed
spec/services/labels/transfer_service_spec.rb
View file @
470b3cb5
...
...
@@ -8,6 +8,7 @@ describe Labels::TransferService do
let
(
:group_3
)
{
create
(
:group
)
}
let
(
:project_1
)
{
create
(
:project
,
namespace:
group_2
)
}
let
(
:project_2
)
{
create
(
:project
,
namespace:
group_3
)
}
let
(
:project_3
)
{
create
(
:project
,
namespace:
group_1
)
}
let
(
:group_label_1
)
{
create
(
:group_label
,
group:
group_1
,
name:
'Group Label 1'
)
}
let
(
:group_label_2
)
{
create
(
:group_label
,
group:
group_1
,
name:
'Group Label 2'
)
}
...
...
@@ -23,6 +24,7 @@ describe Labels::TransferService do
create
(
:labeled_issue
,
project:
project_1
,
labels:
[
group_label_4
])
create
(
:labeled_issue
,
project:
project_1
,
labels:
[
project_label_1
])
create
(
:labeled_issue
,
project:
project_2
,
labels:
[
group_label_5
])
create
(
:labeled_issue
,
project:
project_3
,
labels:
[
group_label_1
])
create
(
:labeled_merge_request
,
source_project:
project_1
,
labels:
[
group_label_1
,
group_label_2
])
create
(
:labeled_merge_request
,
source_project:
project_2
,
labels:
[
group_label_5
])
end
...
...
@@ -52,5 +54,13 @@ describe Labels::TransferService do
expect
(
project_1
.
labels
.
where
(
title:
group_label_4
.
title
)).
to
be_empty
end
it
'updates only label links in the given project'
do
service
.
execute
targets
=
LabelLink
.
where
(
label_id:
group_label_1
.
id
).
map
(
&
:target
)
expect
(
targets
).
to
eq
(
project_3
.
issues
)
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