Class: EY::Repo

Inherits:
Object show all
Defined in:
lib/engineyard/repo.rb

Instance Method Summary collapse

Constructor Details

#initialize(path = File.expand_path('.')) ⇒ Repo

Returns a new instance of Repo.



6
7
8
# File 'lib/engineyard/repo.rb', line 6

def initialize(path=File.expand_path('.'))
  @path = path
end

Instance Method Details

#current_branchObject



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/engineyard/repo.rb', line 10

def current_branch
  if File.directory?(File.join(@path, ".git"))
    head = File.read(File.join(@path, ".git/HEAD")).chomp
    if head.gsub!("ref: refs/heads/", "")
      head
    else
      nil
    end
  else
    nil
  end
end

#urlsObject

Raises:



23
24
25
26
27
# File 'lib/engineyard/repo.rb', line 23

def urls
  lines = `git config -f #{Escape.shell_command(@path)}/.git/config --get-regexp 'remote.*.url'`.split(/\n/)
  raise NoRemotesError.new(@path) if lines.empty?
  lines.map { |c| c.split.last }
end