From b31a1bbc3a9eeaad49987d2d94e5b0d871efb0e4 Mon Sep 17 00:00:00 2001 From: Joey Paris Date: Fri, 22 Jan 2021 14:13:33 -0500 Subject: [PATCH 01/12] Update runtime dependency thor to newer version --- codelog.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codelog.gemspec b/codelog.gemspec index 00d663a..46507b9 100644 --- a/codelog.gemspec +++ b/codelog.gemspec @@ -21,7 +21,7 @@ Gem::Specification.new do |spec| spec.post_install_message = 'To start using the codelog run `codelog setup` and fill the `template.yml` file' spec.required_ruby_version = ">= 2.1.10" - spec.add_runtime_dependency "thor", "~> 0.19" + spec.add_runtime_dependency "thor", "~> 1.0" spec.add_development_dependency "bundler", "~> 1.15" spec.add_development_dependency "rake", "~> 10.0" From d3ae1e23c699f946ce98ff54e86991841022b3cd Mon Sep 17 00:00:00 2001 From: Joey Paris Date: Fri, 22 Jan 2021 14:20:13 -0500 Subject: [PATCH 02/12] Update changelog --- changelogs/unreleased/20210122141855785_change.yml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 changelogs/unreleased/20210122141855785_change.yml diff --git a/changelogs/unreleased/20210122141855785_change.yml b/changelogs/unreleased/20210122141855785_change.yml new file mode 100644 index 0000000..6e1635a --- /dev/null +++ b/changelogs/unreleased/20210122141855785_change.yml @@ -0,0 +1,2 @@ +"Changed": + - Change thor runtime dependency to ~> 1.0 From 1317b1c1c570e193980f6d19715b3ff965584a04 Mon Sep 17 00:00:00 2001 From: Joey Paris Date: Wed, 7 Apr 2021 13:45:34 -0400 Subject: [PATCH 03/12] Add pending changelog for unreleased changes --- CHANGELOG_PENDING.md | 5 ++++ changelogs/codelog.yml | 2 ++ .../unreleased/20210407134249312_change.yml | 2 ++ lib/codelog.rb | 1 + lib/codelog/cli.rb | 7 ++++++ lib/codelog/command/pending.rb | 15 ++++++++++++ lib/codelog/command/step/delete.rb | 1 + lib/codelog/config.rb | 8 +++++++ lib/codelog/output/release_file.rb | 2 +- spec/codelog/cli_spec.rb | 8 +++++++ spec/codelog/command/pending_spec.rb | 23 +++++++++++++++++++ spec/codelog/command/step/changelog_spec.rb | 1 + spec/codelog/config_spec.rb | 12 ++++++++++ spec/codelog/output/release_file_spec.rb | 2 +- 14 files changed, 87 insertions(+), 2 deletions(-) create mode 100644 CHANGELOG_PENDING.md create mode 100644 changelogs/unreleased/20210407134249312_change.yml create mode 100644 lib/codelog/command/pending.rb create mode 100644 spec/codelog/command/pending_spec.rb diff --git a/CHANGELOG_PENDING.md b/CHANGELOG_PENDING.md new file mode 100644 index 0000000..19cee18 --- /dev/null +++ b/CHANGELOG_PENDING.md @@ -0,0 +1,5 @@ +## Pending Changes +### Added +- Ability to create a pending changelog for unreleased changes + +--- diff --git a/changelogs/codelog.yml b/changelogs/codelog.yml index 452d18d..c9f32de 100644 --- a/changelogs/codelog.yml +++ b/changelogs/codelog.yml @@ -2,6 +2,8 @@ header_textfile: changelogs/header.txt default_changelog_filename: CHANGELOG.md +default_pending_changelog_filename: CHANGELOG_PENDING.md +default_pending_changelog_title: "Pending Changes" # Tag formatting --------------------------------------------------- diff --git a/changelogs/unreleased/20210407134249312_change.yml b/changelogs/unreleased/20210407134249312_change.yml new file mode 100644 index 0000000..669fec5 --- /dev/null +++ b/changelogs/unreleased/20210407134249312_change.yml @@ -0,0 +1,2 @@ +"Added": + - Ability to create a pending changelog for unreleased changes diff --git a/lib/codelog.rb b/lib/codelog.rb index 5e5edb8..4b437d9 100644 --- a/lib/codelog.rb +++ b/lib/codelog.rb @@ -8,6 +8,7 @@ require 'codelog/command/new' require 'codelog/command/release' require 'codelog/command/preview' +require 'codelog/command/pending' require 'codelog/command/bump' require 'codelog/command/step/changelog' require 'codelog/command/step/delete' diff --git a/lib/codelog/cli.rb b/lib/codelog/cli.rb index 3085b75..fe98d9d 100644 --- a/lib/codelog/cli.rb +++ b/lib/codelog/cli.rb @@ -30,6 +30,13 @@ def release(version_number, end end + desc 'pending ', 'Generate pending changelog from unreleased files' + method_option :title, desc: 'Title to use for the unreleased changes section', + aliases: ['-t', '--title'], type: :string + def pending(title = Codelog::Config.pending_changelog_title) + Codelog::Command::Pending.run title + end + desc 'bump [VERSION_TYPE] <RELEASE_DATE>', 'Bumps the next version, being it major, minor or patch' method_option :preview, desc: 'Prints the preview of the next version', diff --git a/lib/codelog/command/pending.rb b/lib/codelog/command/pending.rb new file mode 100644 index 0000000..f8c9e6e --- /dev/null +++ b/lib/codelog/command/pending.rb @@ -0,0 +1,15 @@ +module Codelog + module Command + class Pending + def self.run(title) + Codelog::Command::Pending.new.run title + end + + def run(title) + outputter = Codelog::Output::ReleaseFile.new(Codelog::Config.pending_filename) + Codelog::Command::Step::Version.run title, Date.today.strftime(Codelog::Config.date_input_format), outputter + puts "\n== Pending Changelog updated ==" + end + end + end +end diff --git a/lib/codelog/command/step/delete.rb b/lib/codelog/command/step/delete.rb index f7fb7b4..98fa7fd 100644 --- a/lib/codelog/command/step/delete.rb +++ b/lib/codelog/command/step/delete.rb @@ -13,6 +13,7 @@ def self.run def run chdir Dir.pwd do system('rm -rv changelogs/unreleased/*.yml') + system("> #{Codelog::Config.pending_filename}") end end end diff --git a/lib/codelog/config.rb b/lib/codelog/config.rb index d5c8190..16e2cdf 100644 --- a/lib/codelog/config.rb +++ b/lib/codelog/config.rb @@ -9,6 +9,14 @@ def filename settings['default_changelog_filename'] || 'CHANGELOG.md' end + def pending_filename + settings['default_pending_changelog_filename'] || 'CHANGELOG_PENDING.md' + end + + def pending_changelog_title + settings['default_pending_changelog_title'] || 'Pending Changes' + end + def header File.open(settings['header_textfile'], 'r').read || '' end diff --git a/lib/codelog/output/release_file.rb b/lib/codelog/output/release_file.rb index f70bdd1..88260c0 100644 --- a/lib/codelog/output/release_file.rb +++ b/lib/codelog/output/release_file.rb @@ -11,7 +11,7 @@ def self.print(content, file_path) def print(content) Dir.chdir Dir.pwd do - File.open(@file_path, 'a') do |line| + File.open(@file_path, 'w+') do |line| line.puts content end end diff --git a/spec/codelog/cli_spec.rb b/spec/codelog/cli_spec.rb index 452e934..27b9cae 100644 --- a/spec/codelog/cli_spec.rb +++ b/spec/codelog/cli_spec.rb @@ -43,6 +43,14 @@ subject.release '1.2.3', '2012-12-12' expect(Codelog::Command::Release).to have_received(:run).with '1.2.3', '2012-12-12' end + + describe '#pending' do + context 'passing the title as an argument' do + it 'calls the pending command' do + allow(Codelog::Command::Pending).to receive(:run) + subject.pending 'Pending Changes' + expect(Codelog::Command::Pending).to have_received(:run).with 'Pending Changes' + end end end diff --git a/spec/codelog/command/pending_spec.rb b/spec/codelog/command/pending_spec.rb new file mode 100644 index 0000000..cd76ceb --- /dev/null +++ b/spec/codelog/command/pending_spec.rb @@ -0,0 +1,23 @@ +require 'spec_helper' + +describe Codelog::Command::Pending do + describe '#run' do + let(:mock_file_outputter) { double(Codelog::Output::ReleaseFile) } + + it 'calls' do + allow(Codelog::Command::Step::Version).to receive(:new) + allow(Codelog::Output::ReleaseFile).to receive(:new).and_return(mock_file_outputter) + + expect(Codelog::Command::Step::Version).to receive(:run).with('Pending Changes', Date.today.strftime(Codelog::Config.date_input_format), mock_file_outputter) + expect(subject).to receive(:puts).with("\n== Pending Changelog updated ==") + subject.run 'Pending Changes' + end + end + + describe '.run' do + it 'creates an instance of the class to run the command' do + expect_any_instance_of(described_class).to receive(:run).with 'Pending Changes' + described_class.run 'Pending Changes' + end + end +end diff --git a/spec/codelog/command/step/changelog_spec.rb b/spec/codelog/command/step/changelog_spec.rb index d0b3882..3f77fed 100644 --- a/spec/codelog/command/step/changelog_spec.rb +++ b/spec/codelog/command/step/changelog_spec.rb @@ -21,6 +21,7 @@ it 'creates a changelog file from the releases' do allow(mocked_changelog).to receive(:puts) + expect(File).to receive(:open).with('changelogs/header.txt', 'r').and_return(mocked_header_textfile) expect(File).to receive(:open).with('CHANGELOG.md', 'w+').and_yield mocked_changelog subject.run expect(mocked_changelog).to have_received(:puts).with(['line_2\n', 'line_1\n']) diff --git a/spec/codelog/config_spec.rb b/spec/codelog/config_spec.rb index 3f5f11f..da530bf 100644 --- a/spec/codelog/config_spec.rb +++ b/spec/codelog/config_spec.rb @@ -22,6 +22,18 @@ end end + describe '#pending_filename' do + it 'returns the correct pending filename' do + expect(described_class.pending_filename).to eq('CHANGELOG_PENDING.md') + end + end + + describe '#pending_changelog_title' do + it 'returns the correct pending changelog title' do + expect(described_class.pending_changelog_title).to eq('Pending Changes') + end + end + describe '#header' do let(:mocked_header_file) { double(File, read: 'stubbed header') } diff --git a/spec/codelog/output/release_file_spec.rb b/spec/codelog/output/release_file_spec.rb index 9a27f9b..e079ac5 100644 --- a/spec/codelog/output/release_file_spec.rb +++ b/spec/codelog/output/release_file_spec.rb @@ -15,7 +15,7 @@ it 'prints the passed content in a file on the passed path' do subject - expect(File).to have_received(:open).with(file_path, 'a') + expect(File).to have_received(:open).with(file_path, 'w+') expect(mocked_file).to have_received(:puts).with(file_content) end end From 75043798616f8f62e0a283d76ff73de800782ad9 Mon Sep 17 00:00:00 2001 From: Joey Paris <joey@leadjig.com> Date: Wed, 7 Apr 2021 13:58:11 -0400 Subject: [PATCH 04/12] Update README.md --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index 5c4cefa..ae32a61 100644 --- a/README.md +++ b/README.md @@ -114,6 +114,16 @@ $ codelog release 1.0.0 --preview ``` Will display a preview of your changes on your console as if the version **1.0.0** has been released. +### Generate a Pending Releases Changelog + +You may find yourself wanting a single markdown file of all your unreleased changes, whether it be for testing purposes or as a list of changes coming soon. The `pending` command does that for you. + +```bash +$ codelog pending <TITLE> +``` + +`TITLE` is an option argument that is effectively the "Version" pending. The default value is `Pending Changes`. + ## Configuring Since version 0.3.0, there are a few configurations that are possible. You can choose: From 9897836111110f8ea1a71f372c7980b783370bad Mon Sep 17 00:00:00 2001 From: Joey Paris <joey@leadjig.com> Date: Fri, 16 Apr 2021 11:01:25 -0400 Subject: [PATCH 05/12] Prepend pending changes to CHANGELOG.md instead of creating separate file --- CHANGELOG.md | 6 ++++++ CHANGELOG_PENDING.md | 5 ----- changelogs/releases/pending.md | 6 ++++++ changelogs/unreleased/20210407134249312_change.yml | 3 ++- lib/codelog/cli.rb | 2 +- lib/codelog/command/pending.rb | 7 +++++-- lib/codelog/command/step/changelog.rb | 2 +- lib/codelog/command/step/delete.rb | 1 - lib/codelog/config.rb | 8 ++------ spec/codelog/cli_spec.rb | 9 +++++++++ spec/codelog/command/pending_spec.rb | 3 ++- spec/codelog/config_spec.rb | 10 ++-------- 12 files changed, 36 insertions(+), 26 deletions(-) delete mode 100644 CHANGELOG_PENDING.md create mode 100644 changelogs/releases/pending.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 00cbbd1..786fa60 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## Pending Changes +### Added +- Ability to include pending changes in changelog for unreleased changes +- Test for the release preview flag + +--- ## 0.8.0 ### Added - Preview option for changelogs on the `release` and `bump` command diff --git a/CHANGELOG_PENDING.md b/CHANGELOG_PENDING.md deleted file mode 100644 index 19cee18..0000000 --- a/CHANGELOG_PENDING.md +++ /dev/null @@ -1,5 +0,0 @@ -## Pending Changes -### Added -- Ability to create a pending changelog for unreleased changes - ---- diff --git a/changelogs/releases/pending.md b/changelogs/releases/pending.md new file mode 100644 index 0000000..e4123a9 --- /dev/null +++ b/changelogs/releases/pending.md @@ -0,0 +1,6 @@ +## Pending Changes +### Added +- Ability to include pending changes in changelog for unreleased changes +- Test for the release preview flag + +--- diff --git a/changelogs/unreleased/20210407134249312_change.yml b/changelogs/unreleased/20210407134249312_change.yml index 669fec5..090a7d1 100644 --- a/changelogs/unreleased/20210407134249312_change.yml +++ b/changelogs/unreleased/20210407134249312_change.yml @@ -1,2 +1,3 @@ "Added": - - Ability to create a pending changelog for unreleased changes + - Ability to include pending changes in changelog for unreleased changes + - Test for the release preview flag diff --git a/lib/codelog/cli.rb b/lib/codelog/cli.rb index fe98d9d..147a487 100644 --- a/lib/codelog/cli.rb +++ b/lib/codelog/cli.rb @@ -33,7 +33,7 @@ def release(version_number, desc 'pending <TITLE>', 'Generate pending changelog from unreleased files' method_option :title, desc: 'Title to use for the unreleased changes section', aliases: ['-t', '--title'], type: :string - def pending(title = Codelog::Config.pending_changelog_title) + def pending(title = Codelog::Config.pending_changes_title) Codelog::Command::Pending.run title end diff --git a/lib/codelog/command/pending.rb b/lib/codelog/command/pending.rb index f8c9e6e..7064cb8 100644 --- a/lib/codelog/command/pending.rb +++ b/lib/codelog/command/pending.rb @@ -1,14 +1,17 @@ module Codelog module Command class Pending + RELEASES_PATH = 'changelogs/releases'.freeze + def self.run(title) Codelog::Command::Pending.new.run title end def run(title) - outputter = Codelog::Output::ReleaseFile.new(Codelog::Config.pending_filename) + outputter = Codelog::Output::ReleaseFile.new("#{RELEASES_PATH}/pending.md") Codelog::Command::Step::Version.run title, Date.today.strftime(Codelog::Config.date_input_format), outputter - puts "\n== Pending Changelog updated ==" + Codelog::Command::Step::Changelog.run + puts "\n== Pending changes added to changelog ==" end end end diff --git a/lib/codelog/command/step/changelog.rb b/lib/codelog/command/step/changelog.rb index 4e11c0d..0c1c922 100644 --- a/lib/codelog/command/step/changelog.rb +++ b/lib/codelog/command/step/changelog.rb @@ -22,7 +22,7 @@ def changes version_changelogs = Dir['changelogs/releases/*.md'] version_changelogs.sort_by! do |file_name| version_number = file_name.split('/').last.chomp('.md') - Gem::Version.new(version_number) + version_number == 'pending' ? version_number : Gem::Version.new(version_number).to_s end.reverse! version_changelogs.inject([]) do |partial_changes, version_changelog| partial_changes + File.readlines(version_changelog) diff --git a/lib/codelog/command/step/delete.rb b/lib/codelog/command/step/delete.rb index 98fa7fd..f7fb7b4 100644 --- a/lib/codelog/command/step/delete.rb +++ b/lib/codelog/command/step/delete.rb @@ -13,7 +13,6 @@ def self.run def run chdir Dir.pwd do system('rm -rv changelogs/unreleased/*.yml') - system("> #{Codelog::Config.pending_filename}") end end end diff --git a/lib/codelog/config.rb b/lib/codelog/config.rb index 16e2cdf..ec0f3db 100644 --- a/lib/codelog/config.rb +++ b/lib/codelog/config.rb @@ -9,12 +9,8 @@ def filename settings['default_changelog_filename'] || 'CHANGELOG.md' end - def pending_filename - settings['default_pending_changelog_filename'] || 'CHANGELOG_PENDING.md' - end - - def pending_changelog_title - settings['default_pending_changelog_title'] || 'Pending Changes' + def pending_changes_title + settings['default_pending_changes_title'] || 'Pending Changes' end def header diff --git a/spec/codelog/cli_spec.rb b/spec/codelog/cli_spec.rb index 27b9cae..15411f5 100644 --- a/spec/codelog/cli_spec.rb +++ b/spec/codelog/cli_spec.rb @@ -44,6 +44,15 @@ expect(Codelog::Command::Release).to have_received(:run).with '1.2.3', '2012-12-12' end + it 'calls the release command with the preview flag' do + allow(Codelog::Command::Preview).to receive(:run) + subject.options = {preview: true} + subject.release '1.2.3', '2012-12-12' + expect(Codelog::Command::Preview).to have_received(:run).with '1.2.3', '2012-12-12' + end + end + end + describe '#pending' do context 'passing the title as an argument' do it 'calls the pending command' do diff --git a/spec/codelog/command/pending_spec.rb b/spec/codelog/command/pending_spec.rb index cd76ceb..20578b0 100644 --- a/spec/codelog/command/pending_spec.rb +++ b/spec/codelog/command/pending_spec.rb @@ -9,7 +9,8 @@ allow(Codelog::Output::ReleaseFile).to receive(:new).and_return(mock_file_outputter) expect(Codelog::Command::Step::Version).to receive(:run).with('Pending Changes', Date.today.strftime(Codelog::Config.date_input_format), mock_file_outputter) - expect(subject).to receive(:puts).with("\n== Pending Changelog updated ==") + expect(Codelog::Command::Step::Changelog).to receive(:run) + expect(subject).to receive(:puts).with("\n== Pending changes added to changelog ==") subject.run 'Pending Changes' end end diff --git a/spec/codelog/config_spec.rb b/spec/codelog/config_spec.rb index da530bf..ac6d2ad 100644 --- a/spec/codelog/config_spec.rb +++ b/spec/codelog/config_spec.rb @@ -22,15 +22,9 @@ end end - describe '#pending_filename' do - it 'returns the correct pending filename' do - expect(described_class.pending_filename).to eq('CHANGELOG_PENDING.md') - end - end - - describe '#pending_changelog_title' do + describe '#pending_changes_title' do it 'returns the correct pending changelog title' do - expect(described_class.pending_changelog_title).to eq('Pending Changes') + expect(described_class.pending_changes_title).to eq('Pending Changes') end end From 48eb8c995733c70f15aa31cf65ea066dacd6e08c Mon Sep 17 00:00:00 2001 From: Joey Paris <joey@leadjig.com> Date: Fri, 16 Apr 2021 11:05:31 -0400 Subject: [PATCH 06/12] Update README and codelog.yml config --- README.md | 4 ++-- changelogs/codelog.yml | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ae32a61..07c3fea 100644 --- a/README.md +++ b/README.md @@ -114,9 +114,9 @@ $ codelog release 1.0.0 --preview ``` Will display a preview of your changes on your console as if the version **1.0.0** has been released. -### Generate a Pending Releases Changelog +### Add Pending Releases to Changelog -You may find yourself wanting a single markdown file of all your unreleased changes, whether it be for testing purposes or as a list of changes coming soon. The `pending` command does that for you. +You may find yourself wanting to include all of your unreleased changes in your changelog, whether it be for testing purposes or as a list of changes coming soon. The `pending` command does that for you. ```bash $ codelog pending <TITLE> diff --git a/changelogs/codelog.yml b/changelogs/codelog.yml index c9f32de..2361b04 100644 --- a/changelogs/codelog.yml +++ b/changelogs/codelog.yml @@ -2,8 +2,7 @@ header_textfile: changelogs/header.txt default_changelog_filename: CHANGELOG.md -default_pending_changelog_filename: CHANGELOG_PENDING.md -default_pending_changelog_title: "Pending Changes" +default_pending_changes_title: "Pending Changes" # Tag formatting --------------------------------------------------- From c09b76da57de33a4cafec6acc6254c3439e501d0 Mon Sep 17 00:00:00 2001 From: Joey Paris <joey@leadjig.com> Date: Fri, 16 Apr 2021 11:14:16 -0400 Subject: [PATCH 07/12] Fix rubocop offenses --- lib/codelog/command/pending.rb | 4 +++- lib/codelog/command/regenerate.rb | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/codelog/command/pending.rb b/lib/codelog/command/pending.rb index 7064cb8..bb0dab6 100644 --- a/lib/codelog/command/pending.rb +++ b/lib/codelog/command/pending.rb @@ -9,7 +9,9 @@ def self.run(title) def run(title) outputter = Codelog::Output::ReleaseFile.new("#{RELEASES_PATH}/pending.md") - Codelog::Command::Step::Version.run title, Date.today.strftime(Codelog::Config.date_input_format), outputter + Codelog::Command::Step::Version.run title, + Date.today.strftime(Codelog::Config.date_input_format), + outputter Codelog::Command::Step::Changelog.run puts "\n== Pending changes added to changelog ==" end diff --git a/lib/codelog/command/regenerate.rb b/lib/codelog/command/regenerate.rb index 815837b..f9d75fe 100644 --- a/lib/codelog/command/regenerate.rb +++ b/lib/codelog/command/regenerate.rb @@ -7,7 +7,7 @@ def self.run def run Codelog::Command::Step::Changelog.run - puts "The CHANGELOG was regenerated successfully!" + puts 'The CHANGELOG was regenerated successfully!' end end end From 6fd8fdc6f31df47b8db4076c1139a79da08d5fc6 Mon Sep 17 00:00:00 2001 From: Joey Paris <joey@leadjig.com> Date: Fri, 16 Apr 2021 11:21:44 -0400 Subject: [PATCH 08/12] Add additional regenerate rspec test --- spec/codelog/command/regenerate_spec.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/spec/codelog/command/regenerate_spec.rb b/spec/codelog/command/regenerate_spec.rb index 2cfb611..ad8c526 100644 --- a/spec/codelog/command/regenerate_spec.rb +++ b/spec/codelog/command/regenerate_spec.rb @@ -1,12 +1,18 @@ require 'spec_helper' describe Codelog::Command::Regenerate do + describe '#run' do + it 'calls the "Changelog" step to re-generate the CHANGELOG using existing releases' do + expect(Codelog::Command::Step::Changelog).to receive(:run) + expect(subject).to receive(:puts).with("The CHANGELOG was regenerated successfully!") + subject.run + end + end + describe '.run' do it 'calls the "Changelog" step to re-generate the CHANGELOG using existing releases' do allow(Codelog::Command::Step::Changelog).to receive(:run) - described_class.run - expect(Codelog::Command::Step::Changelog).to have_received(:run) end end From 39d476db3309217916bc0e666327c71e177c9f80 Mon Sep 17 00:00:00 2001 From: Joey Paris <joey@leadjig.com> Date: Fri, 16 Apr 2021 11:23:18 -0400 Subject: [PATCH 09/12] Add regenerate rspec test to cli tests --- spec/codelog/cli_spec.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/spec/codelog/cli_spec.rb b/spec/codelog/cli_spec.rb index 15411f5..acb43ff 100644 --- a/spec/codelog/cli_spec.rb +++ b/spec/codelog/cli_spec.rb @@ -53,6 +53,14 @@ end end + describe '#regenerate' do + it 'calls the regenerate command' do + allow(Codelog::Command::Regenerate).to receive(:run) + subject.regenerate + expect(Codelog::Command::Regenerate).to have_received(:run) + end + end + describe '#pending' do context 'passing the title as an argument' do it 'calls the pending command' do From 1024178f5ee5dd60adf93699cab3575d184d35ac Mon Sep 17 00:00:00 2001 From: joeyparis <mail@joeyparis.me> Date: Tue, 20 Apr 2021 19:43:54 -0400 Subject: [PATCH 10/12] Update spec/codelog/command/pending_spec.rb Co-authored-by: Guilherme Moreira Santos <gmoreirasantos1325@hotmail.com> --- spec/codelog/command/pending_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/codelog/command/pending_spec.rb b/spec/codelog/command/pending_spec.rb index 20578b0..2dbc62b 100644 --- a/spec/codelog/command/pending_spec.rb +++ b/spec/codelog/command/pending_spec.rb @@ -4,7 +4,7 @@ describe '#run' do let(:mock_file_outputter) { double(Codelog::Output::ReleaseFile) } - it 'calls' do + it 'adds the pending changes to the changelog' do allow(Codelog::Command::Step::Version).to receive(:new) allow(Codelog::Output::ReleaseFile).to receive(:new).and_return(mock_file_outputter) From abcf77a1ee7b293a593ea202a86a6a91e78a7d7f Mon Sep 17 00:00:00 2001 From: Joey Paris <joey@leadjig.com> Date: Mon, 3 May 2021 17:44:01 -0400 Subject: [PATCH 11/12] Fix issue where pending changes would still be included/duplicated as pending changes after a new release --- lib/codelog/command/step/delete.rb | 1 + spec/codelog/command/step/delete_spec.rb | 2 ++ 2 files changed, 3 insertions(+) diff --git a/lib/codelog/command/step/delete.rb b/lib/codelog/command/step/delete.rb index f7fb7b4..c29e113 100644 --- a/lib/codelog/command/step/delete.rb +++ b/lib/codelog/command/step/delete.rb @@ -13,6 +13,7 @@ def self.run def run chdir Dir.pwd do system('rm -rv changelogs/unreleased/*.yml') + system('[ -f changelogs/releases/pending.md ] && rm -rv changelogs/releases/pending.md') end end end diff --git a/spec/codelog/command/step/delete_spec.rb b/spec/codelog/command/step/delete_spec.rb index 3c2ffe0..25ac9a8 100644 --- a/spec/codelog/command/step/delete_spec.rb +++ b/spec/codelog/command/step/delete_spec.rb @@ -10,6 +10,8 @@ it 'removes all the files from the unreleased folder' do expect(subject).to have_received(:system) .with('rm -rv changelogs/unreleased/*.yml') + expect(subject).to have_received(:system) + .with('[ -f changelogs/releases/pending.md ] && rm -rv changelogs/releases/pending.md') end end From 1f7ab947c3de323db7fe33ffd4f1663d8ce22f1e Mon Sep 17 00:00:00 2001 From: Joey Paris <joey@leadjig.com> Date: Tue, 27 Jan 2026 12:58:29 -0500 Subject: [PATCH 12/12] Update pending changelog and Ruby tooling --- .ruby-version | 1 + CHANGELOG.md | 5 +++++ changelogs/releases/pending.md | 5 +++++ codelog.gemspec | 2 +- lib/codelog/command/step/version.rb | 1 + 5 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 .ruby-version diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 0000000..86fb650 --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +3.3.7 diff --git a/CHANGELOG.md b/CHANGELOG.md index 786fa60..7ba1f8e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,9 +5,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## Pending Changes ### Added +- Command `codelog regenerate` that re-generates the CHANGELOG based on the existing releases +- Added `[-v | --version]` option to the `codelog` command - Ability to include pending changes in changelog for unreleased changes - Test for the release preview flag +### Changed +- Change thor runtime dependency to ~> 1.0 + --- ## 0.8.0 ### Added diff --git a/changelogs/releases/pending.md b/changelogs/releases/pending.md index e4123a9..8625efc 100644 --- a/changelogs/releases/pending.md +++ b/changelogs/releases/pending.md @@ -1,6 +1,11 @@ ## Pending Changes ### Added +- Command `codelog regenerate` that re-generates the CHANGELOG based on the existing releases +- Added `[-v | --version]` option to the `codelog` command - Ability to include pending changes in changelog for unreleased changes - Test for the release preview flag +### Changed +- Change thor runtime dependency to ~> 1.0 + --- diff --git a/codelog.gemspec b/codelog.gemspec index 46507b9..3767183 100644 --- a/codelog.gemspec +++ b/codelog.gemspec @@ -23,7 +23,7 @@ Gem::Specification.new do |spec| spec.add_runtime_dependency "thor", "~> 1.0" - spec.add_development_dependency "bundler", "~> 1.15" + spec.add_development_dependency "bundler", "~> 2.6" spec.add_development_dependency "rake", "~> 10.0" spec.add_development_dependency "rspec", "~> 3.4" spec.add_development_dependency "rubocop", "~> 0.52.1" diff --git a/lib/codelog/command/step/version.rb b/lib/codelog/command/step/version.rb index facdd79..c568016 100644 --- a/lib/codelog/command/step/version.rb +++ b/lib/codelog/command/step/version.rb @@ -1,3 +1,4 @@ +require 'stringio' require 'date' require 'yaml' require 'fileutils'