Sha256: 7924b212c5a5fe6a416c56fd465dd0396a049e0bd35f487b510fba2844ab63d2

Contents?: true

Size: 859 Bytes

Versions: 6

Compression:

Stored size: 859 Bytes

Contents

# By default, command runs only when story is finished
class FinishedCommand < Command

  def run!
    check_finishes unless force?
    system cmd
  end

  private

    # 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'.)
    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 --force to override"
        $stderr.puts warning
        exit 1
      end
    end

    def finished?
      !!(`git log -1`.match(/Finishe(s|d)|Deliver(s|ed)|Fixe(s|d) #\d+/i))
    end

    def force?
      options.force
    end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
pivotal-github-0.8.1 lib/pivotal-github/finished_command.rb
pivotal-github-0.8.0 lib/pivotal-github/finished_command.rb
pivotal-github-0.7.0 lib/pivotal-github/finished_command.rb
pivotal-github-0.6.14 lib/pivotal-github/finished_command.rb
pivotal-github-0.6.12 lib/pivotal-github/finished_command.rb
pivotal-github-0.6.11 lib/pivotal-github/finished_command.rb