Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
c75c6b84
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,体验更适合开发者的 AI 搜索 >>
提交
c75c6b84
编写于
4月 20, 2015
作者:
D
Douwe Maan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Revert disallowing usernames to end in period.
上级
41f01dd3
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
2 addition
and
79 deletion
+2
-79
CHANGELOG
CHANGELOG
+0
-1
db/migrate/20150324133047_remove_periods_at_ends_of_usernames.rb
...ate/20150324133047_remove_periods_at_ends_of_usernames.rb
+0
-76
lib/gitlab/regex.rb
lib/gitlab/regex.rb
+2
-2
未找到文件。
CHANGELOG
浏览文件 @
c75c6b84
...
...
@@ -87,7 +87,6 @@ v 7.10.0 (unreleased)
- Fix admin user projects lists.
- Don't leak private group existence by redirecting from namespace controller to group controller.
- Ability to skip some items from backup (database, respositories or uploads)
- Fix "Hello @username." references not working by no longer allowing usernames to end in period.
- Archive repositories in background worker.
- Import GitHub, Bitbucket or GitLab.com projects owned by authenticated user into current namespace.
- Project labels are now available over the API under the "tag_list" field (Cristian Medina)
...
...
db/migrate/20150324133047_remove_periods_at_ends_of_usernames.rb
已删除
100644 → 0
浏览文件 @
41f01dd3
class
RemovePeriodsAtEndsOfUsernames
<
ActiveRecord
::
Migration
include
Gitlab
::
ShellAdapter
class
Namespace
<
ActiveRecord
::
Base
class
<<
self
def
find_by_path_or_name
(
path
)
find_by
(
"lower(path) = :path OR lower(name) = :path"
,
path:
path
.
downcase
)
end
def
clean_path
(
path
)
path
=
path
.
dup
path
.
gsub!
(
/@.*\z/
,
""
)
path
.
gsub!
(
/\.git\z/
,
""
)
path
.
gsub!
(
/\A-+/
,
""
)
path
.
gsub!
(
/\.+\z/
,
""
)
path
.
gsub!
(
/[^a-zA-Z0-9_\-\.]/
,
""
)
counter
=
0
base
=
path
while
Namespace
.
find_by_path_or_name
(
path
)
counter
+=
1
path
=
"
#{
base
}#{
counter
}
"
end
path
end
end
end
def
up
changed_paths
=
{}
select_all
(
"SELECT id, username FROM users WHERE username LIKE '%.'"
).
each
do
|
user
|
username_was
=
user
[
"username"
]
username
=
Namespace
.
clean_path
(
username_was
)
changed_paths
[
username_was
]
=
username
username
=
quote_string
(
username
)
execute
"UPDATE users SET username = '
#{
username
}
' WHERE id =
#{
user
[
"id"
]
}
"
execute
"UPDATE namespaces SET path = '
#{
username
}
', name = '
#{
username
}
' WHERE type IS NULL AND owner_id =
#{
user
[
"id"
]
}
"
end
select_all
(
"SELECT id, path FROM namespaces WHERE type = 'Group' AND path LIKE '%.'"
).
each
do
|
group
|
path_was
=
group
[
"path"
]
path
=
Namespace
.
clean_path
(
path_was
)
changed_paths
[
path_was
]
=
path
path
=
quote_string
(
path
)
execute
"UPDATE namespaces SET path = '
#{
path
}
' WHERE id =
#{
group
[
"id"
]
}
"
end
changed_paths
.
each
do
|
path_was
,
path
|
if
gitlab_shell
.
mv_namespace
(
path_was
,
path
)
# If repositories moved successfully we need to remove old satellites
# and send update instructions to users.
# However we cannot allow rollback since we moved namespace dir
# So we basically we mute exceptions in next actions
begin
gitlab_shell
.
rm_satellites
(
path_was
)
# We cannot send update instructions since models and mailers
# can't safely be used from migrations as they may be written for
# later versions of the database.
# send_update_instructions
rescue
# Returning false does not rollback after_* transaction but gives
# us information about failing some of tasks
false
end
else
# if we cannot move namespace directory we should rollback
# db changes in order to prevent out of sync between db and fs
raise
Exception
.
new
(
'namespace directory cannot be moved'
)
end
end
end
end
lib/gitlab/regex.rb
浏览文件 @
c75c6b84
...
...
@@ -2,7 +2,7 @@ module Gitlab
module
Regex
extend
self
NAMESPACE_REGEX_STR
=
'(?:[a-zA-Z0-9_\.][a-zA-Z0-9_\-\.]*
[a-zA-Z0-9_\-]|[a-zA-Z0-9_]
)'
.
freeze
NAMESPACE_REGEX_STR
=
'(?:[a-zA-Z0-9_\.][a-zA-Z0-9_\-\.]*)'
.
freeze
def
namespace_regex
@namespace_regex
||=
/\A
#{
NAMESPACE_REGEX_STR
}
\z/
.
freeze
...
...
@@ -10,7 +10,7 @@ module Gitlab
def
namespace_regex_message
"can contain only letters, digits, '_', '-' and '.'. "
\
"Cannot start with '-'
or end in '.'
."
\
"Cannot start with '-'."
\
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录