Skip to content
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## 0.9.1 (Next)

- [#90](https://github.com/dblock/ruby-gem-release/pull/90): Publish the released changelog section as GitHub Release notes in the standard workflow instead of generated notes, read before any publication - [@dblock](https://github.com/dblock).
- [#91](https://github.com/dblock/ruby-gem-release/pull/91): Accept an Intridea Next section with release notes but no contribution placeholder, rejecting a placeholder marked differently from the configured one - [@dblock](https://github.com/dblock).
- Your contribution here.

## 0.9.0 (2026/11/20)
Expand Down
6 changes: 3 additions & 3 deletions docs/changelog/intridea.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ changelog = RubyGemRelease::Changelog::Intridea.new(path: 'CHANGELOG.md')

## Placeholder

`placeholder:` defaults to `'- Your contribution here.'`. Set `placeholder: '* Your contribution here.'` for the alternative bullet. It must be a single nonempty line, configured identically for both phases.
`placeholder:` defaults to `'- Your contribution here.'`. Set `placeholder: '* Your contribution here.'` for the alternative bullet. It must be a single nonempty line, configured identically for both phases. The placeholder is optional in a Next section that has release notes; contributors may replace it. A line with the placeholder's text under a different list marker, such as `* Your contribution here.` when `- Your contribution here.` is configured, fails rather than being published as a note.

## Date

Expand All @@ -30,9 +30,9 @@ Pass `sections:`, such as `sections: %w[Features Fixes]`, to name the subsection

## Release

During `release:validate`, placeholder-only or structural-only notes fail unless the selected release already has a heading. Invalid headings and missing placeholders also fail; multiple matching placeholders are allowed.
During `release:validate`, placeholder-only or structural-only notes fail unless the selected release already has a heading. Invalid headings and placeholders marked differently from the configured one also fail; multiple matching placeholders are allowed.

`changelog.release!(release)` replaces the Next heading with the [Release](../release.md) version and date, removing every matching placeholder from that section. Missing or duplicate headings, a missing placeholder, or an existing release heading fail without writing the file.
`changelog.release!(release)` replaces the Next heading with the [Release](../release.md) version and date, removing every matching placeholder from that section. Missing or duplicate headings, a mismatched placeholder, or an existing release heading fail without writing the file.

Placeholder-only sections and sections containing only headings, comments, or reference definitions also fail without writing. Add actual release notes to the Next section before retrying; older releases do not count. There is no empty-release opt-out. See [Release Notes](base.md#release) for what counts as content.

Expand Down
16 changes: 13 additions & 3 deletions lib/ruby-gem-release/changelog/intridea.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,25 @@ def release_notes(section, separator, version, level)
check_notes(section, version)
end

# The placeholder is optional, but a differently marked copy would otherwise count as a release note.
def remove_placeholder(section, separator)
positions = []
editable_lines(section) { |line, offset| positions << offset if line.chomp == @placeholder }
raise ArgumentError, "expected at least one placeholder in #{@path}" if positions.empty?

editable_lines(section) do |line, offset|
positions << offset if line.chomp == @placeholder
raise ArgumentError, "placeholder #{line.strip.inspect} in #{@path} does not match the configured #{@placeholder.inspect}" if mismatched_placeholder?(line.chomp)
end
positions.reverse_each { |position| section.slice!(position, placeholder_length(section, position, separator)) }
section
end

def mismatched_placeholder?(line)
line != @placeholder && placeholder_text(line) == placeholder_text(@placeholder)
end

def placeholder_text(line)
line.strip.sub(/\A(?:[-*+]|\d+[.)])[ \t]+/, '')
end

def subsection_headings(content, position, level)
section_end = section_end_position(content, position, level)
lines = content.lines
Expand Down
26 changes: 17 additions & 9 deletions spec/ruby_gem_release/changelog/intridea_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,17 @@
expect(File.read(path)).to eq(content)
end

it 'rejects a missing placeholder during pending-note validation' do
content = "## 1.0.0 (Next)\n\n- Change.\n"
it 'accepts notes without a placeholder during pending-note validation' do
File.write(path, "## 1.0.0 (Next)\n\n- Change.\n\n## 0.9.0 (2026/01/01)\n\n- Older.\n")
expect(described_class.new(path: path).pending?).to be(true)
end

it 'rejects a placeholder marked differently from the configured one without writing', :aggregate_failures do
content = "## 1.0.0 (Next)\n\n* Your contribution here.\n"
File.write(path, content)
expect { described_class.new(path: path).pending? }.to raise_error(ArgumentError, /placeholder/)
expect { described_class.new(path: path).pending? }
.to raise_error(ArgumentError, /placeholder "\* Your contribution here\." in .*CHANGELOG.md does not match the configured "- Your contribution here\."/)
expect { described_class.new(path: path).release!(release) }.to raise_error(ArgumentError, /does not match the configured/)
expect(File.read(path)).to eq(content)
end

Expand Down Expand Up @@ -150,12 +157,13 @@
expect(File.binread(path)).to eq(content)
end

it 'rejects a missing placeholder without modifying the file' do
content = "## 1.0.0 (Next)\n\n- Change.\n"
File.write(path, content)
expect { described_class.new(path: path).release!(release) }
.to raise_error(ArgumentError, /placeholder/)
expect(File.read(path)).to eq(content)
it 'releases notes without a placeholder and restores it in the next section', :aggregate_failures do
File.write(path, "# Changelog\n\n## 1.0.0 (Next)\n\n- Change.\n")
changelog = described_class.new(path: path)
changelog.release!(release)
expect(File.read(path)).to include("## 1.0.0 (#{release.date.strftime('%Y/%m/%d')})\n\n- Change.\n")
changelog.prepare_next!(release.with_next_version('1.0.1'))
expect(File.read(path)).to start_with("# Changelog\n\n## 1.0.1 (Next)\n\n- Your contribution here.\n")
end

it 'writes release dates with a configured strftime format' do
Expand Down
Loading