Skip to content

Commit 1ef335c

Browse files
authored
Merge pull request #196 from fastlane/lk/fix-release-notes-file-default
Make --release_notes_file take precedence over FL_CHANGELOG
2 parents 2562e8e + b42fd9e commit 1ef335c

File tree

4 files changed

+51
-4
lines changed

4 files changed

+51
-4
lines changed

.ruby-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2.6.3

lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_action.rb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ def self.run(params)
5353
end
5454
end
5555

56-
release_notes = get_value_from_value_or_file(params[:release_notes], params[:release_notes_file])
57-
fad_api_client.post_notes(app_id, release_id, release_notes)
56+
fad_api_client.post_notes(app_id, release_id, release_notes(params))
5857

5958
testers = get_value_from_value_or_file(params[:testers], params[:testers_file])
6059
groups = get_value_from_value_or_file(params[:groups], params[:groups_file])
@@ -153,6 +152,12 @@ def self.validate_app!(app, binary_type)
153152
end
154153
end
155154

155+
def self.release_notes(params)
156+
release_notes_param =
157+
get_value_from_value_or_file(params[:release_notes], params[:release_notes_file])
158+
release_notes_param || Actions.lane_context[SharedValues::FL_CHANGELOG]
159+
end
160+
156161
def self.available_options
157162
[
158163
# iOS Specific
@@ -217,8 +222,6 @@ def self.available_options
217222
FastlaneCore::ConfigItem.new(key: :release_notes,
218223
env_name: "FIREBASEAPPDISTRO_RELEASE_NOTES",
219224
description: "Release notes for this build",
220-
default_value: Actions.lane_context[SharedValues::FL_CHANGELOG],
221-
default_value_dynamic: true,
222225
optional: true,
223226
type: String),
224227
FastlaneCore::ConfigItem.new(key: :release_notes_file,

spec/firebase_app_distribution_action_spec.rb

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,45 @@
170170
end
171171
end
172172

173+
describe '#release_notes' do
174+
before do
175+
allow(Fastlane::Actions.lane_context).to receive('[]')
176+
.with(Fastlane::Actions::SharedValues::FL_CHANGELOG)
177+
.and_return('changelog-content')
178+
end
179+
180+
describe 'when no release notes are set' do
181+
let(:params) { {} }
182+
it 'defaults to changelog' do
183+
expect(action.release_notes(params)).to eq('changelog-content')
184+
end
185+
end
186+
187+
describe 'when only release_notes_file is set' do
188+
let(:params) { { release_notes_file: 'release-notes-file-path' } }
189+
let(:fake_file) { double('File') }
190+
191+
it 'uses release_notes_file' do
192+
expect(fake_file).to receive(:read).and_return('release-notes-file-content')
193+
expect(File).to receive(:open).with('release-notes-file-path').and_return(fake_file)
194+
expect(action.release_notes(params)).to eq('release-notes-file-content')
195+
end
196+
end
197+
198+
describe 'when release_notes and release_notes_file are set' do
199+
let(:params) do
200+
{
201+
release_notes: 'release-notes-content',
202+
release_notes_file: 'release-notes-file-path'
203+
}
204+
end
205+
206+
it 'uses release_notes' do
207+
expect(action.release_notes(params)).to eq('release-notes-content')
208+
end
209+
end
210+
end
211+
173212
describe '#run' do
174213
let(:params) do
175214
{

spec/firebase_app_distribution_helper_spec.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@
4848
expect { helper.get_value_from_value_or_file(nil, "invalid_path") }
4949
.to raise_error("#{ErrorMessage::INVALID_PATH}: invalid_path")
5050
end
51+
52+
it 'returns nil when the value and path are both nil' do
53+
expect(helper.get_value_from_value_or_file(nil, nil)).to eq(nil)
54+
end
5155
end
5256

5357
describe '#string_to_array' do

0 commit comments

Comments
 (0)