Class: Giticious::Cli::Main
- Inherits:
-
Thor
- Object
- Thor
- Giticious::Cli::Main
- Defined in:
- lib/giticious/cli/main.rb
Instance Method Summary collapse
Instance Method Details
#check ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/giticious/cli/main.rb', line 13 def check begin Giticious::Check.run puts "Everything looks fine!" rescue => e $stderr.puts e. exit 1 end end |
#gitserve(user) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/giticious/cli/main.rb', line 34 def gitserve(user) abort unless user abort if ENV["SSH_ORIGINAL_COMMAND"].nil? command_match = ENV["SSH_ORIGINAL_COMMAND"].match(/(git\-upload\-pack|git\-receive\-pack) \'([A-Za-z0-9\-_\.]+)\.git\'/) abort "Project not found / Command invalid" if command_match.nil? action = command_match[1] repo = command_match[2] perms = Giticious::Service::Repository.new.(repo, user) abort "You have no access to #{repo}" if perms == false command = "#{command_match[1]} 'repositories/#{command_match[2]}.git'" abort "Read access denied" unless perms.perm_read abort "Write access denied" unless action == "git-receive-pack" and perms.perm_write Kernel.exec "git", "shell", "-c", command end |
#init ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/giticious/cli/main.rb', line 24 def init begin Giticious::Setup.run rescue => e $stderr.puts e. exit 1 end end |
#version ⇒ Object
7 8 9 10 |
# File 'lib/giticious/cli/main.rb', line 7 def version puts "Giticious: #{Giticious::VERSION}" puts "Ruby: #{RUBY_VERSION}" end |