public static Optional<byte[]> getBlob(BlobStore blobStore, final String blobName) { Optional<byte[]> blob = blobStore.getBlob(blobName); return blob; }
public static Optional<byte[]> getBlob(BlobStore blobStore, final String blobName) { Optional<byte[]> blob = blobStore.getBlob(blobName); return blob; }
@Override public byte[] iniBytes() throws IOException { Optional<byte[]> bytes = blobStore.getBlob(filterKey); if (bytes.isPresent()) { return bytes.get(); } else { throw new IOException("Filter blob did not exist."); } }
@Override public byte[] iniBytes() throws IOException { Optional<byte[]> bytes = blobStore.getBlob(filterKey); if (bytes.isPresent()) { return bytes.get(); } else { throw new IOException("Filter blob did not exist."); } }
/** * @return true if this is a sparse (mapped) clone. */ @Override public boolean isSparse() { return blobStore().getBlob(Blobs.SPARSE_FILTER_BLOB_KEY).isPresent(); }
/** * @return true if this is a sparse (mapped) clone. */ @Override public boolean isSparse() { return blobStore().getBlob(Blobs.SPARSE_FILTER_BLOB_KEY).isPresent(); }
/** * Returns the {@link RepositoryFilter} defined for {@code repo} as of its * {@link Blobs#SPARSE_FILTER_BLOB_KEY sparse_filter} blobstore's blob */ public static Optional<RepositoryFilter> getFilter(Repository repo) throws IllegalStateException { BlobStore blobStore = repo.blobStore(); Optional<byte[]> filterBlob = blobStore.getBlob(SPARSE_FILTER_BLOB_KEY); IniRepositoryFilter filter = null; if (filterBlob.isPresent()) { filter = new IniRepositoryFilter(blobStore, SPARSE_FILTER_BLOB_KEY); } return Optional.fromNullable(filter); }
/** * Returns the {@link RepositoryFilter} defined for {@code repo} as of its * {@link Blobs#SPARSE_FILTER_BLOB_KEY sparse_filter} blobstore's blob */ public static Optional<RepositoryFilter> getFilter(Repository repo) throws IllegalStateException { BlobStore blobStore = repo.blobStore(); Optional<byte[]> filterBlob = blobStore.getBlob(SPARSE_FILTER_BLOB_KEY); IniRepositoryFilter filter = null; if (filterBlob.isPresent()) { filter = new IniRepositoryFilter(blobStore, SPARSE_FILTER_BLOB_KEY); } return Optional.fromNullable(filter); }
private ObjectId getTheirsHeadId() { ObjectId theirsHeadId; Optional<Ref> mergeHead = geogig.command(RefParse.class).setName(Ref.MERGE_HEAD).call(); if (mergeHead.isPresent()) { // It was a merge theirsHeadId = mergeHead.get().getObjectId(); } else { // It was a rebase final Optional<byte[]> branchBlob = geogig.getRepository().blobStore() .getBlob(RebaseOp.REBASE_BRANCH_BLOB); Preconditions.checkState(branchBlob.isPresent(), "Cannot find merge/rebase head reference"); List<String> branchLines = Blobs.readLines(branchBlob); String currentBranch = branchLines.get(0); Optional<Ref> rebaseHead = geogig.command(RefParse.class).setName(currentBranch).call(); Preconditions.checkState(rebaseHead.isPresent(), "Rebase head could not be resolved."); theirsHeadId = rebaseHead.get().getObjectId(); } return theirsHeadId; }
private ObjectId getTheirsHeadId() { ObjectId theirsHeadId; Optional<Ref> mergeHead = geogig.command(RefParse.class).setName(Ref.MERGE_HEAD).call(); if (mergeHead.isPresent()) { // It was a merge theirsHeadId = mergeHead.get().getObjectId(); } else { // It was a rebase final Optional<byte[]> branchBlob = geogig.getRepository().blobStore() .getBlob(RebaseOp.REBASE_BRANCH_BLOB); Preconditions.checkState(branchBlob.isPresent(), "Cannot find merge/rebase head reference"); List<String> branchLines = Blobs.readLines(branchBlob); String currentBranch = branchLines.get(0); Optional<Ref> rebaseHead = geogig.command(RefParse.class).setName(currentBranch).call(); Preconditions.checkState(rebaseHead.isPresent(), "Rebase head could not be resolved."); theirsHeadId = rebaseHead.get().getObjectId(); } return theirsHeadId; }
private ObjectId getTheirsHeadId() { ObjectId theirsHeadId; Optional<Ref> mergeHead = geogig.command(RefParse.class).setName(Ref.MERGE_HEAD).call(); if (mergeHead.isPresent()) { // It was a merge theirsHeadId = mergeHead.get().getObjectId(); } else { // It was a rebase final Optional<byte[]> branchBlob = geogig.getRepository().blobStore() .getBlob(RebaseOp.REBASE_BRANCH_BLOB); Preconditions.checkState(branchBlob.isPresent(), "Cannot find merge/rebase head reference"); List<String> branchLines = Blobs.readLines(branchBlob); String currentBranch = branchLines.get(0); Optional<Ref> rebaseHead = geogig.command(RefParse.class).setName(currentBranch).call(); Preconditions.checkState(rebaseHead.isPresent(), "Rebase head could not be resolved."); theirsHeadId = rebaseHead.get().getObjectId(); } return theirsHeadId; }
Optional<byte[]> blobValue = geogig.blobStore().getBlob(deleteKey); if (!blobValue.isPresent()) { throw new CommandSpecException("The specified token does not exist or has expired.",
@Test public void testClean() throws Exception { // Set up some refs to clean up geogig.command(UpdateRef.class).setName(Ref.MERGE_HEAD).setNewValue(ObjectId.NULL).call(); geogig.command(UpdateRef.class).setName(Ref.ORIG_HEAD).setNewValue(ObjectId.NULL).call(); geogig.command(UpdateRef.class).setName(Ref.CHERRY_PICK_HEAD).setNewValue(ObjectId.NULL) .call(); geogig.getRepository().blobStore().putBlob(MergeOp.MERGE_MSG, "Merge message".getBytes()); ImmutableList<String> cleanedUp = geogig.command(CleanRefsOp.class).call(); assertEquals(4, cleanedUp.size()); assertTrue(cleanedUp.contains(Ref.MERGE_HEAD)); assertTrue(cleanedUp.contains(Ref.ORIG_HEAD)); assertTrue(cleanedUp.contains(Ref.CHERRY_PICK_HEAD)); assertTrue(cleanedUp.contains(MergeOp.MERGE_MSG)); Optional<Ref> ref = geogig.command(RefParse.class).setName(Ref.MERGE_HEAD).call(); assertFalse(ref.isPresent()); ref = geogig.command(RefParse.class).setName(Ref.ORIG_HEAD).call(); assertFalse(ref.isPresent()); ref = geogig.command(RefParse.class).setName(Ref.CHERRY_PICK_HEAD).call(); assertFalse(ref.isPresent()); Optional<byte[]> mergeMsg = geogig.getRepository().blobStore().getBlob(MergeOp.MERGE_MSG); assertFalse(mergeMsg.isPresent()); // Running it again should result in nothing being cleaned up. cleanedUp = geogig.command(CleanRefsOp.class).call(); assertEquals(0, cleanedUp.size()); }
@Test public void testClean() throws Exception { // Set up some refs to clean up geogig.command(UpdateRef.class).setName(Ref.MERGE_HEAD).setNewValue(ObjectId.NULL).call(); geogig.command(UpdateRef.class).setName(Ref.ORIG_HEAD).setNewValue(ObjectId.NULL).call(); geogig.command(UpdateRef.class).setName(Ref.CHERRY_PICK_HEAD).setNewValue(ObjectId.NULL) .call(); geogig.getRepository().blobStore().putBlob(MergeOp.MERGE_MSG, "Merge message".getBytes()); ImmutableList<String> cleanedUp = geogig.command(CleanRefsOp.class).call(); assertEquals(4, cleanedUp.size()); assertTrue(cleanedUp.contains(Ref.MERGE_HEAD)); assertTrue(cleanedUp.contains(Ref.ORIG_HEAD)); assertTrue(cleanedUp.contains(Ref.CHERRY_PICK_HEAD)); assertTrue(cleanedUp.contains(MergeOp.MERGE_MSG)); Optional<Ref> ref = geogig.command(RefParse.class).setName(Ref.MERGE_HEAD).call(); assertFalse(ref.isPresent()); ref = geogig.command(RefParse.class).setName(Ref.ORIG_HEAD).call(); assertFalse(ref.isPresent()); ref = geogig.command(RefParse.class).setName(Ref.CHERRY_PICK_HEAD).call(); assertFalse(ref.isPresent()); Optional<byte[]> mergeMsg = geogig.getRepository().blobStore().getBlob(MergeOp.MERGE_MSG); assertFalse(mergeMsg.isPresent()); // Running it again should result in nothing being cleaned up. cleanedUp = geogig.command(CleanRefsOp.class).call(); assertEquals(0, cleanedUp.size()); }
ref = geogig.command(RefParse.class).setName(Ref.ORIG_HEAD).call(); assertFalse(ref.isPresent()); Optional<byte[]> mergemsg = repository.blobStore().getBlob(MergeOp.MERGE_MSG); assertFalse(mergemsg.isPresent());
ref = geogig.command(RefParse.class).setName(Ref.ORIG_HEAD).call(); assertFalse(ref.isPresent()); Optional<byte[]> mergemsg = repository.blobStore().getBlob(MergeOp.MERGE_MSG); assertFalse(mergemsg.isPresent());