Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
c837da34
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,发现更多精彩内容 >>
提交
c837da34
编写于
3月 24, 2017
作者:
J
Jacob Vosmaer
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Helper method for storage path stripping
上级
b46ac16c
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
49 addition
and
8 deletion
+49
-8
app/workers/post_receive.rb
app/workers/post_receive.rb
+4
-8
lib/gitlab/repo_path.rb
lib/gitlab/repo_path.rb
+23
-0
spec/lib/gitlab/repo_path_spec.rb
spec/lib/gitlab/repo_path_spec.rb
+22
-0
未找到文件。
app/workers/post_receive.rb
浏览文件 @
c837da34
...
...
@@ -3,20 +3,16 @@ class PostReceive
include
DedicatedSidekiqQueue
def
perform
(
repo_path
,
identifier
,
changes
)
if
repository_storage
=
Gitlab
.
config
.
repositories
.
storages
.
find
{
|
p
|
repo_path
.
start_with?
(
p
[
1
][
'path'
].
to_s
)
}
repo_path
.
gsub!
(
repository_storage
[
1
][
'path'
].
to_s
,
""
)
else
log
(
"Check gitlab.yml config for correct repositories.storages values. No repository storage path matches
\"
#{
repo_path
}
\"
"
)
end
repo_relative_path
=
Gitlab
::
RepoPath
.
strip_storage_path
(
repo_path
)
changes
=
Base64
.
decode64
(
changes
)
unless
changes
.
include?
(
' '
)
# Use Sidekiq.logger so arguments can be correlated with execution
# time and thread ID's.
Sidekiq
.
logger
.
info
"changes:
#{
changes
.
inspect
}
"
if
ENV
[
'SIDEKIQ_LOG_ARGUMENTS'
]
post_received
=
Gitlab
::
GitPostReceive
.
new
(
repo_path
,
identifier
,
changes
)
post_received
=
Gitlab
::
GitPostReceive
.
new
(
repo_
relative_
path
,
identifier
,
changes
)
if
post_received
.
project
.
nil?
log
(
"Triggered hook for non-existing project with full path
\"
#{
repo_path
}
\"
"
)
log
(
"Triggered hook for non-existing project with full path
\"
#{
repo_
relative_
path
}
\"
"
)
return
false
end
...
...
@@ -25,7 +21,7 @@ class PostReceive
elsif
post_received
.
regular_project?
process_project_changes
(
post_received
)
else
log
(
"Triggered hook for unidentifiable repository type with full path
\"
#{
repo_path
}
\"
"
)
log
(
"Triggered hook for unidentifiable repository type with full path
\"
#{
repo_
relative_
path
}
\"
"
)
false
end
end
...
...
lib/gitlab/repo_path.rb
0 → 100644
浏览文件 @
c837da34
module
Gitlab
module
RepoPath
NotFoundError
=
Class
.
new
(
StandardError
)
def
self
.
strip_storage_path
(
repo_path
)
result
=
nil
Gitlab
.
config
.
repositories
.
storages
.
values
.
each
do
|
params
|
storage_path
=
params
[
'path'
]
if
repo_path
.
start_with?
(
storage_path
)
result
=
repo_path
.
sub
(
storage_path
,
''
)
break
end
end
if
result
.
nil?
raise
NotFoundError
.
new
(
"No known storage path matches
#{
repo_path
.
inspect
}
"
)
end
result
.
sub
(
/\A\/*/
,
''
)
end
end
end
spec/lib/gitlab/repo_path_spec.rb
0 → 100644
浏览文件 @
c837da34
require
'spec_helper'
describe
::
Gitlab
::
RepoPath
do
describe
'.strip_storage_path'
do
before
do
allow
(
Gitlab
.
config
.
repositories
).
to
receive
(
:storages
).
and_return
({
'storage1'
=>
{
'path'
=>
'/foo'
},
'storage2'
=>
{
'path'
=>
'/bar'
},
})
end
it
'strips the storage path'
do
expect
(
described_class
.
strip_storage_path
(
'/bar/foo/qux/baz.git'
)).
to
eq
(
'foo/qux/baz.git'
)
end
it
'raises NotFoundError if no storage matches the path'
do
expect
{
described_class
.
strip_storage_path
(
'/doesnotexist/foo.git'
)
}.
to
raise_error
(
described_class
::
NotFoundError
)
end
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录