Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
338eb2c4
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 搜索 >>
提交
338eb2c4
编写于
12月 01, 2015
作者:
R
Rubén Dávila
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Call update hook from new GitHooksService class. #3069
上级
5145706c
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
19 addition
and
10 deletion
+19
-10
app/services/git_hooks_service.rb
app/services/git_hooks_service.rb
+1
-3
spec/models/repository_spec.rb
spec/models/repository_spec.rb
+1
-1
spec/services/git_hooks_service_spec.rb
spec/services/git_hooks_service_spec.rb
+17
-6
未找到文件。
app/services/git_hooks_service.rb
浏览文件 @
338eb2c4
...
@@ -8,9 +8,7 @@ class GitHooksService
...
@@ -8,9 +8,7 @@ class GitHooksService
@newrev
=
newrev
@newrev
=
newrev
@ref
=
ref
@ref
=
ref
pre_status
=
run_hook
(
'pre-receive'
)
if
run_hook
(
'pre-receive'
)
&&
run_hook
(
'update'
)
if
pre_status
yield
yield
run_hook
(
'post-receive'
)
run_hook
(
'post-receive'
)
...
...
spec/models/repository_spec.rb
浏览文件 @
338eb2c4
...
@@ -107,7 +107,7 @@ describe Repository do
...
@@ -107,7 +107,7 @@ describe Repository do
context
'when pre hooks were successful'
do
context
'when pre hooks were successful'
do
it
'should run without errors'
do
it
'should run without errors'
do
hook
=
double
(
trigger:
true
)
hook
=
double
(
trigger:
true
)
expect
(
Gitlab
::
Git
::
Hook
).
to
receive
(
:new
).
twice
.
and_return
(
hook
)
expect
(
Gitlab
::
Git
::
Hook
).
to
receive
(
:new
).
exactly
(
3
).
times
.
and_return
(
hook
)
expect
{
repository
.
add_branch
(
user
,
'new_feature'
,
'master'
)
}.
not_to
raise_error
expect
{
repository
.
add_branch
(
user
,
'new_feature'
,
'master'
)
}.
not_to
raise_error
end
end
...
...
spec/services/git_hooks_service_spec.rb
浏览文件 @
338eb2c4
...
@@ -17,16 +17,17 @@ describe GitHooksService do
...
@@ -17,16 +17,17 @@ describe GitHooksService do
describe
'#execute'
do
describe
'#execute'
do
context
'when pre hooks were successful'
do
context
'when receive hooks were successful'
do
it
'should call post hooks'
do
it
'should call post-receive hook'
do
expect
(
service
).
to
receive
(
:run_hook
).
with
(
'pre-receive'
).
and_return
(
true
)
hook
=
double
(
trigger:
true
)
expect
(
service
).
to
receive
(
:run_hook
).
with
(
'post-receive'
).
and_return
(
true
)
expect
(
Gitlab
::
Git
::
Hook
).
to
receive
(
:new
).
exactly
(
3
).
times
.
and_return
(
hook
)
expect
(
service
.
execute
(
user
,
@repo_path
,
@blankrev
,
@newrev
,
@ref
)
{
}).
to
eq
(
true
)
expect
(
service
.
execute
(
user
,
@repo_path
,
@blankrev
,
@newrev
,
@ref
)
{
}).
to
eq
(
true
)
end
end
end
end
context
'when pre
hooks
failed'
do
context
'when pre
-receive hook
failed'
do
it
'should not call post
hooks
'
do
it
'should not call post
-receive hook
'
do
expect
(
service
).
to
receive
(
:run_hook
).
with
(
'pre-receive'
).
and_return
(
false
)
expect
(
service
).
to
receive
(
:run_hook
).
with
(
'pre-receive'
).
and_return
(
false
)
expect
(
service
).
not_to
receive
(
:run_hook
).
with
(
'post-receive'
)
expect
(
service
).
not_to
receive
(
:run_hook
).
with
(
'post-receive'
)
...
@@ -34,5 +35,15 @@ describe GitHooksService do
...
@@ -34,5 +35,15 @@ describe GitHooksService do
end
end
end
end
context
'when update hook failed'
do
it
'should not call post-receive hook'
do
expect
(
service
).
to
receive
(
:run_hook
).
with
(
'pre-receive'
).
and_return
(
true
)
expect
(
service
).
to
receive
(
:run_hook
).
with
(
'update'
).
and_return
(
false
)
expect
(
service
).
not_to
receive
(
:run_hook
).
with
(
'post-receive'
)
service
.
execute
(
user
,
@repo_path
,
@blankrev
,
@newrev
,
@ref
)
end
end
end
end
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录