Sha256: 32f0dcb264698966f9bc9c9e06b96664d8c8408a395bd19b89b17b9a85d93ed2

Contents?: true

Size: 740 Bytes

Versions: 2

Compression:

Stored size: 740 Bytes

Contents

# coding: UTF-8

Dir::glob(File.dirname(__FILE__) + '/git/*.rb').each do |file|
  require file
end

module Daddy
  
  class Git
    def branches
      branches = []
      `git branch -a`.split("\n").each do |b|
        next if b.index('HEAD')
        next if b.index('gh-pages')
        next unless b.index('remotes/origin/')
        branches << b.strip.sub('remotes/origin/', '')
      end
      
      branches.sort! do |a, b|
        if a == 'master'
          -1
        elsif b == 'master'
          1
        else
          b <=> a
        end
      end
      
      branches
    end
    
    def current_branch
      `git branch`.split("\n").each do |b|
        return b.split.last if b.start_with?('*')
      end
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
daddy-0.0.10 lib/daddy/git.rb
daddy-0.0.9 lib/daddy/git.rb