Example usage for org.eclipse.jgit.revwalk RevTag parse

List of usage examples for org.eclipse.jgit.revwalk RevTag parse

Introduction

In this page you can find the example usage for org.eclipse.jgit.revwalk RevTag parse.

Prototype

public static RevTag parse(byte[] raw) throws CorruptObjectException 

Source Link

Document

Parse an annotated tag from its canonical format.

Usage

From source file:com.github.koraktor.mavanagaiata.git.jgit.JGitRepositoryTest.java

License:Open Source License

private RevTag createTag(String name, String objectId) throws CorruptObjectException {
    String tagData = String.format(
            "object %s\n" + "type commit\n" + "tag %s\n"
                    + "tagger Sebastian Staudt <koraktor@gmail.com> %d +0100\n" + "%s",
            objectId, name, new Date().getTime(), "Tag subject");
    return RevTag.parse(tagData.getBytes());
}

From source file:com.github.koraktor.mavanagaiata.git.jgit.JGitTagTest.java

License:Open Source License

@Test
public void test() throws Exception {
    RevTag rawTag = RevTag.parse(("object 4b825dc642cb6eb9a060e54bf8d69288fbee4904\n" + "type commit\n"
            + "tag 1.0.0\n" + "tagger Sebastian Staudt <koraktor@gmail.com> 1275131880 +0200\n" + "\n"
            + "Version 1.0.0\n").getBytes());
    Date tagDate = new Date(1275131880000L);

    JGitTag tag = new JGitTag(rawTag);
    JGitTag tag2 = new JGitTag(rawTag);

    assertThat(tag.getDate(), is(equalTo(tagDate)));
    assertThat(tag.getName(), is(equalTo("1.0.0")));
    assertThat(tag.getTimeZone(), is(TimeZone.getTimeZone("GMT+0200")));
    assertThat(tag, is(equalTo(tag2)));//from w ww.ja  v  a 2s  .  co m
}