Class: CommitChangelog

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

Overview

Filters commit messages for changelog entries.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(to_commit, from_commit) ⇒ Array

Instantiates an object containing changelog entries between two git commits.

Parameters:

  • to_commit (String)

    Most recent commit whose changelog lines to include.

  • from_commit (String)

    Earlier commit whose changelog lines will not be included.



34
35
36
37
38
39
# File 'lib/commit_changelog.rb', line 34

def initialize(to_commit, from_commit)
  pattern = ChangelogFilter.pattern
  messages = Git.get_filtered_messages(from_commit, to_commit, pattern)
  filter = ChangelogFilter.FromString(messages)
  @changelog = filter.changelog
end

Instance Attribute Details

#changelogObject (readonly)

Contains changelog entries of the commits.



20
21
22
# File 'lib/commit_changelog.rb', line 20

def changelog
  @changelog
end

Instance Method Details

#add_commit(commit) ⇒ Object

Adds changelog information contained in a specific commit message. This method is typically used to parse the initial commit’s commit message.

Parameters:

  • commit (String)

    Sha-1 of the commit whose commit message to filter for changelog lines.

Returns:

  • Undefined



50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/commit_changelog.rb', line 50

def add_commit(commit)
  pattern = ChangelogFilter.pattern
  filtered_text = Git.get_filtered_message(commit, pattern)
  if filtered_text
    filtered_lines = filtered_text.split("\n").uniq
    if @changelog
      @changelog = @changelog.concat(filtered_lines).uniq
    else
      @changelog = filtered_lines
    end
  end
end