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>
This commit is contained in:
parent
e07adf1619
commit
d05c4d2408
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user