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
6 changes: 6 additions & 0 deletions gems/kettle-jem/lib/kettle/jem.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7782,6 +7782,12 @@ def merge_config_template_source(recipe, template_content, destination_content,
return merge_changelog_template_source(template_content, destination_content, facts: facts) if recipe.fetch(:target_path) == "CHANGELOG.md"

merge_result = Ast::Template::MergeDispatch.dispatch(:markdown, template_content, destination_content)
# A successful structural merge can still produce no document (for
# example, a license containing only unheaded prose). Never replace a
# nonempty destination with that empty result.
if merge_result[:ok] && merge_result.fetch(:output).strip.empty? && !destination_content.strip.empty?
return destination_content
end
when :dotenv
merge_result = merge_dotenv_template_source(template_content, destination_content, recipe)
when :rbs
Expand Down
22 changes: 22 additions & 0 deletions gems/kettle-jem/spec/integration/template_bootstrap_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1073,6 +1073,28 @@
end
end

it "preserves a complete existing AGPL license when templating a monorepo subgem" do
Dir.mktmpdir("kettle-jem-agpl-license") do |root|
license = File.read(File.expand_path("../../lib/kettle/jem/templates/AGPL-3.0-only.md.example", __dir__))
destination = license.sub("GNU AFFERO GENERAL PUBLIC LICENSE", "GNU Affero General Public License")
write_tree(root, {
"example.gemspec" => <<~RUBY,
Gem::Specification.new do |spec|
spec.name = "example"
spec.summary = "Example gem"
spec.licenses = ["AGPL-3.0-only"]
spec.required_ruby_version = ">= 3.2"
end
RUBY
"AGPL-3.0-only.md" => destination
})
described_class.setup_project(root, env: {}, run_options: {bootstrap_mode: true, template_profile: "monorepo-subgem-release", skip_commit: true})
described_class.apply_project(root, env: {}, run_options: {only: "AGPL-3.0-only.md", accept: true, skip_commit: true})

expect(File.read(File.join(root, "AGPL-3.0-only.md"))).to eq(destination)
end
end

it "bootstraps a monorepo subgem release profile with per-gem harness entries" do
tmp_root = File.expand_path("../tmp", __dir__)
FileUtils.mkdir_p(tmp_root)
Expand Down
Loading