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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
338eb2c4
Commit
338eb2c4
authored
Dec 01, 2015
by
Rubén Dávila
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Call update hook from new GitHooksService class. #3069
parent
5145706c
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
10 deletions
+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
No files found.
app/services/git_hooks_service.rb
View file @
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
View file @
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
View file @
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
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