spacedentist / spr

Submit pull requests for individual, amendable, rebaseable commits to GitHub
https://getcord.github.io/spr/
MIT License
377 stars 33 forks source link

Cleanup without land (similar to close?) #146

Open MarcCelani-at opened 1 year ago

MarcCelani-at commented 1 year ago

Our repo uses a merge queue to squash and merge all PRs into main and release branches. The way that it is implemented is that after a PR passes all checks and gets code reviewed, a PR author can apply a label to their PR that instructs a github action to merge it into main. This github action will maintain a queue of PRs that want to be merged, and they all need to re-run CI against tip of main before the merge happens. This is to prevent two PRs that don't play nice together from landing and breaking main.

The problem with this approach is that we do not have a way to cleanup the branches that spr creates. I'm not sure if this is something spr land automatically does or not, but we can't run spr land since only the merge queue (and those with special privileges) can merge directly to main.

This would probably be similar to spr close, except the PR is already going to be squashed and merged at this point. I haven't tested using spr close on an already merged PR because I don't know what it will do.

rockwotj commented 1 year ago

I feel like close should be able to handle this.

MarcCelani-at commented 1 year ago

Sorry, I'm a little confused by your comment. Do you mean "as is" or with some kind of special flag, "--cleanupBranchesIfAlreadyClosed"? Because spr close tries to actually close the PR, and if it is already merged, it will fail without cleaning up any branches (this is relevant for stacked PRs)

rockwotj commented 1 year ago

Sorry, to clarify - I think that if you invoke spr close and the PR is closed, but the branches exist they should be deleted. No special flags needed. I agree that it doesn't do that today, but it should.

rockwotj commented 1 year ago

Essentially, this should not return an error but skip over closing the PR on GitHub.