Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fastlane_core] fix the display of non-unicode characters when printing lane context #21857

Merged
merged 3 commits into from
Feb 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
36 changes: 36 additions & 0 deletions fastlane/spec/lane_manager_base_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
describe Fastlane do
describe Fastlane::LaneManagerBase do
describe "#print_lane_context" do
it "prints lane context" do
Fastlane::Actions.lane_context[Fastlane::Actions::SharedValues::LANE_NAME] = "test"

cleaned_row_data = [[:LANE_NAME, "test"]]

table_data = FastlaneCore::PrintTable.transform_output(cleaned_row_data)
expect(FastlaneCore::PrintTable).to receive(:transform_output).with(cleaned_row_data).and_call_original
expect(Terminal::Table).to receive(:new).with({
title: "Lane Context".yellow,
rows: table_data
})
Fastlane::LaneManagerBase.print_lane_context
end

it "prints lane context" do
Fastlane::Actions.lane_context[Fastlane::Actions::SharedValues::LANE_NAME] = "test"

expect(UI).to receive(:important).with('Lane Context:'.yellow)
expect(UI).to receive(:message).with(Fastlane::Actions.lane_context)

FastlaneSpec::Env.with_verbose(true) do
Fastlane::LaneManagerBase.print_lane_context
end
end

it "doesn't crash when lane_context contains non unicode text" do
Fastlane::Actions.lane_context[Fastlane::Actions::SharedValues::LANE_NAME] = "test\xAE"

Fastlane::LaneManagerBase.print_lane_context
end
end
end
end
16 changes: 16 additions & 0 deletions fastlane_core/lib/fastlane_core/print_table.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
require_relative 'configuration/configuration'
require_relative 'helper'

# Monkey patch Terminal::Table until this is merged
# https://github.com/tj/terminal-table/pull/131
# solves https://github.com/fastlane/fastlane/issues/21852
# loads Terminal::Table first to be able to monkey patch it.
require 'terminal-table'
module Terminal
class Table
class Cell
def lines
# @value.to_s.split(/\n/)
@value.to_s.encode("utf-8", invalid: :replace).split(/\n/)
end
end
end
end

module FastlaneCore
class PrintTable
class << self
Expand Down