Allow users to reject their own watch/blacklist PRs (v2: Now with cleaner commit history!) #11549
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is #11285 but with a less messy commit history (and a small regex adjustment).
I'd have done rebase-foo on THAT PR instead, but my Git wizardry is... Novitiate. That's a word, right?
Implements feature request #8642
This PR allows users to reject/close (including
-force
) their own auto-created watch and blacklist PRs.This was tested in this chatroom (where I removed SD ignoring its own messages when considering them for commands and some other changes, the full diff of which is available here where I mistakenly committed them to this branch and had to remove them).
One small change I made was making the
payload
argument forget_pull_request
an optional arg with a blank string as its default. This change has no effect elsewhere in the project asget_pull_request
isn't used anywhere aside from in this PR's changes, and you don't need to supply a payload when performing a GET request for a PR anyway.I also took the liberty to remove the "so the user can learn from their mistakes" content from the required-rejection CmdException. I have a couple of reasons for this removal:
Known limitations:
This PR operates off of the chat messager's chat id, and so does submitting a watch PR. This can be different across chat servers, such as if a user submits a watch PR in SO chat and attempts to self-close it in Charcoal HQ. This will yield a
"You need blacklist manager privileges to reject pull requests that aren't created by you."
error.Given that 95% of all watch/blacklist PRs occur in Charcoal HQ, I consider this an acceptable limitation.