BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
7ece18f1
Commit
7ece18f1
authored
Oct 26, 2017
by
Douwe Maan
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'gl-username-hook-fix' into 'master'
Fix the incorrect value being used to set GL_USERNAME on hooks See merge request gitlab-org/gitlab-ce!15038
parents
cd08fd23
42a45392
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
14 deletions
+16
-14
hooks_service.rb
lib/gitlab/git/hooks_service.rb
+1
-1
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 @
7ece18f1
...
@@ -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 @
7ece18f1
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