From 61c2875edcfd770df4e005fb84a59e79db54fdd1 Mon Sep 17 00:00:00 2001 From: "Daniel (dB.) Doubrovkine" Date: Fri, 20 Nov 2026 20:50:07 -0500 Subject: [PATCH] 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 Claude-Session: https://claude.ai/code/session_011Gr21hZDQo5axDMuFgzL6s --- CHANGELOG.md | 1 + docs/changelog/intridea.md | 6 ++--- lib/ruby-gem-release/changelog/intridea.rb | 16 +++++++++--- .../changelog/intridea_spec.rb | 26 ++++++++++++------- 4 files changed, 34 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e03ff0e..9787ed8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/docs/changelog/intridea.md b/docs/changelog/intridea.md index 42dfe53..0f42634 100644 --- a/docs/changelog/intridea.md +++ b/docs/changelog/intridea.md @@ -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 @@ -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. diff --git a/lib/ruby-gem-release/changelog/intridea.rb b/lib/ruby-gem-release/changelog/intridea.rb index 389e946..eaaad24 100644 --- a/lib/ruby-gem-release/changelog/intridea.rb +++ b/lib/ruby-gem-release/changelog/intridea.rb @@ -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 diff --git a/spec/ruby_gem_release/changelog/intridea_spec.rb b/spec/ruby_gem_release/changelog/intridea_spec.rb index 4111f8b..255deaf 100644 --- a/spec/ruby_gem_release/changelog/intridea_spec.rb +++ b/spec/ruby_gem_release/changelog/intridea_spec.rb @@ -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 @@ -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