From f0272b0944b7cbb19032e2de8a85900ef476ba23 Mon Sep 17 00:00:00 2001 From: Carlo Cabrera <30379873+carlocab@users.noreply.github.com> Date: Tue, 28 Mar 2023 21:59:53 +0800 Subject: [PATCH] dev-cmd/pr-pu{ll,blish}: handle PRs with an autosquash label - request `autosquash` from the publish job in `pr-publish` if the PR is labelled with `autosquash` - show a warning in `pr-pull` if called without `--autosquash` on a PR with the autosquash label. --- Library/Homebrew/dev-cmd/pr-publish.rb | 4 ++++ Library/Homebrew/dev-cmd/pr-pull.rb | 11 +++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Library/Homebrew/dev-cmd/pr-publish.rb b/Library/Homebrew/dev-cmd/pr-publish.rb index 3204476dbc..699c83cdee 100644 --- a/Library/Homebrew/dev-cmd/pr-publish.rb +++ b/Library/Homebrew/dev-cmd/pr-publish.rb @@ -67,6 +67,10 @@ module Homebrew inputs[:pull_request] = issue + pr_labels = GitHub.pull_request_labels(user, repo, issue) + oh1 "Found `autosquash` label on ##{issue}. Requesting autosquash." + inputs[:autosquash] = true if pr_labels.include?("autosquash") + 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 diff --git a/Library/Homebrew/dev-cmd/pr-pull.rb b/Library/Homebrew/dev-cmd/pr-pull.rb index 4810633397..aa91edf6d0 100644 --- a/Library/Homebrew/dev-cmd/pr-pull.rb +++ b/Library/Homebrew/dev-cmd/pr-pull.rb @@ -308,11 +308,9 @@ module Homebrew Utils::Git.cherry_pick!(path, "--ff", "--allow-empty", *commits, verbose: args.verbose?, resolve: args.resolve?) end - def self.formulae_need_bottles?(tap, original_commit, user, repo, pull_request, args:) + def self.formulae_need_bottles?(tap, original_commit, labels, args:) return if args.dry_run? - labels = GitHub.pull_request_labels(user, repo, pull_request) - return false if labels.include?("CI-syntax-only") || labels.include?("CI-no-bottles") changed_packages(tap, original_commit).any? do |f| @@ -456,6 +454,11 @@ module Homebrew opoo "Current branch is #{tap.path.git_branch}: do you need to pull inside #{tap.path.git_origin_branch}?" end + pr_labels = GitHub.pull_request_labels(user, repo, pr) + if pr_labels.include?("autosquash") && !args.autosquash? + opoo "Pull request is labelled `autosquash`: do you need to pass `--autosquash`?" + end + pr_check_conflicts("#{user}/#{repo}", pr) ohai "Fetching #{tap} pull request ##{pr}" @@ -478,7 +481,7 @@ module Homebrew signoff!(tap.path, pull_request: pr, dry_run: args.dry_run?) unless args.clean? end - unless formulae_need_bottles?(tap, original_commit, user, repo, pr, args: args) + unless formulae_need_bottles?(tap, original_commit, pr_labels, args: args) ohai "Skipping artifacts for ##{pr} as the formulae don't need bottles" next end