Skip to content

Commit 36c878d

Browse files
authored
Allow extract_release_notes_for_version to return the extracted release notes without saving to a file (#623)
2 parents f9cc258 + 9d98b8f commit 36c878d

2 files changed

Lines changed: 10 additions & 7 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ _None_
1111
### New Features
1212

1313
- Introduce new `openai_ask` action to get responses to a prompt/question from OpenAI API. [#621]
14+
- Allow `extract_release_notes_for_version` to return the extracted release notes without saving to a file. [#623]
1415

1516
### Bug Fixes
1617

lib/fastlane/plugin/wpmreleasetoolkit/actions/common/extract_release_notes_for_version_action.rb

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,18 @@ def self.run(params)
88
release_notes_file_path = params[:release_notes_file_path]
99
extracted_notes_file_path = params[:extracted_notes_file_path]
1010

11-
extracted_notes_file = File.open(extracted_notes_file_path, 'w') unless extracted_notes_file_path.blank?
12-
11+
extracted_notes = ''
1312
extract_notes(release_notes_file_path, version) do |line|
14-
extracted_notes_file.nil? ? puts(line) : extracted_notes_file.write(line)
13+
extracted_notes += line
1514
end
15+
extracted_notes.chomp!('') # Remove any extra empty line(s) at the end
1616

17-
return if extracted_notes_file.nil?
17+
unless extracted_notes_file_path.nil? || extracted_notes_file_path.empty?
18+
File.write(extracted_notes_file_path, extracted_notes)
19+
commit_extracted_notes_file(extracted_notes_file_path, version)
20+
end
1821

19-
extracted_notes_file.close
20-
commit_extracted_notes_file(extracted_notes_file_path, version)
22+
extracted_notes
2123
end
2224

2325
def self.extract_notes(release_notes_file_path, version)
@@ -57,7 +59,7 @@ def self.authors
5759
end
5860

5961
def self.return_value
60-
# If your method provides a return value, you can describe here what it does
62+
'The content of the extracted release notes (the same text as what was written in the `extracted_notes_file_path` if one was provided)'
6163
end
6264

6365
def self.details

0 commit comments

Comments
 (0)