spr icon indicating copy to clipboard operation
spr copied to clipboard

Cleanup without land (similar to close?)

Open MarcCelani-at opened this issue 3 years ago • 4 comments

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.

MarcCelani-at avatar Oct 13 '22 02:10 MarcCelani-at

I feel like close should be able to handle this.

rockwotj avatar Oct 20 '22 14:10 rockwotj

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)

MarcCelani-at avatar Oct 20 '22 14:10 MarcCelani-at

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 avatar Oct 20 '22 19:10 rockwotj

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

rockwotj avatar Oct 20 '22 19:10 rockwotj