Sha256: fe1146899df17fd7cc23d39c0179495ba0396fff966a96eaf40a4f1e5d2ce7ad

Contents?: true

Size: 510 Bytes

Versions: 2

Compression:

Stored size: 510 Bytes

Contents

class BaseBranch::GitBranch
  class << self
    def current_branch
      raise(
        BaseBranch::BaseBranchExceptions::UninitializedRepository,
        'Please initialize a git repository and have at least one branch.'
      ) if (branchez = branches).empty?

      (branchez.detect { |br| br[0, 2] == '* ' } || '').gsub('* ', '').chomp
    end

    def master?
      current_branch == 'master'
    end

    def branches
      `git branch -a`.split("\n")
    end
  end

  private_class_method :branches
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
base-branch-0.1.2 lib/base_branch/git_branch.rb
base-branch-0.1.1 lib/base_branch/git_branch.rb