Class: GitBreeze::CommitMessage

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

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ CommitMessage

Returns a new instance of CommitMessage.



4
5
6
7
# File 'lib/git_breeze/commit_message.rb', line 4

def initialize(file)
  @file = file
  @message = File.read(@file)
end

Instance Method Details

#append(text) ⇒ Object

def keyword

  @message =~ /\[(fix|fixes|fixed|complete|completes|completed|finish|finishes|finished|deliver|delivers|delivered)\]/io
  $1
end


25
26
27
28
29
30
31
32
# File 'lib/git_breeze/commit_message.rb', line 25

def append(text)
  body, postscript = parse(@message)
  new_message = format_message(body, text, postscript)
  File.open(@file, 'w') do |f|
    f.write(new_message)
  end
  new_message
end

#mentions_story?(number) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/git_breeze/commit_message.rb', line 9

def mentions_story?(number)
  @message =~ /^(?!#).*\[(\w+\s)?(#\d+\s)*##{number}(\s#\d+)*(\s\w+)?\]/io
end

#movelistObject



13
14
15
16
17
18
# File 'lib/git_breeze/commit_message.rb', line 13

def movelist
    @message =~ /(m\:[\w]+)/io
    movecommand = $1
    @message.sub! movecommand, ''
    movecommand
end