Commit c32e6125 authored by Jacob Vosmaer's avatar Jacob Vosmaer

Get rid of Gitlab::ShellEnv

parent a4a85c26
......@@ -3,7 +3,7 @@ class GitHooksService
def execute(user, repo_path, oldrev, newrev, ref)
@repo_path = repo_path
@user = Gitlab::ShellEnv.gl_id(user)
@user = Gitlab::GlId.gl_id(user)
@oldrev = oldrev
@newrev = newrev
@ref = ref
......
require_relative 'shell_env'
module Grack
class AuthSpawner
def self.call(env)
......@@ -61,11 +59,6 @@ module Grack
end
@user = authenticate_user(login, password)
if @user
Gitlab::ShellEnv.set_env(@user)
@env['REMOTE_USER'] = @auth.username
end
end
def ci_request?(login, password)
......
module Gitlab
# This module provide 2 methods
# to set specific ENV variables for GitLab Shell
module ShellEnv
extend self
def set_env(user)
# Set GL_ID env variable
if user
ENV['GL_ID'] = gl_id(user)
end
end
def reset_env
# Reset GL_ID env variable
ENV['GL_ID'] = nil
end
def gl_id(user)
if user.present?
"user-#{user.id}"
else
# This empty string is used in the render_grack_auth_ok method
""
end
end
end
end
module Gitlab
module GlId
def self.gl_id(user)
if user.present?
"user-#{user.id}"
else
""
end
end
end
end
......@@ -8,7 +8,7 @@ module Gitlab
class << self
def git_http_ok(repository, user)
{
'GL_ID' => Gitlab::ShellEnv.gl_id(user),
'GL_ID' => Gitlab::GlId.gl_id(user),
'RepoPath' => repository.path_to_repo,
}
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment