Sha256: b9b6a4dd4420c509b149e7e9e87c278b98e7512ddbcea427ceb0f700faebb7ab

Contents?: true

Size: 513 Bytes

Versions: 4

Compression:

Stored size: 513 Bytes

Contents

# coding: utf-8

module Githelp
  def git_branch
    begin
      `git branch`
    rescue
      nil
    end
  end
  
  def branches
    b = git_branch
    if b
      b.split(/\n/).map { |line|
        line.chomp!
        line.sub(/^../,'')
      }
    else
      [ '##BRANCH##' ]
    end
  end
  
  def branch
    b = git_branch
    if b
      b.split(/\n/).map { |line|
        line.chomp!
        if line =~ /^\* (.*)$/ then
          return $1
        end
      }
      ''
    else
      ''
    end
  end
end


Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
githelp-0.1.4 lib/githelp/branches.rb
githelp-0.1.3 lib/githelp/branches.rb
githelp-0.1.2 lib/githelp/branches.rb
githelp-0.1.1 lib/githelp/branches.rb