Class: Basketcase::CheckinCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/basketcase.rb

Instance Attribute Summary

Attributes inherited from Command

#comment, #listener, #targets

Instance Method Summary collapse

Methods inherited from Command

#accept_args, #effective_targets, #initialize, #option_comment, #option_graphical, #option_recurse, #report, #specified_targets

Methods included from Utils

#mkpath

Constructor Details

This class inherits a constructor from Basketcase::Command

Instance Method Details

#executeObject



489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
# File 'lib/basketcase.rb', line 489

def execute
  prompt_for_comment
  comment_file = Pathname.new("basketcase-checkin-comment.tmp")
  comment_file.open("w") do |out|
    out.puts(@comment)
  end
  cleartool_unsafe("checkin -cfile #{comment_file} #{specified_targets}") do |line|
    case line
    when /^Loading /
      # ignore
    when /^Making dir /
      # ignore
    when /^Checked in "(.+)" version "(\S+)"\./
      report(:COMMIT, mkpath($1), $2)
    else
      cannot_deal_with line
    end
  end
  comment_file.unlink
end

#helpObject



485
486
487
# File 'lib/basketcase.rb', line 485

def help
  "Check-in elements, prompting for a check-in message."
end

#prompt_for_commentObject

Raises:



510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
# File 'lib/basketcase.rb', line 510

def prompt_for_comment
  return if @comment
  comment_file = Pathname.new("basketcase-comment.tmp")
  begin
    comment_file.open('w') do |out|
      out.puts <<EOF
# Please enter the commit message for your changes.
# (Comment lines starting with '#' will not be included)
#
# Changes to be committed:
EOF
      specified_targets.each do |target|
        out.puts "#\t#{target}"
      end
    end
    edit(comment_file)
    @comment = comment_file.read.gsub(/^#.*\n/, '')
  ensure
    comment_file.unlink
  end
  raise UsageException, "No check-in comment provided" if @comment.empty?
  @comment
end

#synopsisObject



481
482
483
# File 'lib/basketcase.rb', line 481

def synopsis
  "<element> ..."
end