Skip to content

Commit 4fdb698

Browse files
authored
Prevent frozen string errors in promo screenshots action (#653)
2 parents 7827298 + d9544c7 commit 4fdb698

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ _None_
1414

1515
### Bug Fixes
1616

17-
_None_
17+
- Fix `can't modify frozen String: "transparent"` and other `FrozenError` crashes in `promo_screenshots_action`. [#653]
1818

1919
### Internal Changes
2020

lib/fastlane/plugin/wpmreleasetoolkit/helper/promo_screenshots_helper.rb

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@ module Helper
2424
class PromoScreenshots
2525
def initialize
2626
if $skip_magick
27-
message = "PromoScreenshots feature is currently disabled.\n"
28-
message << "Please, install RMagick if you aim to generate the PromoScreenshots.\n"
29-
message << "'bundle install --with screenshots' should do it if your project is configured for PromoScreenshots.\n"
30-
message << 'Aborting.'
27+
message = <<~MSG
28+
PromoScreenshots feature is currently disabled.
29+
Please, install RMagick if you aim to generate the PromoScreenshots.
30+
'bundle install --with screenshots' should do it if your project is configured for PromoScreenshots.
31+
Aborting.
32+
MSG
3133
UI.user_error!(message)
3234
end
3335

@@ -400,10 +402,13 @@ def open_image(path)
400402
end
401403

402404
def create_image(width, height, background = 'transparent')
403-
background.paint.to_hex
405+
# The paint method we call below modifies the string in place.
406+
# But if the string is frozen, we need to dup it first, otherwise we'll get a frozen string error.
407+
working_background = background.frozen? ? background.dup : background
408+
working_background.paint.to_hex
404409

405410
Image.new(width, height) do
406-
self.background_color = background
411+
self.background_color = working_background
407412
end
408413
end
409414

0 commit comments

Comments
 (0)