Skip to content

Bugfix: undefined method line_labels_for #753

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from Apr 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions lib/github_changelog_generator/generator/entry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ def generate_entry_for_tag(pull_requests, issues, newer_tag_name, newer_tag_link
@content
end

def line_labels_for(issue)
labels = if @options[:issue_line_labels] == ["ALL"]
issue["labels"]
else
issue["labels"].select { |label| @options[:issue_line_labels].include?(label["name"]) }
end
labels.map { |label| " \[[#{label['name']}](#{label['url'].sub('api.github.com/repos', 'github.com')})\]" }.join("")
end

private

# Creates section objects for this entry.
Expand Down Expand Up @@ -205,14 +214,5 @@ def add_unmapped_section(issues)
end
nil
end

def line_labels_for(issue)
labels = if @options[:issue_line_labels] == ["ALL"]
issue["labels"]
else
issue["labels"].select { |label| @options[:issue_line_labels].include?(label["name"]) }
end
labels.map { |label| " \[[#{label['name']}](#{label['url'].sub('api.github.com/repos', 'github.com')})\]" }.join("")
end
end
end
4 changes: 2 additions & 2 deletions lib/github_changelog_generator/generator/section.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module GitHubChangelogGenerator
#
# @see GitHubChangelogGenerator::Entry
class Section
attr_accessor :name, :prefix, :issues, :labels, :body_only
attr_accessor :name, :options, :prefix, :issues, :labels, :body_only
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're not using the setter, can :options become a attr_reader?


def initialize(opts = {})
@name = opts[:name]
Expand Down Expand Up @@ -49,7 +49,7 @@ def get_string_for_issue(issue)
encapsulated_title = encapsulate_string issue["title"]

title_with_number = "#{encapsulated_title} [\\##{issue['number']}](#{issue['html_url']})"
title_with_number = "#{title_with_number}#{line_labels_for(issue)}" if @options[:issue_line_labels].present?
title_with_number = "#{title_with_number}#{Entry.new(options).line_labels_for(issue)}" if @options[:issue_line_labels].present?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps later, one can build an @entry to be used to repeatedly make the line_labels_for call on?

line = issue_line_with_user(title_with_number, issue)
issue_line_with_body(line, issue)
end
Expand Down