Class: GitBreeze::PrepareCommitMessage

Inherits:
Object
  • Object
show all
Defined in:
lib/git_breeze/prepare_commit_message.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file, source = nil, commit_sha = nil) ⇒ PrepareCommitMessage

Returns a new instance of PrepareCommitMessage.



12
13
14
15
16
# File 'lib/git_breeze/prepare_commit_message.rb', line 12

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

Instance Attribute Details

#commit_shaObject (readonly)

Returns the value of attribute commit_sha.



6
7
8
# File 'lib/git_breeze/prepare_commit_message.rb', line 6

def commit_sha
  @commit_sha
end

#fileObject (readonly)

Returns the value of attribute file.



6
7
8
# File 'lib/git_breeze/prepare_commit_message.rb', line 6

def file
  @file
end

#sourceObject (readonly)

Returns the value of attribute source.



6
7
8
# File 'lib/git_breeze/prepare_commit_message.rb', line 6

def source
  @source
end

Class Method Details

.run(file, source = nil, commit_sha = nil) ⇒ Object



8
9
10
# File 'lib/git_breeze/prepare_commit_message.rb', line 8

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

Instance Method Details

#runObject



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/git_breeze/prepare_commit_message.rb', line 18

def run
  exit_when_commit_exists

  story = story_number_from_branch
  message = CommitMessage.new(file)
  exit if message.mentions_story?(story)
  movelist = message.movelist

  message_addition = ["##{story}", movelist].compact.join(' ')
  message.append(" -- Applies to story #{message_addition}")
end