aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cmd/gist-logs.rb
diff options
context:
space:
mode:
authorAndrew Janke2015-10-16 05:41:50 -0400
committerAndrew Janke2015-11-26 12:42:30 -0500
commitd05c4d24083b11a8f9fff4417b24d094159ac70b (patch)
treebbbc6054b39c213dd5dfd237c9614353f01273e1 /Library/Homebrew/cmd/gist-logs.rb
parente07adf16198f0cd89d61ab4e6b50348417949308 (diff)
downloadbrew-d05c4d24083b11a8f9fff4417b24d094159ac70b.tar.bz2
gist-logs: Friendlier titles and display for log gists
Adds a summary file and description to get more informative displays on gist.github.com. Closes Homebrew/homebrew#45023. Signed-off-by: Andrew Janke <andrew@apjanke.net>
Diffstat (limited to 'Library/Homebrew/cmd/gist-logs.rb')
-rw-r--r--Library/Homebrew/cmd/gist-logs.rb36
1 files changed, 30 insertions, 6 deletions
diff --git a/Library/Homebrew/cmd/gist-logs.rb b/Library/Homebrew/cmd/gist-logs.rb
index 495041a71..29deb6551 100644
--- a/Library/Homebrew/cmd/gist-logs.rb
+++ b/Library/Homebrew/cmd/gist-logs.rb
@@ -3,25 +3,36 @@ require "cmd/config"
require "net/http"
require "net/https"
require "stringio"
+require "socket"
module Homebrew
def gistify_logs(f)
files = load_logs(f.logs)
+ build_time = f.logs.ctime
+ timestamp = build_time.strftime("%Y-%m-%d_%H-%M-%S")
s = StringIO.new
Homebrew.dump_verbose_config(s)
- files["config.out"] = { :content => s.string }
- files["doctor.out"] = { :content => `brew doctor 2>&1` }
+ # Dummy summary file, asciibetically first, to control display title of gist
+ files["# #{f.name} - #{timestamp}.txt"] = { :content => brief_build_info(f) }
+ files["00.config.out"] = { :content => s.string }
+ files["00.doctor.out"] = { :content => `brew doctor 2>&1` }
unless f.core_formula?
tap = <<-EOS.undent
Formula: #{f.name}
Tap: #{f.tap}
Path: #{f.path}
EOS
- files["tap.out"] = { :content => tap }
+ files["00.tap.out"] = { :content => tap }
end
- url = create_gist(files)
+ # Description formatted to work well as page title when viewing gist
+ if f.core_formula?
+ descr = "#{f.name} on #{OS_VERSION} - Homebrew build logs"
+ else
+ descr = "#{f.name} (#{f.full_name}) on #{OS_VERSION} - Homebrew build logs"
+ end
+ url = create_gist(files, descr)
if ARGV.include?("--new-issue") || ARGV.switch?("n")
auth = :AUTH_TOKEN
@@ -40,6 +51,19 @@ module Homebrew
puts url if url
end
+ def brief_build_info(f)
+ build_time_str = f.logs.ctime.strftime("%Y-%m-%d %H:%M:%S")
+ s = <<-EOS.undent
+ Homebrew build logs for #{f.full_name} on #{OS_VERSION}
+ EOS
+ if ARGV.include?("--with-hostname")
+ hostname = Socket.gethostname
+ s << "Host: #{hostname}\n"
+ end
+ s << "Build date: #{build_time_str}\n"
+ s
+ end
+
# Hack for ruby < 1.9.3
def noecho_gets
system "stty -echo"
@@ -68,8 +92,8 @@ module Homebrew
logs
end
- def create_gist(files)
- post("/gists", "public" => true, "files" => files)["html_url"]
+ def create_gist(files, descr)
+ post("/gists", { "public" => true, "files" => files, "description" => descr })["html_url"]
end
def new_issue(repo, title, body, auth)