Module: GritService::Service::Repo

Extended by:
Helpers
Defined in:
lib/grit_service/service/repo.rb

Instance Method Summary collapse

Methods included from Helpers

service

Instance Method Details

#initialize_repo(path, options) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/grit_service/service/repo.rb', line 11

def initialize_repo(path, options)
  repo_options = {}
  epath = File.expand_path(path)

  if File.exist?(File.join(epath, '.git'))
    repo_options[:working_dir] = epath
    repo_options[:path] = File.join(epath, '.git')
    repo_options[:bare] = false
  elsif File.exist?(epath) && (epath =~ /\.git$/ || options[:is_bare])
    repo_options[:path] = epath
    repo_options[:bare] = true
  elsif File.exist?(epath)
    raise Grit::InvalidGitRepositoryError.new(epath)
  else
    raise Grit::NoSuchPathError.new(epath)
  end

  repo_options
end