aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cmd/gist-logs.rb
diff options
context:
space:
mode:
authorAndrew Janke2016-07-05 08:45:17 -0400
committerGitHub2016-07-05 08:45:17 -0400
commitf518f57bd8c9ff864dc23911fac59f10995302b9 (patch)
tree7e2e4eb6ab977329bf47679f48de56113831a4b4 /Library/Homebrew/cmd/gist-logs.rb
parent1b1bf56733e1ede7d414c8a5ef1e04dabc645455 (diff)
downloadbrew-f518f57bd8c9ff864dc23911fac59f10995302b9.tar.bz2
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.
Diffstat (limited to 'Library/Homebrew/cmd/gist-logs.rb')
-rw-r--r--Library/Homebrew/cmd/gist-logs.rb3
1 files changed, 3 insertions, 0 deletions
diff --git a/Library/Homebrew/cmd/gist-logs.rb b/Library/Homebrew/cmd/gist-logs.rb
index 72616463d..bcb15cd14 100644
--- a/Library/Homebrew/cmd/gist-logs.rb
+++ b/Library/Homebrew/cmd/gist-logs.rb
@@ -91,6 +91,9 @@ module Homebrew
logs = {}
dir.children.sort.each do |file|
contents = file.size? ? file.read : "empty log"
+ # small enough to avoid GitHub "unicorn" page-load-timeout errors
+ max_file_size = 1_000_000
+ contents = truncate_text_to_approximate_size(contents, max_file_size, :front_weight => 0.2)
logs[file.basename.to_s] = { :content => contents }
end if dir.exist?
raise "No logs." if logs.empty?