Sha256: cacca70ae9a6a4328a5f7386fcf4d6c15490a8acd8d96da0907b2ffbfc37b579

Contents?: true

Size: 407 Bytes

Versions: 3

Compression:

Stored size: 407 Bytes

Contents

require 'cap-util'

module CapUtil
  class GitBranch
    include CapUtil

    def self.current(action = :run)
      git_cmd = "git symbolic-ref HEAD"
      if action == :run
        say "Fetching #{color "current git branch", :bold, :cyan} from HEAD"
        (r = run_locally(git_cmd)).success? ? r.stdout.split('/').last.strip : halt
      elsif action == :cmd
        git_cmd
      end
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cap-util-1.5.2 lib/cap-util/git_branch.rb
cap-util-1.5.1 lib/cap-util/git_branch.rb
cap-util-1.5.0 lib/cap-util/git_branch.rb