Class: GitGuts::Server

Inherits:
Thor::GitGroup show all
Defined in:
lib/git_guts/server.rb

Constant Summary

Constants inherited from Thor::GitGroup

Thor::GitGroup::BASENAME

Instance Method Summary collapse

Methods inherited from Thor::GitGroup

basename, namespace

Instance Method Details

#startObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/git_guts/server.rb', line 15

def start
  repo_dir = (options[:dir] && File.expand_path(options[:dir])) || Dir.getwd
  puts repo_dir
  begin
    options[:dir] ? Git.bare(repo_dir) : Git.open(repo_dir)
    ENV['RACK_ENV'] = 'production'
    ENV['GIT_DIR'] = repo_dir
    ENV['BARE'] = '1' if options[:dir]
    require 'git_server/lib/git_server_app'
    Rack::Server.start :app => GitServerApp, :Port => options[:port]
  rescue ArgumentError
    puts "Could not start server. Is it a valid git repository ?"
  else
    puts "Server closed"
  end
end