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
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require "abstract_command"
|
||||||
require "cli/parser"
|
require "cli/parser"
|
||||||
require "utils/github"
|
require "utils/github"
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
module_function
|
module DevCmd
|
||||||
|
class PrAutomerge < AbstractCommand
|
||||||
sig { returns(CLI::Parser) }
|
cmd_args do
|
||||||
def pr_automerge_args
|
|
||||||
Homebrew::CLI::Parser.new do
|
|
||||||
description <<~EOS
|
description <<~EOS
|
||||||
Find pull requests that can be automatically merged using `brew pr-publish`.
|
Find pull requests that can be automatically merged using `brew pr-publish`.
|
||||||
EOS
|
EOS
|
||||||
@ -40,11 +39,9 @@ module Homebrew
|
|||||||
|
|
||||||
named_args :none
|
named_args :none
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def pr_automerge
|
|
||||||
args = pr_automerge_args.parse
|
|
||||||
|
|
||||||
|
sig { override.void }
|
||||||
|
def run
|
||||||
without_labels = args.without_labels || [
|
without_labels = args.without_labels || [
|
||||||
"do not merge",
|
"do not merge",
|
||||||
"new formula",
|
"new formula",
|
||||||
@ -58,7 +55,7 @@ module Homebrew
|
|||||||
query += args.ignore_failures? ? " -status:pending" : " status:success"
|
query += args.ignore_failures? ? " -status:pending" : " status:success"
|
||||||
query += " review:approved" unless args.without_approval?
|
query += " review:approved" unless args.without_approval?
|
||||||
query += " label:\"#{args.with_label}\"" if args.with_label
|
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}"
|
odebug "Searching: #{query}"
|
||||||
|
|
||||||
prs = GitHub.search_issues query
|
prs = GitHub.search_issues query
|
||||||
@ -84,4 +81,6 @@ module Homebrew
|
|||||||
ohai "Now run:", " brew #{publish_args.join " "} \\\n #{pr_urls.join " \\\n "}"
|
ohai "Now run:", " brew #{publish_args.join " "} \\\n #{pr_urls.join " \\\n "}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "cmd/shared_examples/args_parse"
|
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"
|
it_behaves_like "parseable arguments"
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user