Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
f62f0c25
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f62f0c25
编写于
5月 18, 2017
作者:
B
Bob Van Landuyt
提交者:
Douwe Maan
5月 18, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixes for the rename reserved paths helpers
上级
36ede008
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
51 addition
and
2 deletion
+51
-2
lib/gitlab/database/rename_reserved_paths_migration/v1/migration_classes.rb
...e/rename_reserved_paths_migration/v1/migration_classes.rb
+8
-0
lib/gitlab/database/rename_reserved_paths_migration/v1/rename_base.rb
...atabase/rename_reserved_paths_migration/v1/rename_base.rb
+2
-1
lib/gitlab/database/rename_reserved_paths_migration/v1/rename_namespaces.rb
...e/rename_reserved_paths_migration/v1/rename_namespaces.rb
+6
-0
spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_base_spec.rb
...se/rename_reserved_paths_migration/v1/rename_base_spec.rb
+9
-0
spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_namespaces_spec.rb
...ame_reserved_paths_migration/v1/rename_namespaces_spec.rb
+26
-1
未找到文件。
lib/gitlab/database/rename_reserved_paths_migration/v1/migration_classes.rb
浏览文件 @
f62f0c25
...
...
@@ -48,6 +48,14 @@ module Gitlab
def
self
.
name
'Namespace'
end
def
kind
type
==
'Group'
?
'group'
:
'user'
end
end
class
User
<
ActiveRecord
::
Base
self
.
table_name
=
'users'
end
class
Route
<
ActiveRecord
::
Base
...
...
lib/gitlab/database/rename_reserved_paths_migration/v1/rename_base.rb
浏览文件 @
f62f0c25
...
...
@@ -41,7 +41,8 @@ module Gitlab
new_full_path
)
update_column_in_batches
(
:routes
,
:path
,
replace_statement
)
do
|
table
,
query
|
query
.
where
(
MigrationClasses
::
Route
.
arel_table
[
:path
].
matches
(
"
#{
old_full_path
}
%"
))
path_or_children
=
table
[
:path
].
matches_any
([
old_full_path
,
"
#{
old_full_path
}
/%"
])
query
.
where
(
path_or_children
)
end
end
...
...
lib/gitlab/database/rename_reserved_paths_migration/v1/rename_namespaces.rb
浏览文件 @
f62f0c25
...
...
@@ -29,9 +29,15 @@ module Gitlab
move_repositories
(
namespace
,
old_full_path
,
new_full_path
)
move_uploads
(
old_full_path
,
new_full_path
)
move_pages
(
old_full_path
,
new_full_path
)
rename_user
(
old_full_path
,
new_full_path
)
if
namespace
.
kind
==
'user'
remove_cached_html_for_projects
(
projects_for_namespace
(
namespace
).
map
(
&
:id
))
end
def
rename_user
(
old_username
,
new_username
)
MigrationClasses
::
User
.
where
(
username:
old_username
)
.
update_all
(
username:
new_username
)
end
def
move_repositories
(
namespace
,
old_full_path
,
new_full_path
)
repo_paths_for_namespace
(
namespace
).
each
do
|
repository_storage_path
|
# Ensure old directory exists before moving it
...
...
spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_base_spec.rb
浏览文件 @
f62f0c25
...
...
@@ -107,6 +107,15 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameBase do
expect
(
new_path
).
to
eq
(
'the-path0'
)
end
it
"doesn't rename routes that start with a similar name"
do
other_namespace
=
create
(
:namespace
,
path:
'the-path-but-not-really'
)
project
=
create
(
:empty_project
,
path:
'the-project'
,
namespace:
other_namespace
)
subject
.
rename_path_for_routable
(
migration_namespace
(
namespace
))
expect
(
project
.
route
.
reload
.
path
).
to
eq
(
'the-path-but-not-really/the-project'
)
end
context
"the-path namespace -> subgroup -> the-path0 project"
do
it
"updates the route of the project correctly"
do
subgroup
=
create
(
:group
,
path:
"subgroup"
,
parent:
namespace
)
...
...
spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_namespaces_spec.rb
浏览文件 @
f62f0c25
...
...
@@ -137,7 +137,7 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameNamespaces do
end
describe
"#rename_namespace"
do
let
(
:namespace
)
{
create
(
:
namespace
,
path
:
'the-path'
)
}
let
(
:namespace
)
{
create
(
:
group
,
name
:
'the-path'
)
}
it
'renames paths & routes for the namespace'
do
expect
(
subject
).
to
receive
(
:rename_path_for_routable
).
...
...
@@ -177,6 +177,31 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameNamespaces do
subject
.
rename_namespace
(
namespace
)
end
it
"doesn't rename users for other namespaces"
do
expect
(
subject
).
not_to
receive
(
:rename_user
)
subject
.
rename_namespace
(
namespace
)
end
it
'renames the username of a namespace for a user'
do
user
=
create
(
:user
,
username:
'the-path'
)
expect
(
subject
).
to
receive
(
:rename_user
).
with
(
'the-path'
,
'the-path0'
)
subject
.
rename_namespace
(
user
.
namespace
)
end
end
describe
'#rename_user'
do
it
'renames a username'
do
subject
=
described_class
.
new
([],
migration
)
user
=
create
(
:user
,
username:
'broken'
)
subject
.
rename_user
(
'broken'
,
'broken0'
)
expect
(
user
.
reload
.
username
).
to
eq
(
'broken0'
)
end
end
describe
'#rename_namespaces'
do
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录