Commit 49cf9bad authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Gitlab::ShellEnv added

parent b698094d
...@@ -32,8 +32,7 @@ module Grack ...@@ -32,8 +32,7 @@ module Grack
self.user = User.find_by_email(login) || User.find_by_username(login) self.user = User.find_by_email(login) || User.find_by_username(login)
return false unless user.try(:valid_password?, password) return false unless user.try(:valid_password?, password)
# Set GL_ID env variable Gitlab::ShellEnv.set_env(user)
ENV['GL_ID'] = "user-#{user.id}"
end end
# Git upload and receive # Git upload and receive
......
...@@ -53,7 +53,6 @@ module Gitlab ...@@ -53,7 +53,6 @@ module Gitlab
system("/home/git/gitlab-shell/bin/gitlab-keys rm-key #{key_id} \"#{key_content}\"") system("/home/git/gitlab-shell/bin/gitlab-keys rm-key #{key_id} \"#{key_content}\"")
end end
def url_to_repo path def url_to_repo path
Gitlab.config.gitlab_shell.ssh_path_prefix + "#{path}.git" Gitlab.config.gitlab_shell.ssh_path_prefix + "#{path}.git"
end end
......
module Gitlab
# This module provide 2 methods
# to set specific ENV variabled for GitLab Shell
module ShellEnv
extend self
def set_env(user)
# Set GL_ID env variable
ENV['GL_ID'] = "user-#{user.id}"
end
def reset_env
# Reset GL_ID env variable
ENV['GL_ID'] = nil
end
end
end
...@@ -17,6 +17,8 @@ module Gitlab ...@@ -17,6 +17,8 @@ module Gitlab
# * Locks the satellite repo # * Locks the satellite repo
# * Yields the prepared satellite repo # * Yields the prepared satellite repo
def in_locked_and_timed_satellite def in_locked_and_timed_satellite
Gitlab::ShellEnv.set_env(user)
Grit::Git.with_timeout(options[:git_timeout]) do Grit::Git.with_timeout(options[:git_timeout]) do
project.satellite.lock do project.satellite.lock do
return yield project.satellite.repo return yield project.satellite.repo
...@@ -28,6 +30,8 @@ module Gitlab ...@@ -28,6 +30,8 @@ module Gitlab
rescue Grit::Git::GitTimeout => ex rescue Grit::Git::GitTimeout => ex
Gitlab::GitLogger.error(ex.message) Gitlab::GitLogger.error(ex.message)
return false return false
ensure
Gitlab::ShellEnv.reset_env
end end
# * Clears the satellite # * Clears the satellite
......
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