dev-cmd/pr-*: replace --no-autosquash with --autosquash

We will now no longer be squashing commits by default, so it makes sense
to default to doing nothing but still autosquash commits when requested
with `--autosquash`.
This commit is contained in:
Carlo Cabrera 2023-03-28 21:51:01 +08:00
parent b753315b0b
commit 834e4c98fc
No known key found for this signature in database
GPG Key ID: C74D447FC549A1D0
3 changed files with 28 additions and 9 deletions

View File

@ -28,9 +28,13 @@ module Homebrew
description: "Pull requests do not require approval to be merged."
switch "--publish",
description: "Run `brew pr-publish` on matching pull requests."
switch "--autosquash",
description: "Instruct `brew pr-publish` to automatically reformat and reword commits " \
"in the pull request to the preferred format."
switch "--no-autosquash",
description: "Instruct `brew pr-publish` to skip automatically reformatting and rewording commits " \
"in the pull request to the preferred format."
"in the pull request to the preferred format.",
replacement: "`--autosquash` to opt in"
switch "--ignore-failures",
description: "Include pull requests that have failing status checks."
@ -41,6 +45,8 @@ module Homebrew
def pr_automerge
args = pr_automerge_args.parse
odeprecated "`brew pr-publish --no-autosquash`" if args.no_autosquash?
without_labels = args.without_labels || [
"do not merge",
"new formula",
@ -71,7 +77,7 @@ module Homebrew
publish_args = ["pr-publish"]
publish_args << "--tap=#{tap}" if tap
publish_args << "--workflow=#{args.workflow}" if args.workflow
publish_args << "--no-autosquash" if args.no_autosquash?
publish_args << "--autosquash" if args.autosquash?
if args.publish?
safe_system HOMEBREW_BREW_FILE, *publish_args, *pr_urls
else

View File

@ -16,19 +16,24 @@ module Homebrew
Publish bottles for a pull request with GitHub Actions.
Requires write access to the repository.
EOS
switch "--autosquash",
description: "If supported on the target tap, automatically reformat and reword commits " \
"to our preferred format."
switch "--no-autosquash",
description: "Skip automatically reformatting and rewording commits in the pull request " \
"to the preferred format, even if supported on the target tap."
"to the preferred format, even if supported on the target tap.",
replacement: "`--autosquash` to opt in"
flag "--branch=",
description: "Branch to publish to (default: `master`)."
flag "--message=",
depends_on: "--autosquash",
description: "Message to include when autosquashing revision bumps, deletions, and rebuilds."
flag "--tap=",
description: "Target tap repository (default: `homebrew/core`)."
flag "--workflow=",
description: "Target workflow filename (default: `publish-commit-bottles.yml`)."
conflicts "--no-autosquash", "--message"
conflicts "--clean", "--autosquash"
named_args :pull_request, min: 1
end
@ -37,12 +42,14 @@ module Homebrew
def pr_publish
args = pr_publish_args.parse
odeprecated "`brew pr-publish --no-autosquash`" if args.no_autosquash?
tap = Tap.fetch(args.tap || CoreTap.instance.name)
workflow = args.workflow || "publish-commit-bottles.yml"
ref = args.branch || "master"
extra_args = []
extra_args << "--no-autosquash" if args.no_autosquash?
extra_args << "--autosquash" if args.autosquash?
extra_args << "--message='#{args.message}'" if args.message.presence
dispatch_args = extra_args.join " "

View File

@ -27,14 +27,17 @@ module Homebrew
switch "-n", "--dry-run",
description: "Print what would be done rather than doing it."
switch "--clean",
depends_on: "--no-autosquash",
description: "Do not amend the commits from pull requests."
switch "--keep-old",
description: "If the formula specifies a rebuild version, " \
"attempt to preserve its value in the generated DSL."
switch "--autosquash",
description: "Automatically reformat and reword commits in the pull request to our " \
"preferred format."
switch "--no-autosquash",
description: "Skip automatically reformatting and rewording commits in the pull request to our " \
"preferred format."
"preferred format.",
replacement: "`--autosquash` to opt in"
switch "--branch-okay",
description: "Do not warn if pulling to a branch besides the repository default (useful for testing)."
switch "--resolve",
@ -46,6 +49,7 @@ module Homebrew
flag "--committer=",
description: "Specify a committer name and email in `git`'s standard author format."
flag "--message=",
depends_on: "--autosquash",
description: "Message to include when autosquashing revision bumps, deletions, and rebuilds."
flag "--artifact=",
description: "Download artifacts with the specified name (default: `bottles`)."
@ -62,7 +66,7 @@ module Homebrew
comma_array "--ignore-missing-artifacts",
description: "Comma-separated list of workflows which can be ignored if they have not been run."
conflicts "--no-autosquash", "--message"
conflicts "--clean", "--autosquash"
named_args :pull_request, min: 1
end
@ -424,6 +428,8 @@ module Homebrew
def self.pr_pull
args = pr_pull_args.parse
odeprecated "`brew pr-pull --no-autosquash`" if args.no_autosquash?
# Needed when extracting the CI artifact.
ensure_executable!("unzip", reason: "extracting CI artifacts")
@ -465,7 +471,7 @@ module Homebrew
unless args.no_commit?
cherry_pick_pr!(user, repo, pr, path: tap.path, args: args) unless args.no_cherry_pick?
if !args.no_autosquash? && !args.dry_run?
if args.autosquash? && !args.dry_run?
autosquash!(original_commit, tap: tap,
verbose: args.verbose?, resolve: args.resolve?, reason: args.message)
end