Port Homebrew::DevCmd::PrAutomerge
This commit is contained in:
parent
d15f99514c
commit
972e853ec0
@ -1,15 +1,14 @@
|
||||
# typed: true
|
||||
# typed: strict
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "abstract_command"
|
||||
require "cli/parser"
|
||||
require "utils/github"
|
||||
|
||||
module Homebrew
|
||||
module_function
|
||||
|
||||
sig { returns(CLI::Parser) }
|
||||
def pr_automerge_args
|
||||
Homebrew::CLI::Parser.new do
|
||||
module DevCmd
|
||||
class PrAutomerge < AbstractCommand
|
||||
cmd_args do
|
||||
description <<~EOS
|
||||
Find pull requests that can be automatically merged using `brew pr-publish`.
|
||||
EOS
|
||||
@ -40,11 +39,9 @@ module Homebrew
|
||||
|
||||
named_args :none
|
||||
end
|
||||
end
|
||||
|
||||
def pr_automerge
|
||||
args = pr_automerge_args.parse
|
||||
|
||||
sig { override.void }
|
||||
def run
|
||||
without_labels = args.without_labels || [
|
||||
"do not merge",
|
||||
"new formula",
|
||||
@ -58,7 +55,7 @@ module Homebrew
|
||||
query += args.ignore_failures? ? " -status:pending" : " status:success"
|
||||
query += " review:approved" unless args.without_approval?
|
||||
query += " label:\"#{args.with_label}\"" if args.with_label
|
||||
without_labels&.each { |label| query += " -label:\"#{label}\"" }
|
||||
without_labels.each { |label| query += " -label:\"#{label}\"" }
|
||||
odebug "Searching: #{query}"
|
||||
|
||||
prs = GitHub.search_issues query
|
||||
@ -85,3 +82,5 @@ module Homebrew
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
require "dev-cmd/pr-automerge"
|
||||
|
||||
RSpec.describe "brew pr-automerge" do
|
||||
RSpec.describe Homebrew::DevCmd::PrAutomerge do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user