diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-02-14 15:17:43 +0200 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-02-14 15:17:43 +0200 |
commit | 49cf9badbce730c053496306778b801d596658af (patch) | |
tree | 35d3edd9840fb7fc32462a2dfd8566c6853e8dd7 | |
parent | b698094d4dcd1558bfcc1611d3572297dd11ae1e (diff) | |
download | gitlab-ce-49cf9badbce730c053496306778b801d596658af.tar.gz |
Gitlab::ShellEnv added
-rw-r--r-- | lib/gitlab/backend/grack_auth.rb | 3 | ||||
-rw-r--r-- | lib/gitlab/backend/shell.rb | 1 | ||||
-rw-r--r-- | lib/gitlab/backend/shell_env.rb | 17 | ||||
-rw-r--r-- | lib/gitlab/satellite/action.rb | 4 |
4 files changed, 22 insertions, 3 deletions
diff --git a/lib/gitlab/backend/grack_auth.rb b/lib/gitlab/backend/grack_auth.rb index 8fcafe4ea9d..1e858701396 100644 --- a/lib/gitlab/backend/grack_auth.rb +++ b/lib/gitlab/backend/grack_auth.rb @@ -32,8 +32,7 @@ module Grack self.user = User.find_by_email(login) || User.find_by_username(login) return false unless user.try(:valid_password?, password) - # Set GL_ID env variable - ENV['GL_ID'] = "user-#{user.id}" + Gitlab::ShellEnv.set_env(user) end # Git upload and receive diff --git a/lib/gitlab/backend/shell.rb b/lib/gitlab/backend/shell.rb index 85fa5bda055..b7b92e86a87 100644 --- a/lib/gitlab/backend/shell.rb +++ b/lib/gitlab/backend/shell.rb @@ -53,7 +53,6 @@ module Gitlab system("/home/git/gitlab-shell/bin/gitlab-keys rm-key #{key_id} \"#{key_content}\"") end - def url_to_repo path Gitlab.config.gitlab_shell.ssh_path_prefix + "#{path}.git" end diff --git a/lib/gitlab/backend/shell_env.rb b/lib/gitlab/backend/shell_env.rb new file mode 100644 index 00000000000..15721875093 --- /dev/null +++ b/lib/gitlab/backend/shell_env.rb @@ -0,0 +1,17 @@ +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 diff --git a/lib/gitlab/satellite/action.rb b/lib/gitlab/satellite/action.rb index ed2541f3998..63303ca3de1 100644 --- a/lib/gitlab/satellite/action.rb +++ b/lib/gitlab/satellite/action.rb @@ -17,6 +17,8 @@ module Gitlab # * Locks the satellite repo # * Yields the prepared satellite repo def in_locked_and_timed_satellite + Gitlab::ShellEnv.set_env(user) + Grit::Git.with_timeout(options[:git_timeout]) do project.satellite.lock do return yield project.satellite.repo @@ -28,6 +30,8 @@ module Gitlab rescue Grit::Git::GitTimeout => ex Gitlab::GitLogger.error(ex.message) return false + ensure + Gitlab::ShellEnv.reset_env end # * Clears the satellite |