Search in sources :

Example 1 with ChangeTypes

use of org.locationtech.geogig.api.porcelain.TransferSummary.ChangedRef.ChangeTypes in project GeoGig by boundlessgeo.

the class SendPack method callInternal.

private TransferSummary callInternal(IRemoteRepo remoteRepo) {
    final Remote remote = this.remote;
    @Nullable String localRefSpec;
    @Nullable String remoteRefSpec;
    boolean force;
    TransferSummary result = new TransferSummary();
    for (TransferableRef ref : this.refsToPush) {
        localRefSpec = ref.getLocalRef();
        remoteRefSpec = ref.getRemoteRef();
        force = ref.isForceUpdate();
        if (ref.isDelete()) {
            Optional<Ref> deleted = remoteRepo.deleteRef(remoteRefSpec);
            if (deleted.isPresent()) {
                ChangedRef deleteResult = new ChangedRef(deleted.get(), null, REMOVED_REF);
                result.add(remote.getPushURL(), deleteResult);
            }
        } else {
            Optional<Ref> localRef = refParse(localRefSpec);
            checkState(localRef.isPresent(), "RefSpec %s does not exist", localRefSpec);
            Optional<Ref> newRef = push(remoteRepo, remote, localRef.get(), remoteRefSpec);
            if (newRef.isPresent()) {
                ChangeTypes changeType = remoteRefSpec == null ? ADDED_REF : CHANGED_REF;
                ChangedRef deleteResult = new ChangedRef(localRef.get(), newRef.get(), changeType);
                result.add(remote.getPushURL(), deleteResult);
            }
        }
    }
    return result;
}
Also used : ChangedRef(org.locationtech.geogig.api.porcelain.TransferSummary.ChangedRef) Ref(org.locationtech.geogig.api.Ref) Remote(org.locationtech.geogig.api.Remote) ChangedRef(org.locationtech.geogig.api.porcelain.TransferSummary.ChangedRef) TransferSummary(org.locationtech.geogig.api.porcelain.TransferSummary) ChangeTypes(org.locationtech.geogig.api.porcelain.TransferSummary.ChangedRef.ChangeTypes) Nullable(javax.annotation.Nullable)

Aggregations

Nullable (javax.annotation.Nullable)1 Ref (org.locationtech.geogig.api.Ref)1 Remote (org.locationtech.geogig.api.Remote)1 TransferSummary (org.locationtech.geogig.api.porcelain.TransferSummary)1 ChangedRef (org.locationtech.geogig.api.porcelain.TransferSummary.ChangedRef)1 ChangeTypes (org.locationtech.geogig.api.porcelain.TransferSummary.ChangedRef.ChangeTypes)1