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
Léo-Paul Géneau
gitlab-ce
Commits
e73af422
Commit
e73af422
authored
Oct 12, 2017
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Gitlab::Git::Env.to_env_hash
parent
1e4b75ba
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
6 deletions
+49
-6
lib/gitlab/git/env.rb
lib/gitlab/git/env.rb
+11
-0
lib/gitlab/git/rev_list.rb
lib/gitlab/git/rev_list.rb
+1
-1
spec/lib/gitlab/git/env_spec.rb
spec/lib/gitlab/git/env_spec.rb
+37
-5
No files found.
lib/gitlab/git/env.rb
View file @
e73af422
...
...
@@ -30,6 +30,17 @@ module Gitlab
RequestStore
.
fetch
(
:gitlab_git_env
)
{
{}
}
end
def
self
.
to_env_hash
env
=
{}
all
.
compact
.
each
do
|
key
,
value
|
value
=
value
.
join
(
File
::
PATH_SEPARATOR
)
if
value
.
is_a?
(
Array
)
env
[
key
.
to_s
]
=
value
end
env
end
def
self
.
[]
(
key
)
all
[
key
]
end
...
...
lib/gitlab/git/rev_list.rb
View file @
e73af422
...
...
@@ -28,7 +28,7 @@ module Gitlab
private
def
execute
(
args
)
output
,
status
=
popen
(
args
,
nil
,
Gitlab
::
Git
::
Env
.
all
.
stringify_keys
)
output
,
status
=
popen
(
args
,
nil
,
Gitlab
::
Git
::
Env
.
to_env_hash
)
unless
status
.
zero?
raise
"Got a non-zero exit code while calling out `
#{
args
.
join
(
' '
)
}
`:
#{
output
}
"
...
...
spec/lib/gitlab/git/env_spec.rb
View file @
e73af422
require
'spec_helper'
describe
Gitlab
::
Git
::
Env
do
describe
"
#
set"
do
describe
"
.
set"
do
context
'with RequestStore.store disabled'
do
before
do
allow
(
RequestStore
).
to
receive
(
:active?
).
and_return
(
false
)
...
...
@@ -34,25 +34,57 @@ describe Gitlab::Git::Env do
end
end
describe
"
#
all"
do
describe
"
.
all"
do
context
'with RequestStore.store enabled'
do
before
do
allow
(
RequestStore
).
to
receive
(
:active?
).
and_return
(
true
)
described_class
.
set
(
GIT_OBJECT_DIRECTORY
:
'foo'
,
GIT_ALTERNATE_OBJECT_DIRECTORIES
:
'bar'
)
GIT_ALTERNATE_OBJECT_DIRECTORIES
:
[
'bar'
]
)
end
it
'returns an env hash'
do
expect
(
described_class
.
all
).
to
eq
({
'GIT_OBJECT_DIRECTORY'
=>
'foo'
,
'GIT_ALTERNATE_OBJECT_DIRECTORIES'
=>
'bar'
'GIT_ALTERNATE_OBJECT_DIRECTORIES'
=>
[
'bar'
]
})
end
end
end
describe
"#[]"
do
describe
".to_env_hash"
do
context
'with RequestStore.store enabled'
do
using
RSpec
::
Parameterized
::
TableSyntax
let
(
:key
)
{
'GIT_OBJECT_DIRECTORY'
}
subject
{
described_class
.
to_env_hash
}
where
(
:input
,
:output
)
do
nil
|
nil
'foo'
|
'foo'
[]
|
''
[
'foo'
]
|
'foo'
%w[foo bar]
|
'foo:bar'
end
with_them
do
before
do
allow
(
RequestStore
).
to
receive
(
:active?
).
and_return
(
true
)
described_class
.
set
(
key
.
to_sym
=>
input
)
end
it
'puts the right value in the hash'
do
if
output
expect
(
subject
.
fetch
(
key
)).
to
eq
(
output
)
else
expect
(
subject
.
has_key?
(
key
)).
to
eq
(
false
)
end
end
end
end
end
describe
".[]"
do
context
'with RequestStore.store enabled'
do
before
do
allow
(
RequestStore
).
to
receive
(
:active?
).
and_return
(
true
)
...
...
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