Commit e620575d authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

working git upload

parent bb9863e8
#!/usr/bin/env ruby #!/usr/bin/env ruby
unless ENV['SSH_CONNECTION']
puts "Only ssh allowed"
exit
end
# #
# GitLab shell, invoked from ~/.ssh/authorized_keys # GitLab shell, invoked from ~/.ssh/authorized_keys
# #
ROOT_PATH = File.join(File.expand_path(File.dirname(__FILE__)), "..")
ROOT_PATH = File.expand_path('..', __FILE__) require File.join(ROOT_PATH, 'lib', 'gitlab_shell')
GitlabShell.new.exec
puts ENV['SSH_CONNECTION'].inspect
exit exit
require 'open3'
class GitlabShell
attr_accessor :username, :repo_name, :git_cmd
def initialize
@username = ARGV.shift
@origin_cmd = ENV['SSH_ORIGINAL_COMMAND']
end
def exec
if @origin_cmd
parse_cmd
return system("git-upload-pack /home/gip/repositories/#{@repo_name}")
else
puts "Welcome #{@username}!"
end
end
protected
def parse_cmd
args = @origin_cmd.split(' ')
@git_cmd = args.shift
@repo_name = args.shift
end
def git_cmds
%w(git-upload-pack git-receive-pack git-upload-archive)
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