in src/main/java/com/googlesource/gerrit/plugins/replication/PushOne.java [624:669]
private List<RemoteRefUpdate> generateUpdates(Transport tn)
throws IOException, PermissionBackendException {
Optional<ProjectState> projectState = projectCache.get(projectName);
if (!projectState.isPresent()) {
return Collections.emptyList();
}
Map<String, Ref> local =
git.getRefDatabase().getRefs().stream().collect(toMap(Ref::getName, r -> r));
boolean filter;
PermissionBackend.ForProject forProject = permissionBackend.currentUser().project(projectName);
try {
projectState.get().checkStatePermitsRead();
forProject.check(ProjectPermission.READ);
filter = false;
} catch (AuthException | ResourceConflictException e) {
filter = true;
}
if (filter) {
if (!pushAllRefs) {
// If we aren't mirroring, reduce the space we need to filter
// to only the references we will update during this operation.
//
Map<String, Ref> n = new HashMap<>();
for (String src : delta) {
Ref r = local.get(src);
if (r != null) {
n.put(src, r);
}
}
local = n;
}
local =
forProject
.filter(local.values(), git, RefFilterOptions.builder().setFilterMeta(true).build())
.stream()
.collect(toMap(Ref::getName, r -> r));
}
List<RemoteRefUpdate> remoteUpdatesList =
pushAllRefs ? doPushAll(tn, local) : doPushDelta(local);
return replicationPushFilter == null || replicationPushFilter.get() == null
? remoteUpdatesList
: replicationPushFilter.get().filter(projectName.get(), remoteUpdatesList);
}