From 3dd5a7465d0c7ad0b3d147c9c66ce8e6bf9ff675 Mon Sep 17 00:00:00 2001 From: Dawid Dziurla Date: Mon, 20 Apr 2020 10:17:42 +0200 Subject: [PATCH] add pr-upload command --- Library/Homebrew/dev-cmd/pr-upload.rb | 43 +++++++++++++++++++ .../Homebrew/test/dev-cmd/pr-upload_spec.rb | 7 +++ docs/Manpage.md | 11 +++++ manpages/brew.1 | 15 +++++++ 4 files changed, 76 insertions(+) create mode 100644 Library/Homebrew/dev-cmd/pr-upload.rb create mode 100644 Library/Homebrew/test/dev-cmd/pr-upload_spec.rb diff --git a/Library/Homebrew/dev-cmd/pr-upload.rb b/Library/Homebrew/dev-cmd/pr-upload.rb new file mode 100644 index 0000000000000..8d967cb95baa5 --- /dev/null +++ b/Library/Homebrew/dev-cmd/pr-upload.rb @@ -0,0 +1,43 @@ +# frozen_string_literal: true + +require "cli/parser" +require "bintray" + +module Homebrew + module_function + + def pr_upload_args + Homebrew::CLI::Parser.new do + usage_banner <<~EOS + `pr-upload` [] + + Apply the bottle commit and publish bottles to Bintray. + EOS + switch "--no-publish", + description: "Apply the bottle commit and upload the bottles, but don't publish them." + switch "--dry-run", "-n", + description: "Print what would be done rather than doing it." + flag "--bintray-org=", + description: "Upload to the specified Bintray organisation (default: homebrew)." + end + end + + def pr_upload + pr_upload_args.parse + + bintray_org = args.bintray_org || "homebrew" + bintray = Bintray.new(org: bintray_org) + + if args.dry_run? + puts "brew bottle --merge --write #{Dir["*.json"].join " "}" + else + system HOMEBREW_BREW_FILE, "bottle", "--merge", "--write", *Dir["*.json"] + end + + if args.dry_run? + puts "Upload bottles described by these JSON files to Bintray:\n #{Dir["*.json"].join("\n ")}" + else + bintray.upload_bottle_json Dir["*.json"], publish_package: !args.no_publish? + end + end +end diff --git a/Library/Homebrew/test/dev-cmd/pr-upload_spec.rb b/Library/Homebrew/test/dev-cmd/pr-upload_spec.rb new file mode 100644 index 0000000000000..69a5f27c174a5 --- /dev/null +++ b/Library/Homebrew/test/dev-cmd/pr-upload_spec.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +require "cmd/shared_examples/args_parse" + +describe "Homebrew.pr_upload_args" do + it_behaves_like "parseable arguments" +end diff --git a/docs/Manpage.md b/docs/Manpage.md index 120e1cee7046a..c9d7aa6976b78 100644 --- a/docs/Manpage.md +++ b/docs/Manpage.md @@ -897,6 +897,17 @@ repository. * `--tap`: Target tap repository (default: homebrew/core). +### `pr-upload` [*`options`*] + +Apply the bottle commit and publish bottles to Bintray. + +* `--no-publish`: + Apply the bottle commit and upload the bottles, but don't publish them. +* `-n`, `--dry-run`: + Print what would be done rather than doing it. +* `--bintray-org`: + Upload to the specified Bintray organisation (default: homebrew). + ### `prof` *`command`* Run Homebrew with the Ruby profiler, e.g. `brew prof readall`. diff --git a/manpages/brew.1 b/manpages/brew.1 index 6a7878449c2c2..52d8c42136009 100644 --- a/manpages/brew.1 +++ b/manpages/brew.1 @@ -1163,6 +1163,21 @@ Upload to the specified Bintray organisation (default: homebrew)\. \fB\-\-tap\fR Target tap repository (default: homebrew/core)\. . +.SS "\fBpr\-upload\fR [\fIoptions\fR]" +Apply the bottle commit and publish bottles to Bintray\. +. +.TP +\fB\-\-no\-publish\fR +Apply the bottle commit and upload the bottles, but don\'t publish them\. +. +.TP +\fB\-n\fR, \fB\-\-dry\-run\fR +Print what would be done rather than doing it\. +. +.TP +\fB\-\-bintray\-org\fR +Upload to the specified Bintray organisation (default: homebrew)\. +. .SS "\fBprof\fR \fIcommand\fR" Run Homebrew with the Ruby profiler, e\.g\. \fBbrew prof readall\fR\. .