Class: EY::Repo
Instance Method Summary collapse
- #current_branch ⇒ Object
-
#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.
6 7 8 |
# File 'lib/engineyard/repo.rb', line 6 def initialize(path=File.('.')) @path = path end |
Instance Method Details
#current_branch ⇒ Object
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 |
#urls ⇒ Object
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 |