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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
36ea5135
Commit
36ea5135
authored
Mar 13, 2020
by
Francisco Javier López
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix bug setting hook env with personal snippets
parent
163c8a8c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
23 deletions
+42
-23
changelogs/unreleased/fj-fix-bug-hook-env.yml
changelogs/unreleased/fj-fix-bug-hook-env.yml
+5
-0
lib/api/internal/base.rb
lib/api/internal/base.rb
+1
-1
spec/requests/api/internal/base_spec.rb
spec/requests/api/internal/base_spec.rb
+36
-22
No files found.
changelogs/unreleased/fj-fix-bug-hook-env.yml
0 → 100644
View file @
36ea5135
---
title
:
Fix bug setting hook env with personal snippets
merge_request
:
27235
author
:
type
:
fixed
lib/api/internal/base.rb
View file @
36ea5135
...
...
@@ -40,7 +40,7 @@ module API
# Stores some Git-specific env thread-safely
env
=
parse_env
Gitlab
::
Git
::
HookEnv
.
set
(
gl_repository
,
env
)
if
project
Gitlab
::
Git
::
HookEnv
.
set
(
gl_repository
,
env
)
if
container
actor
.
update_last_used_at!
access_checker
=
access_checker_for
(
actor
,
params
[
:protocol
])
...
...
spec/requests/api/internal/base_spec.rb
View file @
36ea5135
...
...
@@ -262,6 +262,8 @@ describe API::Internal::Base do
describe
"POST /internal/allowed"
,
:clean_gitlab_redis_shared_state
do
context
"access granted"
do
let
(
:env
)
{
{}
}
around
do
|
example
|
Timecop
.
freeze
{
example
.
run
}
end
...
...
@@ -270,30 +272,32 @@ describe API::Internal::Base do
project
.
add_developer
(
user
)
end
context
'with env passed as a JSON'
do
let
(
:gl_repository
)
{
Gitlab
::
GlRepository
::
WIKI
.
identifier_for_container
(
project
)
}
it
'sets env in RequestStore'
do
obj_dir_relative
=
'./objects'
alt_obj_dirs_relative
=
[
'./alt-objects-1'
,
'./alt-objects-2'
]
shared_examples
'sets hook env'
do
context
'with env passed as a JSON'
do
let
(
:obj_dir_relative
)
{
'./objects'
}
let
(
:alt_obj_dirs_relative
)
{
[
'./alt-objects-1'
,
'./alt-objects-2'
]
}
let
(
:env
)
do
{
GIT_OBJECT_DIRECTORY_RELATIVE
:
obj_dir_relative
,
GIT_ALTERNATE_OBJECT_DIRECTORIES_RELATIVE
:
alt_obj_dirs_relative
}
end
expect
(
Gitlab
::
Git
::
HookEnv
).
to
receive
(
:set
).
with
(
gl_repository
,
{
'GIT_OBJECT_DIRECTORY_RELATIVE'
=>
obj_dir_relative
,
'GIT_ALTERNATE_OBJECT_DIRECTORIES_RELATIVE'
=>
alt_obj_dirs_relative
})
it
'sets env in RequestStore'
do
expect
(
Gitlab
::
Git
::
HookEnv
).
to
receive
(
:set
).
with
(
gl_repository
,
env
.
stringify_keys
)
push
(
key
,
project
.
wiki
,
env:
{
GIT_OBJECT_DIRECTORY_RELATIVE
:
obj_dir_relative
,
GIT_ALTERNATE_OBJECT_DIRECTORIES_RELATIVE
:
alt_obj_dirs_relative
}.
to_json
)
subject
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
end
context
"git push with project.wiki"
do
subject
{
push
(
key
,
project
.
wiki
,
env:
env
.
to_json
)
}
it
'responds with success'
do
push
(
key
,
project
.
wiki
)
subject
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
"status"
]).
to
be_truthy
...
...
@@ -301,6 +305,10 @@ describe API::Internal::Base do
expect
(
json_response
[
"gl_repository"
]).
to
eq
(
"wiki-
#{
project
.
id
}
"
)
expect
(
user
.
reload
.
last_activity_on
).
to
be_nil
end
it_behaves_like
'sets hook env'
do
let
(
:gl_repository
)
{
Gitlab
::
GlRepository
::
WIKI
.
identifier_for_container
(
project
)
}
end
end
context
"git pull with project.wiki"
do
...
...
@@ -328,8 +336,10 @@ describe API::Internal::Base do
end
context
'git push with personal snippet'
do
subject
{
push
(
key
,
personal_snippet
,
env:
env
.
to_json
)
}
it
'responds with success'
do
push
(
key
,
personal_snippet
)
subject
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
"status"
]).
to
be_truthy
...
...
@@ -338,8 +348,9 @@ describe API::Internal::Base do
expect
(
user
.
reload
.
last_activity_on
).
to
be_nil
end
it_behaves_like
'snippets with disabled feature flag'
do
subject
{
push
(
key
,
personal_snippet
)
}
it_behaves_like
'snippets with disabled feature flag'
it_behaves_like
'sets hook env'
do
let
(
:gl_repository
)
{
Gitlab
::
GlRepository
::
SNIPPET
.
identifier_for_container
(
personal_snippet
)
}
end
end
...
...
@@ -360,8 +371,10 @@ describe API::Internal::Base do
end
context
'git push with project snippet'
do
subject
{
push
(
key
,
project_snippet
,
env:
env
.
to_json
)
}
it
'responds with success'
do
push
(
key
,
project_snippet
)
subject
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
"status"
]).
to
be_truthy
...
...
@@ -370,8 +383,9 @@ describe API::Internal::Base do
expect
(
user
.
reload
.
last_activity_on
).
to
be_nil
end
it_behaves_like
'snippets with disabled feature flag'
do
subject
{
push
(
key
,
project_snippet
)
}
it_behaves_like
'snippets with disabled feature flag'
it_behaves_like
'sets hook env'
do
let
(
:gl_repository
)
{
Gitlab
::
GlRepository
::
SNIPPET
.
identifier_for_container
(
project_snippet
)
}
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