@Override public <C extends AbstractGeoGigOp<?>> C pre(C command) throws CannotRunGeogigOperationException { /* * Store the ref name and its old value in the command's user properties to be used in the * post-hook if the operation was successful */ Map<String, Object> params = Scripting.getParamMap(command); String refName = (String) params.get("name"); command.getClientData().put("name", refName); // ignore if still inside a transaction or updating a known symref boolean ignore = command.context() instanceof GeogigTransaction; ignore |= (Ref.WORK_HEAD.equals(refName) || Ref.STAGE_HEAD.equals(refName)); if (ignore) { command.getClientData().put("ignore", Boolean.TRUE); // ignore updates to work/stage heads, we only care of updates to branches return command; } Optional<Ref> currentValue = command.command(RefParse.class).setName(refName).call(); command.getClientData().put("oldValue", currentValue); LOGGER.debug("GWC geogig truncate pre-hook engaged for ref '{}'", refName); return command; }
public @Override void preCall(AbstractGeoGigOp<?> command) {// nothing to do createIndexes(originRepo); createIndexes(upstreamRepo); String originURI = origin.getFetchURL(); command.getClientData().put(originURI, originRepo); String upstreamURI = upstream.getFetchURL(); command.getClientData().put(upstreamURI, upstreamRepo); }
private void verifyFetchedIndexes(AbstractGeoGigOp<?> command, TransferSummary ts) { Set<String> remotes = ts.getRefDiffs().keySet(); for (String remoteURI : remotes) { FetchOp op = (FetchOp) command; Remote remoteObj = op.getRemotes().stream() .filter(r -> remoteURI.equals(r.getFetchURL())).findFirst().get(); String fetchURL = remoteObj.getFetchURL(); Repository remote = (Repository) command.getClientData().get(fetchURL); Collection<RefDiff> collection = ts.getRefDiffs().get(remoteURI); for (RefDiff rd : collection) { if (rd.isDelete()) { continue; } Ref newRef = rd.getNewRef(); Repository local = command.context().repository(); String localRef = newRef.getName(); String remoteBranch = remoteObj.mapToRemote(localRef).orElse(null); verifyClonedIndexes(local, remote, Optional.of(localRef), Optional.of(remoteBranch)); } } }