class CapUtil::GitBranch

Public Class Methods

current(action = :run) click to toggle source
# File lib/cap-util/git_branch.rb, line 7
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