-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use gh
to automerge and cleanup branches on bump*
PRs.
#15784
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,6 +48,9 @@ def bump_formula_pr_args | |
description: "Print the pull request URL instead of opening in a browser." | ||
switch "--no-fork", | ||
description: "Don't try to fork the repository." | ||
switch "--automerge", | ||
env: :bump_automerge, | ||
description: "Open pull requests with automerge and branch cleanup enabled." | ||
Comment on lines
+51
to
+53
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure this works as-is yet, since There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @carlocab Oops, I've misunderstood the workflow. Does this make this PR basically pointless for homebrew/core (and/or homebrew/core)? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At the moment, it is pretty pointless for Homebrew/core. I can see this being useful if/when PRs are blocked from being queued to merge if they are still missing a bottle commit (and require one). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Homebrew/cask would this be useful for homebrew/cask? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cask has automation for this I believe There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, homebrew/cask* already auto-enables automerge for all maintainer-authored PRs labelled Example: Homebrew/homebrew-cask#152038 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cool, problem solved then, thanks all. |
||
comma_array "--mirror", | ||
description: "Use the specified <URL> as a mirror URL. If <URL> is a comma-separated list " \ | ||
"of URLs, multiple mirrors will be added." | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -682,17 +682,21 @@ | |
EOS | ||
end | ||
|
||
begin | ||
url = create_pull_request(tap_remote_repo, commit_message, | ||
"#{username}:#{branch}", remote_branch, pr_message)["html_url"] | ||
if args.no_browse? | ||
puts url | ||
else | ||
exec_browser url | ||
end | ||
url = begin | ||
create_pull_request(tap_remote_repo, commit_message, | ||
"#{username}:#{branch}", remote_branch, pr_message)["html_url"] | ||
rescue *API::ERRORS => e | ||
odie "Unable to open pull request: #{e.message}!" | ||
end | ||
|
||
# Attempt to enable automerge on the created PR if requested. | ||
GitHub::API.run_gh_cli(args: ["pr", "merge", "--auto", "--merge", "--delete-branch", url]) if args.automerge? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a reason we do this rather than call the API directly like we do everywhere else? This sounds like this would not work with Code using the GraphQL directly (untested but should work in theory if no typos): pr = create_pull_request(...)
url = pr["html_url"]
# ...
if args.automerge?
API.open_graphql(<<~EOS, variables: { pullRequestId: pr["node_id"] })
mutation($pullRequestId: ID!) {
enablePullRequestAutoMerge(input: {pullRequestId: $pullRequestId, mergeMethod: MERGE}) {
clientMutationId
}
}
EOS
end There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See also similar-ish code in Homebrew/core: https://github.com/Homebrew/homebrew-core/blob/f0c6e070add5312cb25639bcade628c21a6de2af/.github/workflows/publish-commit-bottles.yml#L211-L232 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Bo98 pretty much because:
If you don't consider this a hard blocker: would rather land this as-is to validate the idea/workflow and anyone who wants to can move to GraphQL later if that's desired. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This appears to be the first beyond token fetching? I'm not entirely convinced it'll work in Homebrew/core CI as is given how our tokens appear to be used over there (plus that additional issue Carlo pointed out), but have of course not tested it. Maybe Homebrew/core CI is a non-concern anyway judging by the original issue. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes.
Yes, may require extra wrangling for the bump job(s).
Indeed, this may be rescoped to cask only. |
||
|
||
if args.no_browse? | ||
puts url | ||
else | ||
exec_browser url | ||
end | ||
end | ||
end | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❓
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops, needs updated.