org.eclipse.jgit.lib.TreeFormatter Java Examples

The following examples show how to use org.eclipse.jgit.lib.TreeFormatter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GfsChangesCollectorTest.java    From ParallelGit with Apache License 2.0 5 votes vote down vote up
@Nonnull
private GitFileEntry newDirectoryEntry(String... children) throws IOException {
  TreeFormatter tf = new TreeFormatter();
  for(String child : children) {
    GitFileEntry childEntry = someFileEntry();
    tf.append(child, childEntry.getMode(), childEntry.getId());
  }
  ObjectId treeId = TreeUtils.insertTree(tf, repo);
  return newTreeEntry(treeId);
}
 
Example #2
Source File: TreeUtilsInsertTreeTest.java    From ParallelGit with Apache License 2.0 5 votes vote down vote up
@Test
public void insertTreeIntoRepository_shouldBeAbleToRetrieveChildrenIdsByTreeIdAndFilename() throws IOException {
  initRepository();

  TreeFormatter tf = new TreeFormatter();
  ObjectId nodeObject1 = someObjectId();
  tf.append("file1.txt", REGULAR_FILE, nodeObject1);
  ObjectId nodeObject2 = someObjectId();
  tf.append("file2.txt", REGULAR_FILE, nodeObject2);
  ObjectId tree = TreeUtils.insertTree(tf, repo);

  assertEquals(nodeObject1, TreeUtils.getObjectId("file1.txt", tree, repo));
  assertEquals(nodeObject2, TreeUtils.getObjectId("file2.txt", tree, repo));
}
 
Example #3
Source File: TreeUtilsInsertTreeTest.java    From ParallelGit with Apache License 2.0 5 votes vote down vote up
@Test
public void insertTreeIntoRepository_shouldBeAbleToRetrieveChildrenFileModesByTreeIdAndFilename() throws IOException {
  initRepository();

  TreeFormatter tf = new TreeFormatter();
  tf.append("file.txt", REGULAR_FILE, someObjectId());
  tf.append("dir", TREE, someObjectId());
  ObjectId tree = TreeUtils.insertTree(tf, repo);

  assertEquals(REGULAR_FILE, TreeUtils.getFileMode("file.txt", tree, repo));
  assertEquals(TREE, TreeUtils.getFileMode("dir", tree, repo));
}
 
Example #4
Source File: GfsChangesCollectorTest.java    From ParallelGit with Apache License 2.0 5 votes vote down vote up
@Nonnull
private GitFileEntry newDirectoryEntry(String... children) throws IOException {
  TreeFormatter tf = new TreeFormatter();
  for(String child : children) {
    GitFileEntry childEntry = someFileEntry();
    tf.append(child, childEntry.getMode(), childEntry.getId());
  }
  ObjectId treeId = TreeUtils.insertTree(tf, repo);
  return newTreeEntry(treeId);
}
 
Example #5
Source File: TreeUtilsInsertTreeTest.java    From ParallelGit with Apache License 2.0 5 votes vote down vote up
@Test
public void insertTreeIntoRepository_shouldBeAbleToRetrieveChildrenIdsByTreeIdAndFilename() throws IOException {
  initRepository();

  TreeFormatter tf = new TreeFormatter();
  ObjectId nodeObject1 = someObjectId();
  tf.append("file1.txt", REGULAR_FILE, nodeObject1);
  ObjectId nodeObject2 = someObjectId();
  tf.append("file2.txt", REGULAR_FILE, nodeObject2);
  ObjectId tree = TreeUtils.insertTree(tf, repo);

  assertEquals(nodeObject1, TreeUtils.getObjectId("file1.txt", tree, repo));
  assertEquals(nodeObject2, TreeUtils.getObjectId("file2.txt", tree, repo));
}
 
Example #6
Source File: TreeUtilsInsertTreeTest.java    From ParallelGit with Apache License 2.0 5 votes vote down vote up
@Test
public void insertTreeIntoRepository_shouldBeAbleToRetrieveChildrenFileModesByTreeIdAndFilename() throws IOException {
  initRepository();

  TreeFormatter tf = new TreeFormatter();
  tf.append("file.txt", REGULAR_FILE, someObjectId());
  tf.append("dir", TREE, someObjectId());
  ObjectId tree = TreeUtils.insertTree(tf, repo);

  assertEquals(REGULAR_FILE, TreeUtils.getFileMode("file.txt", tree, repo));
  assertEquals(TREE, TreeUtils.getFileMode("dir", tree, repo));
}
 
Example #7
Source File: GitTreeUpdate.java    From git-as-svn with GNU General Public License v2.0 5 votes vote down vote up
@NotNull ObjectId buildTree(@NotNull ObjectInserter inserter) throws IOException {
  final TreeFormatter treeBuilder = new TreeFormatter();
  final List<GitTreeEntry> sortedEntries = new ArrayList<>(entries.values());
  Collections.sort(sortedEntries);
  for (GitTreeEntry entry : sortedEntries) {
    treeBuilder.append(entry.getFileName(), entry.getFileMode(), entry.getObjectId().getObject());
  }
  new ObjectChecker().checkTree(treeBuilder.toByteArray());
  return inserter.insert(treeBuilder);
}