Sha256: f54d1c1bcba18c589623eaa1ac9cefac72c8c0b84856ed50cee1fe3d60dac1da

Contents?: true

Size: 710 Bytes

Versions: 5

Compression:

Stored size: 710 Bytes

Contents

require 'git_tracker/branch'
require 'git_tracker/commit_message'

module GitTracker
  class PrepareCommitMessage
    attr_reader :file, :source, :commit_sha

    def self.run(file, source=nil, commit_sha=nil)
      new(file, source, commit_sha).run
    end

    def initialize(file, source=nil, commit_sha=nil)
      @file = file
      @source = source
      @commit_sha = commit_sha
    end

    def run
      story = story_number_from_branch

      message = CommitMessage.new(file)
      exit if message.mentions_story?(story)
      message.append("[##{story}]")
    end

    private

    def story_number_from_branch
      story = Branch.story_number
      exit unless story
      story
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
git_tracker-1.1.0 lib/git_tracker/prepare_commit_message.rb
git_tracker-1.0.2 lib/git_tracker/prepare_commit_message.rb
git_tracker-1.0.1 lib/git_tracker/prepare_commit_message.rb
git_tracker-1.0.0 lib/git_tracker/prepare_commit_message.rb
git_tracker-0.0.1 lib/git_tracker/prepare_commit_message.rb