Simplify the GitReferenceUpdatedListener.Event API
So far the Event exposed the getUpdates method which implied that one Event could contain updates of more than one reference. However, we never made use of that feature. The only implementation of the Event always returns only one Update. The assumption that one Event could contain more than one reference Update also made coding in [1] more complex than necessary. This change simplifies that API in the sense that one Event corresponds to one ref update only. [1] https://gerrit-review.googlesource.com/#/c/50351/2/src/main/java/com/googlesource/gerrit/plugins/replication/PushResultProcessing.java Change-Id: Ifdb27e22ae83f30a6af7f0b4e6bf6acbd85fe6e4
This commit is contained in:
committed by
David Pursehouse
parent
13b2190cc9
commit
c573d8abf6
@@ -16,21 +16,16 @@ package com.google.gerrit.extensions.events;
|
||||
|
||||
import com.google.gerrit.extensions.annotations.ExtensionPoint;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/** Notified when one or more references are modified. */
|
||||
@ExtensionPoint
|
||||
public interface GitReferenceUpdatedListener {
|
||||
public interface Update {
|
||||
|
||||
public interface Event {
|
||||
String getProjectName();
|
||||
String getRefName();
|
||||
String getOldObjectId();
|
||||
String getNewObjectId();
|
||||
}
|
||||
|
||||
public interface Event {
|
||||
String getProjectName();
|
||||
List<Update> getUpdates();
|
||||
}
|
||||
|
||||
void onGitReferenceUpdated(Event event);
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
|
||||
package com.google.gerrit.server.extensions.events;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.gerrit.extensions.events.GitReferenceUpdatedListener;
|
||||
import com.google.gerrit.extensions.registration.DynamicSet;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
@@ -26,7 +25,6 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class GitReferenceUpdated {
|
||||
private static final Logger log = LoggerFactory
|
||||
@@ -85,25 +83,18 @@ public class GitReferenceUpdated {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GitReferenceUpdatedListener.Update> getUpdates() {
|
||||
GitReferenceUpdatedListener.Update update =
|
||||
new GitReferenceUpdatedListener.Update() {
|
||||
@Override
|
||||
public String getRefName() {
|
||||
return ref;
|
||||
}
|
||||
public String getRefName() {
|
||||
return ref;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOldObjectId() {
|
||||
return oldObjectId;
|
||||
}
|
||||
@Override
|
||||
public String getOldObjectId() {
|
||||
return oldObjectId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNewObjectId() {
|
||||
return newObjectId;
|
||||
}
|
||||
};
|
||||
return ImmutableList.of(update);
|
||||
@Override
|
||||
public String getNewObjectId() {
|
||||
return newObjectId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,11 +72,8 @@ public class ChangeCache implements GitReferenceUpdatedListener {
|
||||
|
||||
@Override
|
||||
public void onGitReferenceUpdated(GitReferenceUpdatedListener.Event event) {
|
||||
for (GitReferenceUpdatedListener.Update u : event.getUpdates()) {
|
||||
if (u.getRefName().startsWith("refs/changes/")) {
|
||||
cache.invalidate(new Project.NameKey(event.getProjectName()));
|
||||
break;
|
||||
}
|
||||
if (event.getRefName().startsWith("refs/changes/")) {
|
||||
cache.invalidate(new Project.NameKey(event.getProjectName()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user