Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade the notifier database lazily #657

wants to merge 2 commits into from
Changes from all commits
File filter

Filter by extension

Filter by extension

Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -82,14 +82,7 @@ private Set<PullRequestState> 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) {
} else {
obj.put("commit", hash.hex());

var commit = obj.get("commit").isNull() ?
@@ -116,11 +109,16 @@ private String serializePrState(Collection<PullRequestState> added, Set<PullRequ
var commit = pr.commitId().isPresent()?
JSON.of(pr.commitId().get().hex()) : JSON.of();
return JSON.object().put("pr", pr.prId())
.put("commit", commit);
var ret = JSON.object().put("pr", pr.prId())
if (pr.commitId().isPresent()) {
if (!pr.commitId().get().equals( {
ret.put("commit", JSON.of(pr.commitId().get().hex()));
} else {
return ret;
@@ -193,6 +191,13 @@ public Collection<WorkItem> run(Path scratchPath) {
var storedState =
.filter(ss -> ss.prId().equals(state.prId()))
// The stored entry could be old and be missing commit information - if so, upgrade it
if (storedState.isPresent() && storedState.get().commitId().equals(Optional.of( {
var hash = resultingCommitHashFor(pr);
storedState = Optional.of(new PullRequestState(pr, storedState.get().issueIds(), hash));

if (storedState.isPresent()) {
var storedIssues = storedState.get().issueIds();