Class: Homebrew::DevCmd::PrPublish

Inherits:
AbstractCommand show all
Defined in:
dev-cmd/pr-publish.rb

Instance Attribute Summary

Attributes inherited from AbstractCommand

#args

Instance Method Summary collapse

Methods inherited from AbstractCommand

command, command_name, #initialize, parser

Constructor Details

This class inherits a constructor from Homebrew::AbstractCommand

Instance Method Details

#runvoid

This method returns an undefined value.



34
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
# File 'dev-cmd/pr-publish.rb', line 34

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