From f518f57bd8c9ff864dc23911fac59f10995302b9 Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Tue, 5 Jul 2016 08:45:17 -0400 Subject: gist-logs: truncate log files to be gist-friendly (#279) Truncates each log file to about 1 MB. This avoids upload and download errors with the gists, and respects GitHub's suggested size limits.--- Library/Homebrew/dev-cmd/test-bot.rb | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) (limited to 'Library/Homebrew/dev-cmd') diff --git a/Library/Homebrew/dev-cmd/test-bot.rb b/Library/Homebrew/dev-cmd/test-bot.rb index 3a5fd9f25..296d52f7b 100644 --- a/Library/Homebrew/dev-cmd/test-bot.rb +++ b/Library/Homebrew/dev-cmd/test-bot.rb @@ -45,10 +45,6 @@ module Homebrew HOMEBREW_TAP_REGEX = %r{^([\w-]+)/homebrew-([\w-]+)$} - def ruby_has_encoding? - String.method_defined?(:force_encoding) - end - if ruby_has_encoding? def fix_encoding!(str) # Assume we are starting from a "mostly" UTF-8 string @@ -1032,13 +1028,7 @@ module Homebrew # Truncate to 1MB to avoid hitting CI limits if output.bytesize > MAX_STEP_OUTPUT_SIZE - if ruby_has_encoding? - binary_output = output.force_encoding("BINARY") - output = binary_output.slice(-MAX_STEP_OUTPUT_SIZE, MAX_STEP_OUTPUT_SIZE) - fix_encoding!(output) - else - output = output.slice(-MAX_STEP_OUTPUT_SIZE, MAX_STEP_OUTPUT_SIZE) - end + output = truncate_text_to_approximate_size(output, MAX_STEP_OUTPUT_SIZE, :front_weight => 0.0) output = "truncated output to 1MB:\n" + output end end -- cgit v1.2.3