Ejemplo n.º 1
0
 @Test
 public void taggedTagTime() throws Exception {
   repo.tick(2);
   RevTag tag = repo.tag("tag", repo.commit().create());
   repo.tick(-1);
   RevTag tagTag = repo.tag("tagtag", tag);
   assertThat(getTime(tag)).isEqualTo(start + 3);
   assertThat(getTime(tagTag)).isEqualTo(start + 2);
 }
Ejemplo n.º 2
0
 @Test
 public void taggedTreeAndBlobTime() throws Exception {
   RevBlob blob = repo.blob("contents");
   RevTree tree = repo.tree(repo.file("foo", blob));
   repo.tick(1);
   RevTag blobTag = repo.tag("blob", blob);
   repo.tick(1);
   RevTag treeTag = repo.tag("tree", tree);
   assertThat(getTime(blobTag)).isEqualTo(start + 1);
   assertThat(getTime(treeTag)).isEqualTo(start + 2);
 }
Ejemplo n.º 3
0
 @Test
 public void taggedCommitTime() throws Exception {
   RevCommit commit = repo.commit().create();
   repo.tick(1);
   RevTag tag = repo.tag("tag", commit);
   assertThat(getTime(commit)).isEqualTo(start + 1);
   assertThat(getTime(tag)).isEqualTo(start + 2);
 }
Ejemplo n.º 4
0
  @Test
  public void firstTagMissingTime() throws Exception {
    RevCommit commit = repo.commit().create();
    repo.tick(1);
    RevTag tag = repo.tag("tag", commit);
    repo.tick(1);

    TagBuilder builder = new TagBuilder();
    builder.setObjectId(tag);
    builder.setTag("tagtag");
    builder.setMessage("");
    ObjectId tagTagId;
    try (ObjectInserter ins = repo.getRepository().newObjectInserter()) {
      tagTagId = ins.insert(builder);
      ins.flush();
    }
    assertThat(getTime(commit)).isEqualTo(start + 1);
    assertThat(getTime(tag)).isEqualTo(start + 2);
    assertThat(getTime(tagTagId)).isEqualTo(start + 2);
  }
Ejemplo n.º 5
0
  /**
   * Create a new commit.
   *
   * <p>The author and committer identities are stored using the current timestamp, after being
   * incremented by {@code secDelta}. The message body is empty.
   *
   * @param secDelta number of seconds to advance {@link #tick(int)} by.
   * @param tree the root tree for the commit.
   * @param parents zero or more parents of the commit.
   * @return the new commit.
   * @throws Exception
   */
  public RevCommit commit(final int secDelta, final RevTree tree, final RevCommit... parents)
      throws Exception {
    tick(secDelta);

    final org.eclipse.jgit.lib.CommitBuilder c;

    c = new org.eclipse.jgit.lib.CommitBuilder();
    c.setTreeId(tree);
    c.setParentIds(parents);
    c.setAuthor(new PersonIdent(author, new Date(now)));
    c.setCommitter(new PersonIdent(committer, new Date(now)));
    c.setMessage("");
    ObjectId id;
    try {
      id = inserter.insert(c);
      inserter.flush();
    } finally {
      inserter.release();
    }
    return pool.lookupCommit(id);
  }