class Git::Branch

def archive(file, opts = {})

def archive(file, opts = {})
  @base.lib.archive(@full, file, opts)
end

def check_if_create

def check_if_create
  @base.lib.branch_new(@name) rescue nil
end

def checkout

def checkout
  check_if_create
  @base.checkout(@full)
end

def contains?(commit)

def contains?(commit)
  !@base.lib.branch_contains(commit, self.name).empty?
end

def create

def create
  check_if_create
end

def current

def current
  determine_current
end

def delete

def delete
  @base.lib.branch_delete(@name)
end

def determine_current

def determine_current
  @base.lib.branch_current == @name
end

def gcommit

def gcommit
  @gcommit ||= @base.gcommit(@full)
  @gcommit
end

def in_branch (message = 'in branch work')

end
return true # auto commits and switches back
# do other stuff
# create new file
g.branch('new_branch').in_branch do
def in_branch (message = 'in branch work')
  old_current = @base.lib.branch_current
  checkout
  if yield
    @base.commit_all(message)
  else
    @base.reset_hard
  end
  @base.checkout(old_current)
end

def initialize(base, name)

def initialize(base, name)
  @full = name
  @base = base
  @gcommit = nil
  @stashes = nil
  @remote, @name = parse_name(name)
end

def merge(branch = nil, message = nil)

def merge(branch = nil, message = nil)
  if branch
    in_branch do 
      @base.merge(branch, message)
      false
    end
    # merge a branch into this one
  else
    # merge this branch into the current one
    @base.merge(@name)
  end
end

def parse_name(name)

return [] an Array containing the remote and branch names.
param [String] name branch full name.

parse_name('origin/master/v2') #=> ['origin', 'master/v2']
parse_name('remotes/origin/master') #=> ['origin', 'master']
parse_name('origin/master') #=> ['origin', 'master']
parse_name('master') #=> [nil, 'master']
Example:

Takes the rest as the repo name (can also hold one or more '/').
Takes the second part (splittign by '/') as the remote name.
Removes 'remotes' from the beggining of the name (if present).

Given a full branch name return an Array containing the remote and branch names.
def parse_name(name)
  if name.match(/^(?:remotes)?\/([^\/]+)\/(.+)/)
    return [Git::Remote.new(@base, $1), $2]
  end
  return [nil, name]
end

def stashes

def stashes
  @stashes ||= Git::Stashes.new(@base)
end

def to_a

def to_a
  [@full]
end

def to_s

def to_s
  @full
end

def update_ref(commit)

def update_ref(commit)
  @base.lib.update_ref(@full, commit)
end