class Gitit::GitBranches



Public Class Methods

new(repo) click to toggle source


# File lib/gitit/git_branches.rb, line 12
def initialize(repo)
  @repo = repo
end

Public Instance Methods

create_local_branch(name) click to toggle source


# File lib/gitit/git_branches.rb, line 40
def create_local_branch(name)
  execute_command("branch --quiet #{name}")
  $?.exitstatus == 0
end
exists_locally?(name) click to toggle source


# File lib/gitit/git_branches.rb, line 26
def exists_locally?(name)
  branches = execute_command('branch --no-color').gsub(/^[* ] /, '').lines.map(&:chomp).to_a
  branches.include? name
end
exists_remotely?(name, remote) click to toggle source


# File lib/gitit/git_branches.rb, line 33
def exists_remotely?(name, remote)
  branches = execute_command('branch -r --no-color').gsub(/^[* ] /, '').lines.map(&:chomp).to_a
  branches.include? "#{remote}/#{name}"
end
get_current_branch() click to toggle source


# File lib/gitit/git_branches.rb, line 18
def get_current_branch
  branches = execute_command('branch --no-color')
  branch_match = branches.each_line.select { |b| b.start_with? '* ' }
  branch_match[0].strip.gsub(/\* /, '')
end
push_local_branch_to_remote(name, remote, force) click to toggle source


# File lib/gitit/git_branches.rb, line 47
def push_local_branch_to_remote(name, remote, force)
  execute_command("push --quiet -f #{remote} #{name}") if force
  execute_command("push --quiet #{remote} #{name}") unless force
  $?.exitstatus == 0
end