Class: EY::Repo

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Repo.



8
9
10
# File 'lib/engineyard/repo.rb', line 8

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

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



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

def path
  @path
end

Instance Method Details

#current_branchObject



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/engineyard/repo.rb', line 16

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

#exists?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/engineyard/repo.rb', line 12

def exists?
  File.directory?(File.join(@path, ".git"))
end

#urlsObject



29
30
31
32
# File 'lib/engineyard/repo.rb', line 29

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