Generate mapping that will match expectations
This change neccesitated changing the behavior or the `filter_since_tag`. Since we want our compare links to include the since tag, we need to keep that tag in the filtered list. Instead, we detect that the tag is the since tag and filter it out. This will prevent the since_tag header from being duplicated when pulling from a base. The same goes for the first tag listed in between_tags. We don't want an empty section header for this. Signed-off-by: Tom Duffield <tom@chef.io>
This commit is contained in:
parent
c718930fb1
commit
d6c26ef4a9
|
@ -25,9 +25,16 @@ module GitHubChangelogGenerator
|
|||
# PRs to include in this section will be >= [Left Tag Date] and <= [Right Tag Date]
|
||||
def build_tag_section_mapping(filtered_tags, all_tags)
|
||||
tag_mapping = {}
|
||||
filtered_tags.each do |tag|
|
||||
older_tag_idx = all_tags.index(tag) + 1
|
||||
older_tag = all_tags[older_tag_idx]
|
||||
for i in 0..(filtered_tags.length - 1)
|
||||
tag = filtered_tags[i]
|
||||
|
||||
# Don't create section header for the "since" tag
|
||||
next if @since_tag && tag["name"] == @since_tag
|
||||
|
||||
# Don't create a section header for the first tag in between_tags
|
||||
next if options[:between_tags] && tag == filtered_tags.last
|
||||
|
||||
older_tag = filtered_tags[i + 1]
|
||||
tag_mapping[tag] = [older_tag, tag]
|
||||
end
|
||||
tag_mapping
|
||||
|
@ -113,7 +120,7 @@ module GitHubChangelogGenerator
|
|||
if all_tags.map { |t| t["name"] }.include? tag
|
||||
idx = all_tags.index { |t| t["name"] == tag }
|
||||
filtered_tags = if idx > 0
|
||||
all_tags[0..idx - 1]
|
||||
all_tags[0..idx]
|
||||
else
|
||||
[]
|
||||
end
|
||||
|
|
|
@ -232,7 +232,7 @@ describe GitHubChangelogGenerator::Generator do
|
|||
context "with valid since tag" do
|
||||
let(:generator) { GitHubChangelogGenerator::Generator.new(since_tag: "2") }
|
||||
it { is_expected.to be_a Array }
|
||||
it { is_expected.to match_array(tags_from_strings(%w[1])) }
|
||||
it { is_expected.to match_array(tags_from_strings(%w[1 2])) }
|
||||
end
|
||||
|
||||
context "with invalid since tag" do
|
||||
|
|
Loading…
Reference in New Issue
Block a user