Search in sources :

Example 1 with RevTagImpl

use of org.locationtech.geogig.api.RevTagImpl in project GeoGig by boundlessgeo.

the class HashObjectTest method testHashTags.

@Test
public void testHashTags() throws Exception {
    RevPerson tagger = new RevPersonImpl("volaya", "volaya@boundlessgeo.com", -1000, -1);
    RevPerson tagger2 = new RevPersonImpl("groldan", "groldan@boundlessgeo.com", 10000, 0);
    RevTag tag = new RevTagImpl(null, "tag1", ObjectId.forString("fake commit id"), "message", tagger);
    RevTag tag2 = new RevTagImpl(null, "tag2", ObjectId.forString("another fake commit id"), "another message", tagger2);
    ObjectId tagId = hashCommand.setObject(tag).call();
    ObjectId tagId2 = hashCommand.setObject(tag2).call();
    assertNotNull(tagId);
    assertNotNull(tagId2);
    assertNotSame(tagId, tagId2);
}
Also used : RevPersonImpl(org.locationtech.geogig.api.RevPersonImpl) RevPerson(org.locationtech.geogig.api.RevPerson) RevTag(org.locationtech.geogig.api.RevTag) ObjectId(org.locationtech.geogig.api.ObjectId) RevTagImpl(org.locationtech.geogig.api.RevTagImpl) Test(org.junit.Test)

Example 2 with RevTagImpl

use of org.locationtech.geogig.api.RevTagImpl in project GeoGig by boundlessgeo.

the class TagCreateOp method _call.

/**
     * Executes the tag creation operation.
     * 
     * @return the created tag
     * 
     */
@Override
protected RevTag _call() throws RuntimeException {
    checkState(name != null, "tag name was not provided");
    final String tagRefPath = Ref.TAGS_PREFIX + name;
    checkArgument(!command(RefParse.class).setName(tagRefPath).call().isPresent(), "A tag named '" + name + "' already exists.");
    if (commitId == null) {
        final Optional<Ref> currHead = command(RefParse.class).setName(Ref.HEAD).call();
        Preconditions.checkState(currHead.isPresent(), "Repository has no HEAD, can't create tag");
        commitId = currHead.get().getObjectId();
    }
    RevPerson tagger = resolveTagger();
    message = message == null ? "" : message;
    RevTag tag = new RevTagImpl(ObjectId.NULL, name, commitId, message, tagger);
    ObjectId id = command(HashObject.class).setObject(tag).call();
    tag = new RevTagImpl(id, name, commitId, message, tagger);
    objectDatabase().put(tag);
    Optional<Ref> branchRef = command(UpdateRef.class).setName(tagRefPath).setNewValue(tag.getId()).call();
    checkState(branchRef.isPresent());
    return tag;
}
Also used : Ref(org.locationtech.geogig.api.Ref) UpdateRef(org.locationtech.geogig.api.plumbing.UpdateRef) RevPerson(org.locationtech.geogig.api.RevPerson) RevTag(org.locationtech.geogig.api.RevTag) ObjectId(org.locationtech.geogig.api.ObjectId) RevTagImpl(org.locationtech.geogig.api.RevTagImpl) RefParse(org.locationtech.geogig.api.plumbing.RefParse) UpdateRef(org.locationtech.geogig.api.plumbing.UpdateRef)

Example 3 with RevTagImpl

use of org.locationtech.geogig.api.RevTagImpl in project GeoGig by boundlessgeo.

the class FormatCommonV1 method readTag.

public static RevTag readTag(ObjectId id, DataInput in) throws IOException {
    final ObjectId commitId = readObjectId(in);
    final String name = in.readUTF();
    final String message = in.readUTF();
    final RevPerson tagger = readRevPerson(in);
    return new RevTagImpl(id, name, commitId, message, tagger);
}
Also used : RevPerson(org.locationtech.geogig.api.RevPerson) ObjectId(org.locationtech.geogig.api.ObjectId) RevTagImpl(org.locationtech.geogig.api.RevTagImpl)

Example 4 with RevTagImpl

use of org.locationtech.geogig.api.RevTagImpl in project GeoGig by boundlessgeo.

the class FormatCommonV2 method readTag.

public static RevTag readTag(ObjectId id, DataInput in) throws IOException {
    final ObjectId commitId = readObjectId(in);
    final String name = in.readUTF();
    final String message = in.readUTF();
    final RevPerson tagger = readRevPerson(in);
    return new RevTagImpl(id, name, commitId, message, tagger);
}
Also used : RevPerson(org.locationtech.geogig.api.RevPerson) ObjectId(org.locationtech.geogig.api.ObjectId) RevTagImpl(org.locationtech.geogig.api.RevTagImpl) Integer.toBinaryString(java.lang.Integer.toBinaryString)

Aggregations

ObjectId (org.locationtech.geogig.api.ObjectId)4 RevPerson (org.locationtech.geogig.api.RevPerson)4 RevTagImpl (org.locationtech.geogig.api.RevTagImpl)4 RevTag (org.locationtech.geogig.api.RevTag)2 Integer.toBinaryString (java.lang.Integer.toBinaryString)1 Test (org.junit.Test)1 Ref (org.locationtech.geogig.api.Ref)1 RevPersonImpl (org.locationtech.geogig.api.RevPersonImpl)1 RefParse (org.locationtech.geogig.api.plumbing.RefParse)1 UpdateRef (org.locationtech.geogig.api.plumbing.UpdateRef)1