Skip to content

Commit

Permalink
Merge pull request #17 from SOFware/bug/fix-finalize
Browse files Browse the repository at this point in the history
Fix finalize to retain changelogs
  • Loading branch information
saturnflyer authored Jan 17, 2025
2 parents 7cea550 + 5dda7a5 commit ed756ed
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [0.3.3] - Unreleased

### Fixed

- Properly retain changelog on `reissue:finalize`

## [0.3.2] - 2025-01-16

### Fixed
Expand Down
4 changes: 2 additions & 2 deletions lib/reissue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ def self.call(
# @param changelog_file [String] The path to the changelog file.
#
# @return [Array] The version number and release date.
def self.finalize(date = Date.today, changelog_file: "CHANGELOG.md")
def self.finalize(date = Date.today, changelog_file: "CHANGELOG.md", retain_changelogs: false)
changelog_updater = ChangelogUpdater.new(changelog_file)
changelog = changelog_updater.finalize(date:, changelog_file:)
changelog = changelog_updater.finalize(date:, changelog_file:, retain_changelogs:)
changelog["versions"].first.slice("version", "date").values
end

Expand Down
2 changes: 1 addition & 1 deletion lib/reissue/rake.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def define
desc "Finalize the changelog for an unreleased version to set the release date."
task "#{name}:finalize", [:date] do |task, args|
date = args[:date] || Time.now.strftime("%Y-%m-%d")
version, date = formatter.finalize(date, changelog_file:)
version, date = formatter.finalize(date, changelog_file:, retain_changelogs:)
finalize_message = "Finalize the changelog for version #{version} on #{date}"
if commit_finalize
tasker["#{name}:branch"].invoke("reissue/#{version}") if finalize_with_branch?
Expand Down
10 changes: 10 additions & 0 deletions test/test_reissue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,16 @@ class TestReissue < Minitest::Spec
assert_equal("0.1.2", version)
assert_equal("2021-01-01", date)
end

it "retains changelog history when specified" do
fixture_changelog = File.expand_path("fixtures/changelog.md", __dir__)
tempdir = Dir.mktmpdir
changelog_file = Tempfile.new
changelog_file << File.read(fixture_changelog)
changelog_file.close
Reissue.finalize("2021-01-01", changelog_file: changelog_file.path, retain_changelogs: tempdir)
assert File.exist?(File.join(tempdir, "0.1.2.md"))
end
end

describe ".reformat" do
Expand Down

0 comments on commit ed756ed

Please sign in to comment.