From c939a1bfe92965b67cdd6c25b85819770415b715 Mon Sep 17 00:00:00 2001 From: Robin Westberg Date: Fri, 12 Jun 2020 10:47:08 +0200 Subject: [PATCH] Updated schema migration logic --- .../skara/bots/notify/PullRequestWorkItem.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) 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 b5f0e2fbc..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 @@ -191,13 +191,14 @@ public Collection run(Path scratchPath) { var storedState = stored.stream() .filter(ss -> ss.prId().equals(state.prId())) .findAny(); - if (storedState.isPresent()) { - // The stored entry could be old and be missing commit information - if so, upgrade it - if (storedState.get().commitId().isPresent() && storedState.get().commitId().get().equals(Hash.zero())) { - var hash = resultingCommitHashFor(pr); - storedState = Optional.of(new PullRequestState(pr, issues, hash)); - } + // 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() .filter(issue -> !issues.contains(issue))