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/http"
|
||||||
require "net/https"
|
require "net/https"
|
||||||
require "stringio"
|
require "stringio"
|
||||||
|
require "socket"
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
def gistify_logs(f)
|
def gistify_logs(f)
|
||||||
files = load_logs(f.logs)
|
files = load_logs(f.logs)
|
||||||
|
build_time = f.logs.ctime
|
||||||
|
timestamp = build_time.strftime("%Y-%m-%d_%H-%M-%S")
|
||||||
|
|
||||||
s = StringIO.new
|
s = StringIO.new
|
||||||
Homebrew.dump_verbose_config(s)
|
Homebrew.dump_verbose_config(s)
|
||||||
files["config.out"] = { :content => s.string }
|
# Dummy summary file, asciibetically first, to control display title of gist
|
||||||
files["doctor.out"] = { :content => `brew doctor 2>&1` }
|
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?
|
unless f.core_formula?
|
||||||
tap = <<-EOS.undent
|
tap = <<-EOS.undent
|
||||||
Formula: #{f.name}
|
Formula: #{f.name}
|
||||||
Tap: #{f.tap}
|
Tap: #{f.tap}
|
||||||
Path: #{f.path}
|
Path: #{f.path}
|
||||||
EOS
|
EOS
|
||||||
files["tap.out"] = { :content => tap }
|
files["00.tap.out"] = { :content => tap }
|
||||||
end
|
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")
|
if ARGV.include?("--new-issue") || ARGV.switch?("n")
|
||||||
auth = :AUTH_TOKEN
|
auth = :AUTH_TOKEN
|
||||||
@ -40,6 +51,19 @@ module Homebrew
|
|||||||
puts url if url
|
puts url if url
|
||||||
end
|
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
|
# Hack for ruby < 1.9.3
|
||||||
def noecho_gets
|
def noecho_gets
|
||||||
system "stty -echo"
|
system "stty -echo"
|
||||||
@ -68,8 +92,8 @@ module Homebrew
|
|||||||
logs
|
logs
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_gist(files)
|
def create_gist(files, descr)
|
||||||
post("/gists", "public" => true, "files" => files)["html_url"]
|
post("/gists", { "public" => true, "files" => files, "description" => descr })["html_url"]
|
||||||
end
|
end
|
||||||
|
|
||||||
def new_issue(repo, title, body, auth)
|
def new_issue(repo, title, body, auth)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user