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
Jérome Perrin
gitlab-ce
Commits
42a45392
Commit
42a45392
authored
Oct 25, 2017
by
Alejandro Rodríguez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix the incorrect value being used to set GL_USERNAME on hooks
parent
3ddffec0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
14 deletions
+16
-14
lib/gitlab/git/hooks_service.rb
lib/gitlab/git/hooks_service.rb
+1
-1
spec/lib/gitlab/git/hooks_service_spec.rb
spec/lib/gitlab/git/hooks_service_spec.rb
+15
-13
No files found.
lib/gitlab/git/hooks_service.rb
View file @
42a45392
...
@@ -8,7 +8,7 @@ module Gitlab
...
@@ -8,7 +8,7 @@ module Gitlab
def
execute
(
pusher
,
repository
,
oldrev
,
newrev
,
ref
)
def
execute
(
pusher
,
repository
,
oldrev
,
newrev
,
ref
)
@repository
=
repository
@repository
=
repository
@gl_id
=
pusher
.
gl_id
@gl_id
=
pusher
.
gl_id
@gl_username
=
pusher
.
name
@gl_username
=
pusher
.
user
name
@oldrev
=
oldrev
@oldrev
=
oldrev
@newrev
=
newrev
@newrev
=
newrev
@ref
=
ref
@ref
=
ref
...
...
spec/lib/gitlab/git/hooks_service_spec.rb
View file @
42a45392
require
'spec_helper'
require
'spec_helper'
describe
Gitlab
::
Git
::
HooksService
,
seed_helper:
true
do
describe
Gitlab
::
Git
::
HooksService
,
seed_helper:
true
do
let
(
:user
)
{
Gitlab
::
Git
::
User
.
new
(
'janedoe'
,
'Jane Doe'
,
'janedoe@example.com'
,
'user-456'
)
}
let
(
:gl_id
)
{
'user-456'
}
let
(
:gl_username
)
{
'janedoe'
}
let
(
:user
)
{
Gitlab
::
Git
::
User
.
new
(
gl_username
,
'Jane Doe'
,
'janedoe@example.com'
,
gl_id
)
}
let
(
:repository
)
{
Gitlab
::
Git
::
Repository
.
new
(
'default'
,
TEST_REPO_PATH
,
'project-123'
)
}
let
(
:repository
)
{
Gitlab
::
Git
::
Repository
.
new
(
'default'
,
TEST_REPO_PATH
,
'project-123'
)
}
let
(
:service
)
{
described_class
.
new
}
let
(
:service
)
{
described_class
.
new
}
let
(
:blankrev
)
{
Gitlab
::
Git
::
BLANK_SHA
}
before
do
let
(
:oldrev
)
{
SeedRepo
::
Commit
::
PARENT_ID
}
@blankrev
=
Gitlab
::
Git
::
BLANK_SHA
let
(
:newrev
)
{
SeedRepo
::
Commit
::
ID
}
@oldrev
=
SeedRepo
::
Commit
::
PARENT_ID
let
(
:ref
)
{
'refs/heads/feature'
}
@newrev
=
SeedRepo
::
Commit
::
ID
@ref
=
'refs/heads/feature'
end
describe
'#execute'
do
describe
'#execute'
do
context
'when receive hooks were successful'
do
context
'when receive hooks were successful'
do
it
'calls post-receive hook'
do
let
(
:hook
)
{
double
(
:hook
)
}
hook
=
double
(
trigger:
[
true
,
nil
])
it
'calls all three hooks'
do
expect
(
Gitlab
::
Git
::
Hook
).
to
receive
(
:new
).
exactly
(
3
).
times
.
and_return
(
hook
)
expect
(
Gitlab
::
Git
::
Hook
).
to
receive
(
:new
).
exactly
(
3
).
times
.
and_return
(
hook
)
expect
(
hook
).
to
receive
(
:trigger
).
with
(
gl_id
,
gl_username
,
blankrev
,
newrev
,
ref
)
.
exactly
(
3
).
times
.
and_return
([
true
,
nil
])
service
.
execute
(
user
,
repository
,
@blankrev
,
@newrev
,
@
ref
)
{
}
service
.
execute
(
user
,
repository
,
blankrev
,
newrev
,
ref
)
{
}
end
end
end
end
...
@@ -28,7 +30,7 @@ describe Gitlab::Git::HooksService, seed_helper: true do
...
@@ -28,7 +30,7 @@ describe Gitlab::Git::HooksService, seed_helper: true do
expect
(
service
).
not_to
receive
(
:run_hook
).
with
(
'post-receive'
)
expect
(
service
).
not_to
receive
(
:run_hook
).
with
(
'post-receive'
)
expect
do
expect
do
service
.
execute
(
user
,
repository
,
@blankrev
,
@newrev
,
@
ref
)
service
.
execute
(
user
,
repository
,
blankrev
,
newrev
,
ref
)
end
.
to
raise_error
(
Gitlab
::
Git
::
HooksService
::
PreReceiveError
)
end
.
to
raise_error
(
Gitlab
::
Git
::
HooksService
::
PreReceiveError
)
end
end
end
end
...
@@ -40,7 +42,7 @@ describe Gitlab::Git::HooksService, seed_helper: true do
...
@@ -40,7 +42,7 @@ describe Gitlab::Git::HooksService, seed_helper: true do
expect
(
service
).
not_to
receive
(
:run_hook
).
with
(
'post-receive'
)
expect
(
service
).
not_to
receive
(
:run_hook
).
with
(
'post-receive'
)
expect
do
expect
do
service
.
execute
(
user
,
repository
,
@blankrev
,
@newrev
,
@
ref
)
service
.
execute
(
user
,
repository
,
blankrev
,
newrev
,
ref
)
end
.
to
raise_error
(
Gitlab
::
Git
::
HooksService
::
PreReceiveError
)
end
.
to
raise_error
(
Gitlab
::
Git
::
HooksService
::
PreReceiveError
)
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