@Test public void testNewFileSystemWithSubfolder() { final URI newRepo = URI.create("git://test/sub-repo-name"); final FileSystem fs = provider.newFileSystem(newRepo, EMPTY_ENV); assertThat(fs).isNotNull(); final DirectoryStream<Path> stream = provider.newDirectoryStream(provider.getPath(newRepo), null); assertThat(stream).isEmpty(); }
@Test public void testNewFileSystemWithSubfolder() { final URI newRepo = URI.create("git://test/sub-repo-name"); final FileSystem fs = provider.newFileSystem(newRepo, EMPTY_ENV); assertThat(fs).isNotNull(); final DirectoryStream<Path> stream = provider.newDirectoryStream(provider.getPath(newRepo), null); assertThat(stream).isEmpty(); }
@Test public void testNewFileSystemInited() { final URI newRepo = URI.create("git://init-repo-name"); final Map<String, ?> env = new HashMap<String, Object>() {{ put("init", Boolean.TRUE); }}; final FileSystem fs = provider.newFileSystem(newRepo, env); assertThat(fs).isNotNull(); final DirectoryStream<Path> stream = provider.newDirectoryStream(provider.getPath(newRepo), null); assertThat(stream).isNotNull().hasSize(1); }
@Test public void testNewFileSystemInited() { final URI newRepo = URI.create("git://init-repo-name"); final Map<String, ?> env = new HashMap<String, Object>() {{ put("init", Boolean.TRUE); }}; final FileSystem fs = provider.newFileSystem(newRepo, env); assertThat(fs).isNotNull(); final DirectoryStream<Path> stream = provider.newDirectoryStream(provider.getPath(newRepo), null); assertThat(stream).isNotNull().hasSize(1); }
private Map<JGitPathImpl, JGitPathImpl> mapDirectoryContent(final JGitPathImpl source, final JGitPathImpl target, final CopyOption... options) { final Map<JGitPathImpl, JGitPathImpl> fromTo = new HashMap<>(); for (final Path path : newDirectoryStream(source, null)) { final JGitPathImpl gPath = toPathImpl(path); final PathInfo pathResult = gPath.getFileSystem().getGit().getPathInfo(gPath.getRefTree(), gPath.getPath()); if (pathResult.getPathType() == DIRECTORY) { fromTo.putAll(mapDirectoryContent(gPath, composePath(target, (JGitPathImpl) gPath.getFileName()))); } else { final JGitPathImpl gTarget = composePath(target, (JGitPathImpl) gPath.getFileName()); fromTo.put(gPath, gTarget); } } return fromTo; }
@Test public void testFilteredNewDirectoryStream() throws IOException { final URI newRepo = URI.create("git://filter-dirstream-test-repo"); provider.newFileSystem(newRepo, EMPTY_ENV); final Path path = provider.getPath(URI.create("git://master@filter-dirstream-test-repo/myfile1.txt")); final OutputStream outStream = provider.newOutputStream(path); outStream.write("my cool content".getBytes()); outStream.close(); final Path path2 = provider.getPath(URI.create("git://user_branch@filter-dirstream-test-repo/other/path/myfile2.txt")); final OutputStream outStream2 = provider.newOutputStream(path2); outStream2.write("my cool content".getBytes()); outStream2.close(); final Path path3 = provider.getPath(URI.create("git://user_branch@filter-dirstream-test-repo/myfile3.txt")); final OutputStream outStream3 = provider.newOutputStream(path3); outStream3.write("my cool content".getBytes()); outStream3.close(); final Path path4 = provider.getPath(URI.create("git://user_branch@filter-dirstream-test-repo/myfile4.xxx")); final OutputStream outStream4 = provider.newOutputStream(path4); outStream4.write("my cool content".getBytes()); outStream4.close(); final DirectoryStream<Path> stream1 = provider.newDirectoryStream(provider.getPath(URI.create("git://user_branch@filter-dirstream-test-repo/")), entry -> entry.toString().endsWith(".xxx")); assertThat(stream1).isNotNull().hasSize(1).contains(path4); final DirectoryStream<Path> stream2 = provider.newDirectoryStream(provider.getPath(URI.create("git://master@filter-dirstream-test-repo/")), entry -> false); assertThat(stream2).isNotNull().hasSize(0); }
final DirectoryStream<Path> stream = provider.newDirectoryStream(provider.getPath(newRepo), null); assertThat(stream).isNotNull().hasSize(0);
final DirectoryStream<Path> stream = provider.newDirectoryStream(provider.getPath(newRepo), null); assertThat(stream).isNotNull().hasSize(0);
@Test public void testFilteredNewDirectoryStream() throws IOException { final URI newRepo = URI.create("git://filter-dirstream-test-repo"); provider.newFileSystem(newRepo, EMPTY_ENV); final Path path = provider.getPath(URI.create("git://master@filter-dirstream-test-repo/myfile1.txt")); final OutputStream outStream = provider.newOutputStream(path); outStream.write("my cool content".getBytes()); outStream.close(); final Path path2 = provider.getPath(URI.create("git://user_branch@filter-dirstream-test-repo/other/path/myfile2.txt")); final OutputStream outStream2 = provider.newOutputStream(path2); outStream2.write("my cool content".getBytes()); outStream2.close(); final Path path3 = provider.getPath(URI.create("git://user_branch@filter-dirstream-test-repo/myfile3.txt")); final OutputStream outStream3 = provider.newOutputStream(path3); outStream3.write("my cool content".getBytes()); outStream3.close(); final Path path4 = provider.getPath(URI.create("git://user_branch@filter-dirstream-test-repo/myfile4.xxx")); final OutputStream outStream4 = provider.newOutputStream(path4); outStream4.write("my cool content".getBytes()); outStream4.close(); final DirectoryStream<Path> stream1 = provider.newDirectoryStream(provider.getPath(URI.create("git://user_branch@filter-dirstream-test-repo/")), entry -> entry.toString().endsWith(".xxx")); assertThat(stream1).isNotNull().hasSize(1).contains(path4); final DirectoryStream<Path> stream2 = provider.newDirectoryStream(provider.getPath(URI.create("git://master@filter-dirstream-test-repo/")), entry -> false); assertThat(stream2).isNotNull().hasSize(0); }
private void copyDirectory(final JGitPathImpl source, final JGitPathImpl target) { final List<JGitPathImpl> directories = new ArrayList<JGitPathImpl>(); for (final Path path : newDirectoryStream(source, null)) { final JGitPathImpl gPath = toPathImpl(path); final Pair<PathType, ObjectId> pathResult = checkPath(gPath.getFileSystem().gitRepo(), gPath.getRefTree(), gPath.getPath()); if (pathResult.getK1() == DIRECTORY) { directories.add(gPath); continue; } final JGitPathImpl gTarget = composePath(target, (JGitPathImpl) gPath.getFileName()); copyFile(gPath, gTarget); } for (final JGitPathImpl directory : directories) { createDirectory(composePath(target, (JGitPathImpl) directory.getFileName())); } }
@Test public void testCopyFilesAcrossRepositories() throws IOException { final URI newRepo1 = URI.create("git://copyasset-test-repo1"); provider.newFileSystem(newRepo1, EMPTY_ENV); final URI newRepo2 = URI.create("git://copyasset-test-repo2"); provider.newFileSystem(newRepo2, EMPTY_ENV); final Path path = provider.getPath(URI.create("git://master@copyasset-test-repo1/myfile1.txt")); { final OutputStream outStream = provider.newOutputStream(path); outStream.write("my cool content".getBytes()); outStream.close(); } final Path target = provider.getPath(URI.create("git://master@copyasset-test-repo2/myfile1.txt")); provider.copy(path, target); final DirectoryStream<Path> stream = provider.newDirectoryStream(provider.getPath(URI.create("git://master@copyasset-test-repo2/")), null); for (Path path1 : stream) { System.out.println("content: " + path1.toUri()); } assertThat(stream).isNotNull().hasSize(1); }
@Test public void testCopyFilesAcrossRepositories() throws IOException { final URI newRepo1 = URI.create("git://copyasset-test-repo1"); provider.newFileSystem(newRepo1, EMPTY_ENV); final URI newRepo2 = URI.create("git://copyasset-test-repo2"); provider.newFileSystem(newRepo2, EMPTY_ENV); final Path path = provider.getPath(URI.create("git://master@copyasset-test-repo1/myfile1.txt")); { final OutputStream outStream = provider.newOutputStream(path); outStream.write("my cool content".getBytes()); outStream.close(); } final Path target = provider.getPath(URI.create("git://master@copyasset-test-repo2/myfile1.txt")); provider.copy(path, target); final DirectoryStream<Path> stream = provider.newDirectoryStream(provider.getPath(URI.create("git://master@copyasset-test-repo2/")), null); for (Path path1 : stream) { System.out.println("content: " + path1.toUri()); } assertThat(stream).isNotNull().hasSize(1); }
@Test public void testNewFileSystem() { final URI newRepo = URI.create("git://repo-name"); final FileSystem fs = provider.newFileSystem(newRepo, EMPTY_ENV); assertThat(fs).isNotNull(); final DirectoryStream<Path> stream = provider.newDirectoryStream(provider.getPath(newRepo), null); assertThat(stream).isNotNull().hasSize(0); try { provider.newFileSystem(newRepo, EMPTY_ENV); failBecauseExceptionWasNotThrown(FileSystemAlreadyExistsException.class); } catch (final Exception ignored) { } provider.newFileSystem(URI.create("git://repo-name2"), EMPTY_ENV); }
@Test public void testNewFileSystem() { final URI newRepo = URI.create("git://repo-name"); final FileSystem fs = provider.newFileSystem(newRepo, EMPTY_ENV); assertThat(fs).isNotNull(); final DirectoryStream<Path> stream = provider.newDirectoryStream(provider.getPath(newRepo), null); assertThat(stream).isNotNull().hasSize(0); try { provider.newFileSystem(newRepo, EMPTY_ENV); failBecauseExceptionWasNotThrown(FileSystemAlreadyExistsException.class); } catch (final Exception ignored) { } provider.newFileSystem(URI.create("git://repo-name2"), EMPTY_ENV); }
target); final DirectoryStream<Path> stream = provider.newDirectoryStream(provider.getPath(URI.create("git://other_branch@copybranch-test-repo/")), null);
target); final DirectoryStream<Path> stream = provider.newDirectoryStream(provider.getPath(URI.create("git://other_branch@copybranch-test-repo/")), null);
target); final DirectoryStream<Path> stream = provider.newDirectoryStream(provider.getPath(URI.create("git://user_branch@copyasset-test-repo/")), null);
target); final DirectoryStream<Path> stream = provider.newDirectoryStream(provider.getPath(URI.create("git://user_branch@copyasset-test-repo/")), null);
private void copyDirectory(final JGitPathImpl source, final JGitPathImpl target, final CopyOption... options) { final List<JGitPathImpl> directories = new ArrayList<>(); for (final Path path : newDirectoryStream(source, null)) { final JGitPathImpl gPath = toPathImpl(path); final PathInfo pathResult = gPath.getFileSystem().getGit().getPathInfo(gPath.getRefTree(), gPath.getPath()); if (pathResult.getPathType() == DIRECTORY) { directories.add(gPath); continue; } final JGitPathImpl gTarget = composePath(target, (JGitPathImpl) gPath.getFileName()); copyFile(gPath, gTarget); } for (final JGitPathImpl directory : directories) { createDirectory(composePath(target, (JGitPathImpl) directory.getFileName())); } }
final DirectoryStream<Path> stream3 = provider.newDirectoryStream(dir, null);