Class: EY::Repo
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #current_branch ⇒ Object
- #exists? ⇒ Boolean
-
#initialize(path = File.expand_path('.')) ⇒ Repo
constructor
A new instance of Repo.
- #urls ⇒ Object
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.('.')) @path = path end |
Instance Attribute Details
#path ⇒ Object (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_branch ⇒ Object
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
12 13 14 |
# File 'lib/engineyard/repo.rb', line 12 def exists? File.directory?(File.join(@path, ".git")) end |
#urls ⇒ Object
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 |