class CommandLine::SubCommands::RebaseCommand

Public Class Methods

new(new_args, new_input_stream = STDIN) click to toggle source
Calls superclass method CommandLine::Command::new
# File lib/git/contest/command_line/sub_commands/rebase_command.rb, line 15
def initialize(new_args, new_input_stream = STDIN)
  super
end

Public Instance Methods

define_options() click to toggle source
# File lib/git/contest/command_line/sub_commands/rebase_command.rb, line 19
def define_options
  opt_parser.on "-i", "--interactive", "Do an interactive rebase." do
    options[:interactive] = true
  end
end
run() click to toggle source
# File lib/git/contest/command_line/sub_commands/rebase_command.rb, line 29
def run
  expand_nameprefix_arg_or_current

  puts "Will try to rebase '#{$NAME}'..."

  Git.require_clean_working_tree
  Git.require_branch $BRANCH

  Git.do "checkout -q \"#{$BRANCH}\""
  rebase_options = ""
  if options[:interactive]
    rebase_options += " -i"
  end

  puts Git.do "rebase #{rebase_options} #{$MASTER}"

end
set_default_options() click to toggle source
# File lib/git/contest/command_line/sub_commands/rebase_command.rb, line 25
def set_default_options
  options[:interactive] = false if options[:interactive].nil?
end

Private Instance Methods

expand_nameprefix_arg(name, prefix) click to toggle source
# File lib/git/contest/command_line/sub_commands/rebase_command.rb, line 61
def expand_nameprefix_arg name, prefix
  expanded_name = Git.contest_resolve_nameprefix name, prefix
  exitcode = $?.to_i
  if $? == 0
    $NAME = expanded_name
    $BRANCH = "#{$PREFIX}/#{$NAME}"
  else
    return 1
    end
end
expand_nameprefix_arg_or_current() click to toggle source
# File lib/git/contest/command_line/sub_commands/rebase_command.rb, line 72
def expand_nameprefix_arg_or_current
  if has_next_token?
    expand_nameprefix_arg tokens.first, $PREFIX
    Git.require_branch "#{$PREFIX}/#{$NAME}"
  else
    use_current_branch
    end
end
use_current_branch() click to toggle source
# File lib/git/contest/command_line/sub_commands/rebase_command.rb, line 49
def use_current_branch
  current_branch = Git.current_branch
  if current_branch.start_with? $PREFIX
    $BRANCH = current_branch.strip
    $NAME = $BRANCH[$PREFIX.length+1..-1]
  else
    puts "The current HEAD is no feature branch."
    puts "Please spefcify a <name> argument."
    abort ''
  end
end