Optionally limit the number of PRs created in each submission#824
Optionally limit the number of PRs created in each submission#824rejc2 wants to merge 2 commits intofacebook:mainfrom
Conversation
Currently, when submitting a PR in Sapling, it's easy to accidentally create multiple PRs when only one was intended (e.g. forgetting to run `sl pr follow`, or editing a PR that is based off a different branch). With this change, you can configure Sapling to limit the number of PRs that can be created in a single submit action, e.g. to just 1: ``` sl config --user github.max-prs-to-create=1 ``` Now when attempting to create multiple PRs in a single `sl pr submit` action, Sapling will fail with: ``` abort: refused to create 2 pull requests, max is 1 ```
|
@facebook-github-bot has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
vegerot
left a comment
There was a problem hiding this comment.
As a follow up to this commit, I'd suggest adding a default limit of maybe 10, and update the error message to instruct users how to override it.
| _("refused to create %d pull requests, max is %d") | ||
| % (len(params.pull_requests_to_create), max_pull_requests_to_create) |
There was a problem hiding this comment.
nit:
| _("refused to create %d pull requests, max is %d") | |
| % (len(params.pull_requests_to_create), max_pull_requests_to_create) | |
| _("refused to create %d pull requests, max is %d\nif you want to open %d pull requests, run again with `--config github.max-prs-to-create=-1") | |
| % (len(params.pull_requests_to_create), max_pull_requests_to_create, len(params.pull_requests_to_create) ) | |
There was a problem hiding this comment.
Thanks for the suggestion!
I've updated the PR, and (following our discussion on Discord) set the default value to 5.
Still open to further feedback of course.
Also update error message to explain how to create more than 5 PRs in one command.
|
@rejc2 has updated the pull request. You must reimport the pull request before landing. |
|
@facebook-github-bot has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
|
This pull request has been merged in e62f3e8. |
Optionally limit the number of PRs created in each submission
Currently, when submitting a PR in Sapling, it's easy to accidentally create multiple PRs when only one was intended (e.g. forgetting to run
sl pr follow, or editing a PR that is based off a different branch).With this change, you can configure Sapling to limit the number of PRs that can be created in a single submit action, e.g. to just 1:
Now when attempting to create multiple PRs in a single
sl pr submitaction, Sapling will fail with:(Note that this setting doesn't limit the size of a PR stack: a larger PR stack can be made by submitting each new PR separately. Re-submitting the top PR will still update the entire stack below it, no matter the size.)
Based on feedback and discussion, I've set the default for
github.max-prs-to-createto be 5.