Class: Homebrew::DevCmd::PrPublish Private

Inherits:
AbstractCommand show all
Defined in:
dev-cmd/pr-publish.rb,
sorbet/rbi/dsl/homebrew/dev_cmd/pr_publish.rbi

This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.

Defined Under Namespace

Classes: Args

Instance Method Summary collapse

Methods inherited from AbstractCommand

command, command_name, dev_cmd?, #initialize, parser, ruby_cmd?

Constructor Details

This class inherits a constructor from Homebrew::AbstractCommand

Instance Method Details

#argsHomebrew::DevCmd::PrPublish::Args

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.



10
# File 'sorbet/rbi/dsl/homebrew/dev_cmd/pr_publish.rbi', line 10

def args; end

#runvoid

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

This method returns an undefined value.



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'dev-cmd/pr-publish.rb', line 35

def run
  tap = Tap.fetch(args.tap || CoreTap.instance.name)
  workflow = args.workflow || "publish-commit-bottles.yml"
  ref = args.branch || "master"

  inputs = {
    autosquash:   args.autosquash?,
    large_runner: args.large_runner?,
  }
  inputs[:message] = args.message if args.message.presence

  args.named.uniq.each do |arg|
    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

    inputs[:pull_request] = issue

    pr_labels = GitHub.pull_request_labels(user, repo, issue)
    if pr_labels.include?("autosquash")
      oh1 "Found `autosquash` label on ##{issue}. Requesting autosquash."
      inputs[:autosquash] = true
    end
    if pr_labels.include?("large-bottle-upload")
      oh1 "Found `large-bottle-upload` label on ##{issue}. Requesting upload on large runner."
      inputs[:large_runner] = true
    end

    if args.tap.present? && !T.must("#{user}/#{repo}".casecmp(tap.full_name)).zero?
      odie "Pull request URL is for #{user}/#{repo} but `--tap=#{tap.full_name}` was specified!"
    end

    ohai "Dispatching #{tap} pull request ##{issue}"
    GitHub.workflow_dispatch_event(user, repo, workflow, ref, **inputs)
  end
end