class FinishedCommand

By default, command runs only when story is finished

Public Instance Methods

run!() click to toggle source
# File lib/pivotal-github/finished_command.rb, line 4
def run!
  check_finishes unless override?
  system cmd
end

Private Instance Methods

check_finishes() click to toggle source

Checks to see if the most recent commit finishes the story We look for ‘Finishes’ or ‘Delivers’ and issue a warning if neither is in the most recent commit. (Also supports ‘Finished’ and ‘Delivered’.)

# File lib/pivotal-github/finished_command.rb, line 14
def check_finishes
  unless finished?
    warning =  "Warning: Unfinished story\n"
    warning += "Run `git commit --amend` to add 'Finishes' or 'Delivers' "
    warning += "to the commit message\n"
    warning += "Use --override to override"
    $stderr.puts warning
    exit 1
  end
end
finished?() click to toggle source
# File lib/pivotal-github/finished_command.rb, line 25
def finished?
  !!(`git log -1`.match(/Finishe(s|d)|Deliver(s|ed)|Fixe(s|d) #\d+/i))
end
override?() click to toggle source
# File lib/pivotal-github/finished_command.rb, line 29
def override?
  options.override
end