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
Boxiang Sun
gitlab-ce
Commits
8a172ebd
Commit
8a172ebd
authored
Dec 21, 2018
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update storage location after a group has been renamed/transfered
parent
29527d21
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
23 deletions
+32
-23
app/models/namespace.rb
app/models/namespace.rb
+1
-0
spec/models/namespace_spec.rb
spec/models/namespace_spec.rb
+31
-23
No files found.
app/models/namespace.rb
View file @
8a172ebd
...
@@ -306,6 +306,7 @@ class Namespace < ActiveRecord::Base
...
@@ -306,6 +306,7 @@ class Namespace < ActiveRecord::Base
def
write_projects_repository_config
def
write_projects_repository_config
all_projects
.
find_each
do
|
project
|
all_projects
.
find_each
do
|
project
|
project
.
write_repository_config
project
.
write_repository_config
project
.
track_project_repository
end
end
end
end
end
end
spec/models/namespace_spec.rb
View file @
8a172ebd
...
@@ -337,32 +337,40 @@ describe Namespace do
...
@@ -337,32 +337,40 @@ describe Namespace do
end
end
end
end
it
'updates project full path in .git/config for each project inside namespace'
do
context
'for each project inside the namespace'
do
parent
=
create
(
:group
,
name:
'mygroup'
,
path:
'mygroup'
)
let!
(
:parent
)
{
create
(
:group
,
name:
'mygroup'
,
path:
'mygroup'
)
}
subgroup
=
create
(
:group
,
name:
'mysubgroup'
,
path:
'mysubgroup'
,
parent:
parent
)
let!
(
:subgroup
)
{
create
(
:group
,
name:
'mysubgroup'
,
path:
'mysubgroup'
,
parent:
parent
)
}
project_in_parent_group
=
create
(
:project
,
:legacy_storage
,
:repository
,
namespace:
parent
,
name:
'foo1'
)
let!
(
:project_in_parent_group
)
{
create
(
:project
,
:legacy_storage
,
:repository
,
namespace:
parent
,
name:
'foo1'
)
}
hashed_project_in_subgroup
=
create
(
:project
,
:repository
,
namespace:
subgroup
,
name:
'foo2'
)
let!
(
:hashed_project_in_subgroup
)
{
create
(
:project
,
:repository
,
namespace:
subgroup
,
name:
'foo2'
)
}
legacy_project_in_subgroup
=
create
(
:project
,
:legacy_storage
,
:repository
,
namespace:
subgroup
,
name:
'foo3'
)
let!
(
:legacy_project_in_subgroup
)
{
create
(
:project
,
:legacy_storage
,
:repository
,
namespace:
subgroup
,
name:
'foo3'
)
}
parent
.
update
(
path:
'mygroup_new'
)
it
'updates project full path in .git/config'
do
parent
.
update
(
path:
'mygroup_new'
)
# Routes are loaded when creating the projects, so we need to manually
# reload them for the below code to be aware of the above UPDATE.
expect
(
project_rugged
(
project_in_parent_group
).
config
[
'gitlab.fullpath'
]).
to
eq
"mygroup_new/
#{
project_in_parent_group
.
path
}
"
[
expect
(
project_rugged
(
hashed_project_in_subgroup
).
config
[
'gitlab.fullpath'
]).
to
eq
"mygroup_new/mysubgroup/
#{
hashed_project_in_subgroup
.
path
}
"
project_in_parent_group
,
expect
(
project_rugged
(
legacy_project_in_subgroup
).
config
[
'gitlab.fullpath'
]).
to
eq
"mygroup_new/mysubgroup/
#{
legacy_project_in_subgroup
.
path
}
"
hashed_project_in_subgroup
,
legacy_project_in_subgroup
].
each
do
|
project
|
project
.
route
.
reload
end
end
expect
(
project_rugged
(
project_in_parent_group
).
config
[
'gitlab.fullpath'
]).
to
eq
"mygroup_new/
#{
project_in_parent_group
.
path
}
"
it
'updates the project storage location'
do
expect
(
project_rugged
(
hashed_project_in_subgroup
).
config
[
'gitlab.fullpath'
]).
to
eq
"mygroup_new/mysubgroup/
#{
hashed_project_in_subgroup
.
path
}
"
repository_project_in_parent_group
=
create
(
:project_repository
,
project:
project_in_parent_group
)
expect
(
project_rugged
(
legacy_project_in_subgroup
).
config
[
'gitlab.fullpath'
]).
to
eq
"mygroup_new/mysubgroup/
#{
legacy_project_in_subgroup
.
path
}
"
repository_hashed_project_in_subgroup
=
create
(
:project_repository
,
project:
hashed_project_in_subgroup
)
end
repository_legacy_project_in_subgroup
=
create
(
:project_repository
,
project:
legacy_project_in_subgroup
)
parent
.
update
(
path:
'mygroup_moved'
)
expect
(
repository_project_in_parent_group
.
reload
.
disk_path
).
to
eq
"mygroup_moved/
#{
project_in_parent_group
.
path
}
"
expect
(
repository_hashed_project_in_subgroup
.
reload
.
disk_path
).
to
eq
hashed_project_in_subgroup
.
disk_path
expect
(
repository_legacy_project_in_subgroup
.
reload
.
disk_path
).
to
eq
"mygroup_moved/mysubgroup/
#{
legacy_project_in_subgroup
.
path
}
"
end
def
project_rugged
(
project
)
# Routes are loaded when creating the projects, so we need to manually
# reload them for the below code to be aware of the above UPDATE.
project
.
route
.
reload
def
project_rugged
(
project
)
rugged_repo
(
project
.
repository
)
rugged_repo
(
project
.
repository
)
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