Package org.eclipse.jgit.lib

Examples of org.eclipse.jgit.lib.Tag


   * @param walk
   *            revision walker owning this reference.
   * @return parsed tag.
   */
  public Tag asTag(final RevWalk walk) {
    return new Tag(walk.repository, this, tagName, buffer);
  }
View Full Code Here


   *            object the tag should be pointed at.
   * @return the annotated tag object.
   * @throws Exception
   */
  public RevTag tag(final String name, final RevObject dst) throws Exception {
    final Tag t = new Tag(db);
    t.setType(Constants.typeString(dst.getType()));
    t.setObjId(dst.toObjectId());
    t.setTag(name);
    t.setTagger(new PersonIdent(committer, new Date(now)));
    t.setMessage("");
    ObjectId id;
    try {
      id = inserter.insert(Constants.OBJ_TAG, inserter.format(t));
      inserter.flush();
    } finally {
View Full Code Here

        t.getId());
  }

  public void test020_createBlobTag() throws IOException {
    final ObjectId emptyId = new ObjectWriter(db).writeBlob(new byte[0]);
    final Tag t = new Tag(db);
    t.setObjId(emptyId);
    t.setType("blob");
    t.setTag("test020");
    t.setAuthor(new PersonIdent(author, 1154236443000L, -4 * 60));
    t.setMessage("test020 tagged\n");
    t.tag();
    assertEquals("6759556b09fbb4fd8ae5e315134481cc25d46954", t.getTagId().name());

    Tag mapTag = db.mapTag("test020");
    assertEquals("blob", mapTag.getType());
    assertEquals("test020 tagged\n", mapTag.getMessage());
    assertEquals(new PersonIdent(author, 1154236443000L, -4 * 60), mapTag.getAuthor());
    assertEquals("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", mapTag.getObjId().name());
  }
View Full Code Here

    assertEquals("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", mapTag.getObjId().name());
  }

  public void test020b_createBlobPlainTag() throws IOException {
    test020_createBlobTag();
    Tag t = new Tag(db);
    t.setTag("test020b");
    t.setObjId(ObjectId.fromString("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"));
    t.tag();

    Tag mapTag = db.mapTag("test020b");
    assertEquals("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", mapTag.getObjId().name());

    // We do not repeat the plain tag test for other object types
  }
View Full Code Here

  public void test021_createTreeTag() throws IOException {
    final ObjectId emptyId = new ObjectWriter(db).writeBlob(new byte[0]);
    final Tree almostEmptyTree = new Tree(db);
    almostEmptyTree.addEntry(new FileTreeEntry(almostEmptyTree, emptyId, "empty".getBytes(), false));
    final ObjectId almostEmptyTreeId = new ObjectWriter(db).writeTree(almostEmptyTree);
    final Tag t = new Tag(db);
    t.setObjId(almostEmptyTreeId);
    t.setType("tree");
    t.setTag("test021");
    t.setAuthor(new PersonIdent(author, 1154236443000L, -4 * 60));
    t.setMessage("test021 tagged\n");
    t.tag();
    assertEquals("b0517bc8dbe2096b419d42424cd7030733f4abe5", t.getTagId().name());

    Tag mapTag = db.mapTag("test021");
    assertEquals("tree", mapTag.getType());
    assertEquals("test021 tagged\n", mapTag.getMessage());
    assertEquals(new PersonIdent(author, 1154236443000L, -4 * 60), mapTag.getAuthor());
    assertEquals("417c01c8795a35b8e835113a85a5c0c1c77f67fb", mapTag.getObjId().name());
  }
View Full Code Here

    almostEmptyCommit.setAuthor(new PersonIdent(author, 1154236443000L, -2 * 60)); // not exactly the same
    almostEmptyCommit.setCommitter(new PersonIdent(author, 1154236443000L, -2 * 60));
    almostEmptyCommit.setMessage("test022\n");
    almostEmptyCommit.setTreeId(almostEmptyTreeId);
    ObjectId almostEmptyCommitId = new ObjectWriter(db).writeCommit(almostEmptyCommit);
    final Tag t = new Tag(db);
    t.setObjId(almostEmptyCommitId);
    t.setType("commit");
    t.setTag("test022");
    t.setAuthor(new PersonIdent(author, 1154236443000L, -4 * 60));
    t.setMessage("test022 tagged\n");
    t.tag();
    assertEquals("0ce2ebdb36076ef0b38adbe077a07d43b43e3807", t.getTagId().name());

    Tag mapTag = db.mapTag("test022");
    assertEquals("commit", mapTag.getType());
    assertEquals("test022 tagged\n", mapTag.getMessage());
    assertEquals(new PersonIdent(author, 1154236443000L, -4 * 60), mapTag.getAuthor());
    assertEquals("b5d3b45a96b340441f5abb9080411705c51cc86c", mapTag.getObjId().name());
  }
View Full Code Here

    if (!new File(db.getDirectory(),"refs/tags/test020").delete()) throw new Error("Cannot delete unpacked tag");
    if (!new File(db.getDirectory(),"refs/tags/test021").delete()) throw new Error("Cannot delete unpacked tag");
    if (!new File(db.getDirectory(),"refs/tags/test022").delete()) throw new Error("Cannot delete unpacked tag");

    // We cannot resolve it now, since we have no ref
    Tag mapTag20missing = db.mapTag("test020");
    assertNull(mapTag20missing);

    // Construct packed refs file
    PrintWriter w = new PrintWriter(new FileWriter(new File(db.getDirectory(), "packed-refs")));
    w.println("# packed-refs with: peeled");
    w.println("6759556b09fbb4fd8ae5e315134481cc25d46954 refs/tags/test020");
    w.println("^e69de29bb2d1d6434b8b29ae775ad8c2e48c5391");
    w.println("b0517bc8dbe2096b419d42424cd7030733f4abe5 refs/tags/test021");
    w.println("^417c01c8795a35b8e835113a85a5c0c1c77f67fb");
    w.println("0ce2ebdb36076ef0b38adbe077a07d43b43e3807 refs/tags/test022");
    w.println("^b5d3b45a96b340441f5abb9080411705c51cc86c");
    w.close();
    ((RefDirectory)db.getRefDatabase()).rescan();

    Tag mapTag20 = db.mapTag("test020");
    assertNotNull("have tag test020", mapTag20);
    assertEquals("blob", mapTag20.getType());
    assertEquals("test020 tagged\n", mapTag20.getMessage());
    assertEquals(new PersonIdent(author, 1154236443000L, -4 * 60), mapTag20.getAuthor());
    assertEquals("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", mapTag20.getObjId().name());

    Tag mapTag21 = db.mapTag("test021");
    assertEquals("tree", mapTag21.getType());
    assertEquals("test021 tagged\n", mapTag21.getMessage());
    assertEquals(new PersonIdent(author, 1154236443000L, -4 * 60), mapTag21.getAuthor());
    assertEquals("417c01c8795a35b8e835113a85a5c0c1c77f67fb", mapTag21.getObjId().name());

    Tag mapTag22 = db.mapTag("test022");
    assertEquals("commit", mapTag22.getType());
    assertEquals("test022 tagged\n", mapTag22.getMessage());
    assertEquals(new PersonIdent(author, 1154236443000L, -4 * 60), mapTag22.getAuthor());
    assertEquals("b5d3b45a96b340441f5abb9080411705c51cc86c", mapTag22.getObjId().name());
  }
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.lib.Tag

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.