From f10691bccc2a4661e916ffe7556a7a29ff763ef1 Mon Sep 17 00:00:00 2001 From: Colin Dean Date: Sat, 20 Oct 2018 17:38:52 -0400 Subject: [PATCH] Add --private flag to gist-logs Co-Authored-By: JBallin --- Library/Homebrew/cmd/gist-logs.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/cmd/gist-logs.rb b/Library/Homebrew/cmd/gist-logs.rb index 2afad99ec3..0265cc1186 100644 --- a/Library/Homebrew/cmd/gist-logs.rb +++ b/Library/Homebrew/cmd/gist-logs.rb @@ -1,4 +1,4 @@ -#: * `gist-logs` [`--new-issue`|`-n`] : +#: * `gist-logs` [`--new-issue`|`-n`] [`--private`|`-p`] : #: Upload logs for a failed build of to a new Gist. #: #: is usually the name of the formula to install, but it can be specified @@ -9,6 +9,9 @@ #: If `--new-issue` is passed, automatically create a new issue in the appropriate #: GitHub repository as well as creating the Gist. #: +#: If `--private` is passed, the Gist will be marked private and will not +#: appear in listings but will be accessible with the link. +#: #: If no logs are found, an error message is presented. require "formula" @@ -110,9 +113,13 @@ module Homebrew logs end + def create_private? + ARGV.include?("--private") || ARGV.switch?("p") + end + def create_gist(files, description) url = "https://api.github.com/gists" - data = { "public" => true, "files" => files, "description" => description } + data = { "public" => !create_private?, "files" => files, "description" => description } scopes = GitHub::CREATE_GIST_SCOPES GitHub.open_api(url, data: data, scopes: scopes)["html_url"] end