RFR: 1188: The pr/NNNN branches are not always deleted when a PR is closed
Guoxiong Li
gli at openjdk.java.net
Mon Nov 22 04:41:40 UTC 2021
On Sun, 21 Nov 2021 14:56:30 GMT, Guoxiong Li <gli at openjdk.org> wrote:
> Hi all,
>
> When a PR is ready for reviewing, the label `rfr` will be added and skara will create the branch `pr/NNNN` for it.
> If we convert the PR back to draft, the label `rfr` would be removed and the branch `pr/NNNN` won't be deleted.
> Then we close the PR, **the bot won't deleted the branch**.
>
> The reason is that the following code checks the label `rfr` or `integrated` to decide whether the bot should remove the branch.
>
>
> private boolean isOfInterest(PullRequest pr) {
> var labels = new HashSet<>(pr.labelNames());
> if (!(labels.contains("rfr") || labels.contains("integrated"))) {
> log.fine("PR is not yet ready - needs either 'rfr' or 'integrated' label");
> return false;
> }
> // ignore......
> }
>
>
> To solve this issue, this patch adds one situation about the branch existing or not. And the corresponding test is added.
>
> Thanks for taking the time to review.
>
> Best Regards,
> -- Guoxiong
The newly added test case also tests this situation. Please see the following code taken from the test case.
// Reopen the PR
pr.setState(Issue.State.OPEN);
TestBotRunner.runPeriodicItems(notifyBot);
// The target repo should not contain the branch, because the pr doesn't have label `rfr`.
assertThrows(IOException.class, () -> localRepo.fetch(repo.url(), PreIntegrations.preIntegrateBranch(pr)));
// add label `rfr`
pr.addLabel("rfr");
TestBotRunner.runPeriodicItems(notifyBot);
// The branch should have reappeared
hash = localRepo.fetch(repo.url(), PreIntegrations.preIntegrateBranch(pr));
assertEquals(editHash, hash);
-------------
PR: https://git.openjdk.java.net/skara/pull/1242
More information about the skara-dev
mailing list