pr-{publish,pull}: autosquash by default

This allows dispatching the publish workflow via the GitHub UI to have
the exact same behaviour as doing `brew pr-publish`.

Closes Homebrew/homebrew-core#94704.
This commit is contained in:
Carlo Cabrera 2022-02-08 20:02:21 +08:00
parent 89ab131984
commit 6baf2aadb6
No known key found for this signature in database
GPG Key ID: C74D447FC549A1D0
2 changed files with 10 additions and 5 deletions

View File

@ -26,13 +26,14 @@ module Homebrew
flag "--branch=", flag "--branch=",
description: "Branch to publish to (default: `master`)." description: "Branch to publish to (default: `master`)."
flag "--message=", flag "--message=",
depends_on: "--autosquash",
description: "Message to include when autosquashing revision bumps, deletions, and rebuilds." description: "Message to include when autosquashing revision bumps, deletions, and rebuilds."
flag "--tap=", flag "--tap=",
description: "Target tap repository (default: `homebrew/core`)." description: "Target tap repository (default: `homebrew/core`)."
flag "--workflow=", flag "--workflow=",
description: "Target workflow filename (default: `publish-commit-bottles.yml`)." description: "Target workflow filename (default: `publish-commit-bottles.yml`)."
conflicts "--no-autosquash", "--message"
named_args :pull_request, min: 1 named_args :pull_request, min: 1
end end
end end
@ -45,7 +46,7 @@ module Homebrew
ref = args.branch || "master" ref = args.branch || "master"
extra_args = [] extra_args = []
extra_args << "--autosquash" unless args.no_autosquash? extra_args << "--no-autosquash" if args.no_autosquash?
extra_args << "--message='#{args.message}'" if args.message.presence extra_args << "--message='#{args.message}'" if args.message.presence
dispatch_args = extra_args.join " " dispatch_args = extra_args.join " "

View File

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