From 77a1bc22d7778c3be39658b4cbe4a6f9d8c57d5d Mon Sep 17 00:00:00 2001 From: Dawid Dziurla Date: Thu, 2 Jul 2020 22:47:45 +0200 Subject: [PATCH 1/4] dev-cmd/pr-*: allow to run on other taps too --- Library/Homebrew/dev-cmd/pr-automerge.rb | 3 +-- Library/Homebrew/dev-cmd/pr-publish.rb | 9 +++++---- docs/Manpage.md | 5 ++++- manpages/brew.1 | 6 +++++- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/Library/Homebrew/dev-cmd/pr-automerge.rb b/Library/Homebrew/dev-cmd/pr-automerge.rb index c7aadd8ea1..047a94c503 100644 --- a/Library/Homebrew/dev-cmd/pr-automerge.rb +++ b/Library/Homebrew/dev-cmd/pr-automerge.rb @@ -34,7 +34,6 @@ module Homebrew def pr_automerge pr_automerge_args.parse - ENV["HOMEBREW_FORCE_HOMEBREW_ON_LINUX"] = "1" unless OS.mac? without_labels = Homebrew.args.without_labels || ["do not merge", "new formula"] tap = Tap.fetch(Homebrew.args.tap || CoreTap.instance.name) @@ -59,7 +58,7 @@ module Homebrew end if args.publish? - safe_system "#{HOMEBREW_PREFIX}/bin/brew", "pr-publish", *pr_urls + safe_system HOMEBREW_BREW_FILE, "pr-publish", *pr_urls else ohai "Now run:", " brew pr-publish \\\n #{pr_urls.join " \\\n "}" end diff --git a/Library/Homebrew/dev-cmd/pr-publish.rb b/Library/Homebrew/dev-cmd/pr-publish.rb index d45ab8c185..899e2dee64 100644 --- a/Library/Homebrew/dev-cmd/pr-publish.rb +++ b/Library/Homebrew/dev-cmd/pr-publish.rb @@ -12,8 +12,10 @@ module Homebrew `pr-publish` [] [ ...] Publish bottles for a pull request with GitHub Actions. - Requires write access to the `homebrew/core` repository. + Requires write access to the repository. EOS + flag "--tap=", + description: "Target tap repository (default: `homebrew/core`)." switch :verbose min_named 1 end @@ -22,14 +24,13 @@ module Homebrew def pr_publish pr_publish_args.parse - ENV["HOMEBREW_FORCE_HOMEBREW_ON_LINUX"] = "1" unless OS.mac? + tap = Tap.fetch(Homebrew.args.tap || CoreTap.instance.name) args.named.uniq.each do |arg| - arg = "#{CoreTap.instance.default_remote}/pull/#{arg}" if arg.to_i.positive? + arg = "#{tap.default_remote}/pull/#{arg}" if arg.to_i.positive? url_match = arg.match HOMEBREW_PULL_OR_COMMIT_URL_REGEX _, user, repo, issue = *url_match odie "Not a GitHub pull request: #{arg}" unless issue - tap = Tap.fetch(user, repo) if repo.match?(HOMEBREW_OFFICIAL_REPO_PREFIXES_REGEX) ohai "Dispatching #{tap} pull request ##{issue}" GitHub.dispatch_event(user, repo, "Publish ##{issue}", pull_request: issue) end diff --git a/docs/Manpage.md b/docs/Manpage.md index 2709a17839..56c9b936af 100644 --- a/docs/Manpage.md +++ b/docs/Manpage.md @@ -883,7 +883,10 @@ Find pull requests that can be automatically merged using `brew pr-publish`. ### `pr-publish` [*`options`*] *`pull_request`* [*`pull_request`* ...] Publish bottles for a pull request with GitHub Actions. Requires write access to -the `homebrew/core` repository. +the repository. + +* `--tap`: + Target tap repository (default: `homebrew/core`). ### `pr-pull` [*`options`*] *`pull_request`* [*`pull_request`* ...] diff --git a/manpages/brew.1 b/manpages/brew.1 index a653c4df12..b56adc35ce 100644 --- a/manpages/brew.1 +++ b/manpages/brew.1 @@ -1146,7 +1146,11 @@ Run \fBbrew pr\-publish\fR on matching pull requests\. Include pull requests that have failing status checks\. . .SS "\fBpr\-publish\fR [\fIoptions\fR] \fIpull_request\fR [\fIpull_request\fR \.\.\.]" -Publish bottles for a pull request with GitHub Actions\. Requires write access to the \fBhomebrew/core\fR repository\. +Publish bottles for a pull request with GitHub Actions\. Requires write access to the repository\. +. +.TP +\fB\-\-tap\fR +Target tap repository (default: \fBhomebrew/core\fR)\. . .SS "\fBpr\-pull\fR [\fIoptions\fR] \fIpull_request\fR [\fIpull_request\fR \.\.\.]" Download and publish bottles, and apply the bottle commit from a pull request with artifacts generated by GitHub Actions\. Requires write access to the repository\. From 8be563c5cd3194f5db740a1fbd4504d56e471ee3 Mon Sep 17 00:00:00 2001 From: Dawid Dziurla Date: Fri, 24 Jul 2020 18:48:28 +0200 Subject: [PATCH 2/4] pr-automerge: pass --tap arg down --- Library/Homebrew/dev-cmd/pr-automerge.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/dev-cmd/pr-automerge.rb b/Library/Homebrew/dev-cmd/pr-automerge.rb index 047a94c503..04582ed5ab 100644 --- a/Library/Homebrew/dev-cmd/pr-automerge.rb +++ b/Library/Homebrew/dev-cmd/pr-automerge.rb @@ -58,7 +58,9 @@ module Homebrew end if args.publish? - safe_system HOMEBREW_BREW_FILE, "pr-publish", *pr_urls + publish_args = ["pr-publish"] + publish_args << "--tap=#{args.tap}" if args.tap + safe_system HOMEBREW_BREW_FILE, *publish_args, *pr_urls else ohai "Now run:", " brew pr-publish \\\n #{pr_urls.join " \\\n "}" end From 62ca046390ef3da606c50db4a27d79455f23aacf Mon Sep 17 00:00:00 2001 From: Dawid Dziurla Date: Sat, 25 Jul 2020 08:42:39 +0200 Subject: [PATCH 3/4] pr-automerge: pass proper tap variable Co-authored-by: Jonathan Chang --- Library/Homebrew/dev-cmd/pr-automerge.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/dev-cmd/pr-automerge.rb b/Library/Homebrew/dev-cmd/pr-automerge.rb index 04582ed5ab..e0d4cd63cb 100644 --- a/Library/Homebrew/dev-cmd/pr-automerge.rb +++ b/Library/Homebrew/dev-cmd/pr-automerge.rb @@ -59,7 +59,7 @@ module Homebrew if args.publish? publish_args = ["pr-publish"] - publish_args << "--tap=#{args.tap}" if args.tap + publish_args << "--tap=#{tap}" if tap safe_system HOMEBREW_BREW_FILE, *publish_args, *pr_urls else ohai "Now run:", " brew pr-publish \\\n #{pr_urls.join " \\\n "}" From a0bf5c9ead85a6362f23524ce900ab5415410f36 Mon Sep 17 00:00:00 2001 From: Dawid Dziurla Date: Mon, 27 Jul 2020 12:29:08 +0200 Subject: [PATCH 4/4] pr-publish: check if url repo equals provided tap arg Co-authored-by: Jonathan Chang --- Library/Homebrew/dev-cmd/pr-publish.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Library/Homebrew/dev-cmd/pr-publish.rb b/Library/Homebrew/dev-cmd/pr-publish.rb index 899e2dee64..54b4a28c2e 100644 --- a/Library/Homebrew/dev-cmd/pr-publish.rb +++ b/Library/Homebrew/dev-cmd/pr-publish.rb @@ -31,6 +31,10 @@ module Homebrew url_match = arg.match HOMEBREW_PULL_OR_COMMIT_URL_REGEX _, user, repo, issue = *url_match odie "Not a GitHub pull request: #{arg}" unless issue + if args.tap.present? && !"#{user}/#{repo}".casecmp(tap.full_name).zero? + odie "Pull request URL is for #{user}/#{repo} but --tap=#{tap.full_name}!" + end + ohai "Dispatching #{tap} pull request ##{issue}" GitHub.dispatch_event(user, repo, "Publish ##{issue}", pull_request: issue) end