Do not try to create review notes for ref deletion events
The reviewnotes plugin already handles an all-zeroes oldObjectId by
not including a negative commit for it in the revwalk. An all-zeroes
newObjectId represents a ref deletion, which represents no new history
so the revwalk can be skipped altogether.
Noticed by reading logs.
Missing unknown 0000000000000000000000000000000000000000
org.eclipse.jgit.errors.MissingObjectException: Missing unknown 0000000000000000000000000000000000000000
at org.eclipse.jgit.internal.storage.dfs.DfsReader.open(DfsReader.java:219)
at org.eclipse.jgit.lib.ObjectReader.open(ObjectReader.java:229)
at org.eclipse.jgit.revwalk.RevWalk.parseAny(RevWalk.java:809)
at org.eclipse.jgit.revwalk.RevWalk.parseCommit(RevWalk.java:722)
at com.googlesource.gerrit.plugins.reviewnotes.CreateReviewNotes.createNotes(CreateReviewNotes.java:122)
at com.googlesource.gerrit.plugins.reviewnotes.RefUpdateListener.createReviewNotes(RefUpdateListener.java:126)
at com.googlesource.gerrit.plugins.reviewnotes.RefUpdateListener.access$000(RefUpdateListener.java:38)
at com.googlesource.gerrit.plugins.reviewnotes.RefUpdateListener$1.run(RefUpdateListener.java:66)
Change-Id: I4151d45674f92ed1d034ea3adadc48c49a686f03
diff --git a/src/main/java/com/googlesource/gerrit/plugins/reviewnotes/CreateReviewNotes.java b/src/main/java/com/googlesource/gerrit/plugins/reviewnotes/CreateReviewNotes.java
index 63d9186..d5b92ab 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/reviewnotes/CreateReviewNotes.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/reviewnotes/CreateReviewNotes.java
@@ -117,6 +117,10 @@
void createNotes(String branch, ObjectId oldObjectId, ObjectId newObjectId,
ProgressMonitor monitor) throws OrmException, IOException {
+ if (ObjectId.zeroId().equals(newObjectId)) {
+ return;
+ }
+
RevWalk rw = new RevWalk(git);
try {
rw.markStart(rw.parseCommit(newObjectId));