class Gisha::Commands::Receive
Attributes
git_cmd[RW]
key_id[RW]
repo_name[RW]
repos_path[RW]
Public Class Methods
new(key_id)
click to toggle source
# File lib/gisha/commands/receive.rb, line 7 def initialize(key_id) @key_id = key_id end
Public Instance Methods
exec()
click to toggle source
# File lib/gisha/commands/receive.rb, line 11 def exec if origin_cmd parse_cmd if git_cmds.include?(git_cmd) process_cmd else raise DisallowedCommandError end end end
Private Instance Methods
escape_path(path)
click to toggle source
# File lib/gisha/commands/receive.rb, line 57 def escape_path(path) full_repo_path = File.join(repos_path, path) if File.absolute_path(full_repo_path) == full_repo_path path else abort "Wrong repository path" end end
exec_cmd(*args)
click to toggle source
# File lib/gisha/commands/receive.rb, line 33 def exec_cmd(*args) Kernel::exec( { 'PATH' => ENV['PATH'], 'LD_LIBRARY_PATH' => ENV['LD_LIBRARY_PATH'], 'KEY_ID' => key_id }, *args, unsetenv_others: true) end
git_cmds()
click to toggle source
# File lib/gisha/commands/receive.rb, line 53 def git_cmds %w(git-upload-pack git-receive-pack git-upload-archive) end
origin_cmd()
click to toggle source
# File lib/gisha/commands/receive.rb, line 49 def origin_cmd @origin_cmd ||= ENV['SSH_ORIGINAL_COMMAND'] end
parse_cmd()
click to toggle source
# File lib/gisha/commands/receive.rb, line 42 def parse_cmd args = Shellwords.shellwords(origin_cmd) raise DisallowedCommandError unless args.count == 2 @git_cmd = args[0] @repo_name = escape_path(args[1]) end
process_cmd()
click to toggle source
# File lib/gisha/commands/receive.rb, line 28 def process_cmd repo_full_path = File.join(repos_path, repo_name) exec_cmd(@git_cmd, repo_full_path) end