Class: Sly::Branch

Inherits:
Object
  • Object
show all
Defined in:
lib/sly/branch.rb

Class Method Summary collapse

Class Method Details

.for(item_number) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/sly/branch.rb', line 8

def self.for(item_number)
  item = Sly::Item.with_number(item_number)
  raise "No Sprint.ly item found with that number" if item.nil?
  current_branches = git :branch
  prefix = "-b" unless current_branches =~ /-#{item.number}\n/
  git :checkout, [prefix, item.git_slug].join(' ')
end

.git(command, arg = "") ⇒ Object



16
17
18
19
20
21
# File 'lib/sly/branch.rb', line 16

def self.git(command, arg = "")
  command = "git #{command.to_s} #{arg.to_s}"
  output = %x[#{command} 2>&1]
  raise "Error running #{command}" unless $?.success?
  output
end