diff --git a/bots/notify/src/main/java/org/openjdk/skara/bots/notify/PullRequestWorkItem.java b/bots/notify/src/main/java/org/openjdk/skara/bots/notify/PullRequestWorkItem.java index 2897720f1..98747930c 100644 --- a/bots/notify/src/main/java/org/openjdk/skara/bots/notify/PullRequestWorkItem.java +++ b/bots/notify/src/main/java/org/openjdk/skara/bots/notify/PullRequestWorkItem.java @@ -82,14 +82,7 @@ private Set deserializePrState(String current) { // Storage might be missing commit information if (!obj.contains("commit")) { - var prId = id.split(":")[1]; - var currentPR = pr.repository().pullRequest(prId); - var hash = resultingCommitHashFor(currentPR); - if (hash == null) { - obj.putNull("commit"); - } else { - obj.put("commit", hash.hex()); - } + obj.put("commit", Hash.zero().hex()); } var commit = obj.get("commit").isNull() ? @@ -116,11 +109,16 @@ private String serializePrState(Collection added, Set run(Path scratchPath) { var storedState = stored.stream() .filter(ss -> ss.prId().equals(state.prId())) .findAny(); + // The stored entry could be old and be missing commit information - if so, upgrade it + if (storedState.isPresent() && storedState.get().commitId().equals(Optional.of(Hash.zero()))) { + var hash = resultingCommitHashFor(pr); + storedState = Optional.of(new PullRequestState(pr, storedState.get().issueIds(), hash)); + storage.put(storedState.get()); + } + if (storedState.isPresent()) { var storedIssues = storedState.get().issueIds(); storedIssues.stream()