Commit b83ab386 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

gitlab-shell base implementation

parent e620575d
config.yml
user: git
repos_path: "/home/git/repositories"
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
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