RFR: 1658: Minimize race window when updating PR body

Magnus Ihse Bursie ihse at openjdk.org
Tue Nov 8 23:22:23 UTC 2022


On Tue, 8 Nov 2022 21:43:02 GMT, Zhao Song <zsong at openjdk.org> wrote:

> Currently, when the pr bot tries to update the PR body, users are also likely to update the PR body at the same time. Therefore, users' updates are likely to be overwritten by bot.  
> 
> This is a race between the bot and user and the race window is a little big right now.
> 
> To reduce the race window, in this patch, when PR bot is trying to update PR body, it will check whether the PR body has been modified by user. And if the PR bot has been modified, PR bot would not overwrite it.

forge/src/test/java/org/openjdk/skara/forge/github/GitHubRestApiTests.java line 159:

> 157:         var testPr = testRepo.pullRequest("99");
> 158: 
> 159:         String latestBody = testPr.latestBody();

This looks a bit fragile, but maybe that's a price we have to pay for the manual tests.

However, I think you should also add an automatic test, that verifies that an updated body makes the bot skip the update that time around, but not otherwise. I think it will be possible to define such a setup without having to resort to race-prone logic.

-------------

PR: https://git.openjdk.org/skara/pull/1416


More information about the skara-dev mailing list