diff options
Diffstat (limited to 'lib/gitlab_shell.rb')
| -rw-r--r-- | lib/gitlab_shell.rb | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/lib/gitlab_shell.rb b/lib/gitlab_shell.rb index 4d4d240..93acc57 100644 --- a/lib/gitlab_shell.rb +++ b/lib/gitlab_shell.rb @@ -1,17 +1,25 @@ require 'open3' +require 'yaml' + class GitlabShell - attr_accessor :username, :repo_name, :git_cmd + attr_accessor :username, :repo_name, :git_cmd, :repos_path def initialize @username = ARGV.shift @origin_cmd = ENV['SSH_ORIGINAL_COMMAND'] + @config = YAML.load_file(File.join(ROOT_PATH, 'config.yml')) + @repos_path = @config['repos_path'] end def exec if @origin_cmd parse_cmd - return system("git-upload-pack /home/gip/repositories/#{@repo_name}") + if git_cmds.include?(@git_cmd) + process_cmd + else + puts 'Not allowed command' + end else puts "Welcome #{@username}!" end @@ -28,4 +36,9 @@ class GitlabShell def git_cmds %w(git-upload-pack git-receive-pack git-upload-archive) end + + def process_cmd + repo_full_path = File.join(repos_path, repo_name) + system("#{@git_cmd} #{repo_full_path}") + end end |
