Commit 49cf9badbce730c053496306778b801d596658af

Authored by Dmitriy Zaporozhets
1 parent b698094d

Gitlab::ShellEnv added

lib/gitlab/backend/grack_auth.rb
... ... @@ -32,8 +32,7 @@ module Grack
32 32 self.user = User.find_by_email(login) || User.find_by_username(login)
33 33 return false unless user.try(:valid_password?, password)
34 34  
35   - # Set GL_ID env variable
36   - ENV['GL_ID'] = "user-#{user.id}"
  35 + Gitlab::ShellEnv.set_env(user)
37 36 end
38 37  
39 38 # Git upload and receive
... ...
lib/gitlab/backend/shell.rb
... ... @@ -53,7 +53,6 @@ module Gitlab
53 53 system("/home/git/gitlab-shell/bin/gitlab-keys rm-key #{key_id} \"#{key_content}\"")
54 54 end
55 55  
56   -
57 56 def url_to_repo path
58 57 Gitlab.config.gitlab_shell.ssh_path_prefix + "#{path}.git"
59 58 end
... ...
lib/gitlab/backend/shell_env.rb 0 → 100644
... ... @@ -0,0 +1,17 @@
  1 +module Gitlab
  2 + # This module provide 2 methods
  3 + # to set specific ENV variabled for GitLab Shell
  4 + module ShellEnv
  5 + extend self
  6 +
  7 + def set_env(user)
  8 + # Set GL_ID env variable
  9 + ENV['GL_ID'] = "user-#{user.id}"
  10 + end
  11 +
  12 + def reset_env
  13 + # Reset GL_ID env variable
  14 + ENV['GL_ID'] = nil
  15 + end
  16 + end
  17 +end
... ...
lib/gitlab/satellite/action.rb
... ... @@ -17,6 +17,8 @@ module Gitlab
17 17 # * Locks the satellite repo
18 18 # * Yields the prepared satellite repo
19 19 def in_locked_and_timed_satellite
  20 + Gitlab::ShellEnv.set_env(user)
  21 +
20 22 Grit::Git.with_timeout(options[:git_timeout]) do
21 23 project.satellite.lock do
22 24 return yield project.satellite.repo
... ... @@ -28,6 +30,8 @@ module Gitlab
28 30 rescue Grit::Git::GitTimeout => ex
29 31 Gitlab::GitLogger.error(ex.message)
30 32 return false
  33 + ensure
  34 + Gitlab::ShellEnv.reset_env
31 35 end
32 36  
33 37 # * Clears the satellite
... ...