Class: CapUtil::GitBranch

Inherits:
Object
  • Object
show all
Includes:
CapUtil
Defined in:
lib/cap-util/git_branch.rb

Constant Summary

Constants included from CapUtil

VERSION

Class Method Summary collapse

Methods included from CapUtil

color, #get, halt, #hostname, included, run_locally, run_locally_with_stdin, say, say_bulleted, say_error, say_raw, say_warning, time

Class Method Details

.current(action = :run) ⇒ Object



7
8
9
10
11
12
13
14
15
# 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