Skip to content

Commit 61c2875

Browse files
dblockclaude
andcommitted
Accept Intridea notes without a contribution placeholder
A Next section with real notes no longer fails because its placeholder line was replaced. The placeholder is still removed when present and restored for the next version. A line with the placeholder's text under a different list marker still fails, so a misconfigured placeholder is not published as a release note. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011Gr21hZDQo5axDMuFgzL6s
1 parent 3bbb1f1 commit 61c2875

4 files changed

Lines changed: 34 additions & 15 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## 0.9.1 (Next)
44

55
- [#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).
6+
- [#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).
67
- Your contribution here.
78

89
## 0.9.0 (2026/11/20)

‎docs/changelog/intridea.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ changelog = RubyGemRelease::Changelog::Intridea.new(path: 'CHANGELOG.md')
1616

1717
## Placeholder
1818

19-
`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.
19+
`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.
2020

2121
## Date
2222

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

3131
## Release
3232

33-
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.
33+
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.
3434

35-
`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.
35+
`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.
3636

3737
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.
3838

‎lib/ruby-gem-release/changelog/intridea.rb‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,25 @@ def release_notes(section, separator, version, level)
102102
check_notes(section, version)
103103
end
104104

105+
# The placeholder is optional, but a differently marked copy would otherwise count as a release note.
105106
def remove_placeholder(section, separator)
106107
positions = []
107-
editable_lines(section) { |line, offset| positions << offset if line.chomp == @placeholder }
108-
raise ArgumentError, "expected at least one placeholder in #{@path}" if positions.empty?
109-
108+
editable_lines(section) do |line, offset|
109+
positions << offset if line.chomp == @placeholder
110+
raise ArgumentError, "placeholder #{line.strip.inspect} in #{@path} does not match the configured #{@placeholder.inspect}" if mismatched_placeholder?(line.chomp)
111+
end
110112
positions.reverse_each { |position| section.slice!(position, placeholder_length(section, position, separator)) }
111113
section
112114
end
113115

116+
def mismatched_placeholder?(line)
117+
line != @placeholder && placeholder_text(line) == placeholder_text(@placeholder)
118+
end
119+
120+
def placeholder_text(line)
121+
line.strip.sub(/\A(?:[-*+]|\d+[.)])[ \t]+/, '')
122+
end
123+
114124
def subsection_headings(content, position, level)
115125
section_end = section_end_position(content, position, level)
116126
lines = content.lines

‎spec/ruby_gem_release/changelog/intridea_spec.rb‎

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,17 @@
3232
expect(File.read(path)).to eq(content)
3333
end
3434

35-
it 'rejects a missing placeholder during pending-note validation' do
36-
content = "## 1.0.0 (Next)\n\n- Change.\n"
35+
it 'accepts notes without a placeholder during pending-note validation' do
36+
File.write(path, "## 1.0.0 (Next)\n\n- Change.\n\n## 0.9.0 (2026/01/01)\n\n- Older.\n")
37+
expect(described_class.new(path: path).pending?).to be(true)
38+
end
39+
40+
it 'rejects a placeholder marked differently from the configured one without writing', :aggregate_failures do
41+
content = "## 1.0.0 (Next)\n\n* Your contribution here.\n"
3742
File.write(path, content)
38-
expect { described_class.new(path: path).pending? }.to raise_error(ArgumentError, /placeholder/)
43+
expect { described_class.new(path: path).pending? }
44+
.to raise_error(ArgumentError, /placeholder "\* Your contribution here\." in .*CHANGELOG.md does not match the configured "- Your contribution here\."/)
45+
expect { described_class.new(path: path).release!(release) }.to raise_error(ArgumentError, /does not match the configured/)
3946
expect(File.read(path)).to eq(content)
4047
end
4148

@@ -150,12 +157,13 @@
150157
expect(File.binread(path)).to eq(content)
151158
end
152159

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

161169
it 'writes release dates with a configured strftime format' do

0 commit comments

Comments
 (0)