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
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
Show 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,34 +337,42 @@ describe Namespace do
...
@@ -337,34 +337,42 @@ 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'
)
}
it
'updates project full path in .git/config'
do
parent
.
update
(
path:
'mygroup_new'
)
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.
[
project_in_parent_group
,
hashed_project_in_subgroup
,
legacy_project_in_subgroup
].
each
do
|
project
|
project
.
route
.
reload
end
expect
(
project_rugged
(
project_in_parent_group
).
config
[
'gitlab.fullpath'
]).
to
eq
"mygroup_new/
#{
project_in_parent_group
.
path
}
"
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
}
"
expect
(
project_rugged
(
hashed_project_in_subgroup
).
config
[
'gitlab.fullpath'
]).
to
eq
"mygroup_new/mysubgroup/
#{
hashed_project_in_subgroup
.
path
}
"
expect
(
project_rugged
(
legacy_project_in_subgroup
).
config
[
'gitlab.fullpath'
]).
to
eq
"mygroup_new/mysubgroup/
#{
legacy_project_in_subgroup
.
path
}
"
expect
(
project_rugged
(
legacy_project_in_subgroup
).
config
[
'gitlab.fullpath'
]).
to
eq
"mygroup_new/mysubgroup/
#{
legacy_project_in_subgroup
.
path
}
"
end
end
it
'updates the project storage location'
do
repository_project_in_parent_group
=
create
(
:project_repository
,
project:
project_in_parent_group
)
repository_hashed_project_in_subgroup
=
create
(
:project_repository
,
project:
hashed_project_in_subgroup
)
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
)
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
rugged_repo
(
project
.
repository
)
rugged_repo
(
project
.
repository
)
end
end
end
end
end
describe
'#rm_dir'
,
'callback'
do
describe
'#rm_dir'
,
'callback'
do
let
(
:repository_storage_path
)
do
let
(
:repository_storage_path
)
do
...
...
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