Class: EY::Repo

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repo_path = '.') ⇒ Repo

Returns a new instance of Repo.



10
11
12
# File 'lib/engineyard/repo.rb', line 10

def initialize(repo_path='.')
  self.path = repo_path
end

Instance Attribute Details

#pathObject

Returns the value of attribute path.



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

def path
  @path
end

Instance Method Details

#current_branchObject



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

def current_branch
  if exist? && (head = dotgit("HEAD").read.chomp) && head.gsub!("ref: refs/heads/", "")
    head
  else
    nil
  end
end

#exist?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/engineyard/repo.rb', line 18

def exist?
  dotgit.directory?
end

#fail_on_no_remotes!Object



38
39
40
41
42
# File 'lib/engineyard/repo.rb', line 38

def fail_on_no_remotes!
  if urls.empty?
    raise NoRemotesError.new(path)
  end
end

#has_remote?(repository_uri) ⇒ Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/engineyard/repo.rb', line 34

def has_remote?(repository_uri)
  urls.include?(repository_uri)
end

#urlsObject



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

def urls
  @urls ||= config('remote.*.url').map { |c| c.split.last }
end