Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pr-automerge: match only approved PRs by default #7512

Merged
merged 1 commit into from May 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 7 additions & 4 deletions Library/Homebrew/dev-cmd/pr-automerge.rb
Expand Up @@ -16,9 +16,11 @@ def pr_automerge_args
flag "--tap=",
description: "Target tap repository (default: `homebrew/core`)."
flag "--with-label=",
description: "Pull requests must have this label (default: `ready to merge`)."
description: "Pull requests must have this label."
comma_array "--without-labels=",
description: "Pull requests must not have these labels (default: `do not merge`, `new formula`)."
switch "--without-approval",
description: "Pull requests do not require approval to be merged."
switch "--publish",
description: "Run `brew pr-publish` on matching pull requests."
switch "--ignore-failures",
Expand All @@ -33,12 +35,13 @@ def pr_automerge
pr_automerge_args.parse

ENV["HOMEBREW_FORCE_HOMEBREW_ON_LINUX"] = "1" unless OS.mac?
with_label = Homebrew.args.with_label || "ready to merge"
without_labels = Homebrew.args.without_labels || ["do not merge", "new formula"]
tap = Tap.fetch(Homebrew.args.tap || CoreTap.instance.name)

query = "is:pr is:open repo:#{tap.full_name} label:\"#{with_label}\""
query += args.ignore_failures? ? " -status:pending" : " status:success"
query = "is:pr is:open repo:#{tap.full_name}"
query += Homebrew.args.ignore_failures? ? " -status:pending" : " status:success"
query += " review:approved" unless Homebrew.args.without_approval?
query += " label:\"#{with_label}\"" if Homebrew.args.with_label
without_labels&.each { |label| query += " -label:\"#{label}\"" }
odebug "Searching: #{query}"

Expand Down
4 changes: 3 additions & 1 deletion docs/Manpage.md
Expand Up @@ -858,9 +858,11 @@ Find pull requests that can be automatically merged using `brew pr-publish`.
* `--tap`:
Target tap repository (default: `homebrew/core`).
* `--with-label`:
Pull requests must have this label (default: `ready to merge`).
Pull requests must have this label.
* `--without-labels`:
Pull requests must not have these labels (default: `do not merge`, `new formula`).
* `--without-approval`:
Pull requests do not require approval to be merged.
* `--publish`:
Run `brew pr-publish` on matching pull requests.
* `--ignore-failures`:
Expand Down
2 changes: 1 addition & 1 deletion manpages/brew-cask.1
@@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
.TH "BREW\-CASK" "1" "April 2020" "Homebrew" "brew-cask"
.TH "BREW\-CASK" "1" "May 2020" "Homebrew" "brew-cask"
.
.SH "NAME"
\fBbrew\-cask\fR \- a friendly binary installer for macOS
Expand Down
8 changes: 6 additions & 2 deletions manpages/brew.1
@@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
.TH "BREW" "1" "April 2020" "Homebrew" "brew"
.TH "BREW" "1" "May 2020" "Homebrew" "brew"
.
.SH "NAME"
\fBbrew\fR \- The Missing Package Manager for macOS
Expand Down Expand Up @@ -1103,13 +1103,17 @@ Target tap repository (default: \fBhomebrew/core\fR)\.
.
.TP
\fB\-\-with\-label\fR
Pull requests must have this label (default: \fBready to merge\fR)\.
Pull requests must have this label\.
.
.TP
\fB\-\-without\-labels\fR
Pull requests must not have these labels (default: \fBdo not merge\fR, \fBnew formula\fR)\.
.
.TP
\fB\-\-without\-approval\fR
Pull requests do not require approval to be merged\.
.
.TP
\fB\-\-publish\fR
Run \fBbrew pr\-publish\fR on matching pull requests\.
.
Expand Down