From 4fe8d0b905c3ca1e4d4f5e03e20678472786f108 Mon Sep 17 00:00:00 2001 From: Olivier Halligon Date: Wed, 11 Dec 2024 17:31:18 +0100 Subject: [PATCH 1/2] Allow `extract_release_notes_for_version` to return the extracted release notes without saving to a file --- .../extract_release_notes_for_version_action.rb | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/extract_release_notes_for_version_action.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/extract_release_notes_for_version_action.rb index 5d7219707..fbb86a406 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/extract_release_notes_for_version_action.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/extract_release_notes_for_version_action.rb @@ -8,16 +8,18 @@ def self.run(params) release_notes_file_path = params[:release_notes_file_path] extracted_notes_file_path = params[:extracted_notes_file_path] - extracted_notes_file = File.open(extracted_notes_file_path, 'w') unless extracted_notes_file_path.blank? - + extracted_notes = '' extract_notes(release_notes_file_path, version) do |line| - extracted_notes_file.nil? ? puts(line) : extracted_notes_file.write(line) + extracted_notes += line end + extracted_notes.chomp!('') # Remove any extra empty line(s) at the end - return if extracted_notes_file.nil? + unless extracted_notes_file_path.nil? || extracted_notes_file_path.empty? + File.write(extracted_notes_file_path, extracted_notes) + commit_extracted_notes_file(extracted_notes_file_path, version) + end - extracted_notes_file.close - commit_extracted_notes_file(extracted_notes_file_path, version) + extracted_notes end def self.extract_notes(release_notes_file_path, version) @@ -57,7 +59,7 @@ def self.authors end def self.return_value - # If your method provides a return value, you can describe here what it does + 'The content of the extracted release notes (the same text as what was written in the `extracted_notes_file_path` if one was provided)' end def self.details From 9d98b8f0e780f5496447a27480eab7a4a4867608 Mon Sep 17 00:00:00 2001 From: Olivier Halligon Date: Wed, 11 Dec 2024 17:32:41 +0100 Subject: [PATCH 2/2] Add CHANGELOG entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 14e247cfc..a87b71fbd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ _None_ ### New Features - Introduce new `openai_ask` action to get responses to a prompt/question from OpenAI API. [#621] +- Allow `extract_release_notes_for_version` to return the extracted release notes without saving to a file. [#623] ### Bug Fixes