@Test public void accessOldVersions() throws Exception { final URI newRepo = URI.create("git://old-versions-test-repo"); final FileSystem fs = provider.newFileSystem(newRepo, new HashMap<String, Object>() {{ put(JGitFileSystemProviderConfiguration.GIT_ENV_KEY_INIT, "true"); }}); assertThat(fs).isNotNull(); for (int i = 0; i < 5; i++) { final Path path = provider.getPath(URI.create("git://old-versions-test-repo/some/path/myfile.txt")); final OutputStream outStream = provider.newOutputStream(path); assertThat(outStream).isNotNull(); outStream.write(("my cool content" + i).getBytes()); outStream.close(); } final Path path = provider.getPath(URI.create("git://old-versions-test-repo/some/path/myfile.txt")); final JGitVersionAttributeView attrs = provider.getFileAttributeView(path, JGitVersionAttributeView.class); assertThat(attrs.readAttributes().history().records().size()).isEqualTo(5); for (int i = 0; i < 5; i++) { final Path oldPath = provider.getPath(URI.create("git://" + attrs.readAttributes().history().records().get(i).id() + "@old-versions-test-repo/some/path/myfile.txt")); final InputStream stream = provider.newInputStream(oldPath); assertNotNull(stream); final String content = new Scanner(stream).useDelimiter("\\A").next(); assertEquals("my cool content" + i, content); } }
@Test public void accessOldVersions() throws Exception { final URI newRepo = URI.create("git://old-versions-test-repo"); final FileSystem fs = provider.newFileSystem(newRepo, new HashMap<String, Object>() {{ put(JGitFileSystemProviderConfiguration.GIT_ENV_KEY_INIT, "true"); }}); assertThat(fs).isNotNull(); for (int i = 0; i < 5; i++) { final Path path = provider.getPath(URI.create("git://old-versions-test-repo/some/path/myfile.txt")); final OutputStream outStream = provider.newOutputStream(path); assertThat(outStream).isNotNull(); outStream.write(("my cool content" + i).getBytes()); outStream.close(); } final Path path = provider.getPath(URI.create("git://old-versions-test-repo/some/path/myfile.txt")); final JGitVersionAttributeView attrs = provider.getFileAttributeView(path, JGitVersionAttributeView.class); assertThat(attrs.readAttributes().history().records().size()).isEqualTo(5); for (int i = 0; i < 5; i++) { final Path oldPath = provider.getPath(URI.create("git://" + attrs.readAttributes().history().records().get(i).id() + "@old-versions-test-repo/some/path/myfile.txt")); final InputStream stream = provider.newInputStream(oldPath); assertNotNull(stream); final String content = new Scanner(stream).useDelimiter("\\A").next(); assertEquals("my cool content" + i, content); } }
JGitVersionAttributeView.class); assertThat(attrs.readAttributes().history().records().size()).isEqualTo(5);
JGitVersionAttributeView.class); assertThat(attrs.readAttributes().history().records().size()).isEqualTo(5);
JGitVersionAttributeView.class); assertThat(attrs.readAttributes().history().records().size()).isEqualTo(1); assertThat(attrs.readAttributes().history().records().get(0).uri()).isNotNull(); assertThat(attrs.readAttributes().isDirectory()).isFalse(); assertThat(attrs.readAttributes().isRegularFile()).isTrue(); assertThat(attrs.readAttributes().creationTime()).isNotNull(); assertThat(attrs.readAttributes().lastModifiedTime()).isNotNull(); assertThat(attrs.readAttributes().size()).isEqualTo(15L);
JGitVersionAttributeView.class); assertThat(attrs.readAttributes().history().records().size()).isEqualTo(1); assertThat(attrs.readAttributes().history().records().get(0).uri()).isNotNull(); assertThat(attrs.readAttributes().isDirectory()).isFalse(); assertThat(attrs.readAttributes().isRegularFile()).isTrue(); assertThat(attrs.readAttributes().creationTime()).isNotNull(); assertThat(attrs.readAttributes().lastModifiedTime()).isNotNull(); assertThat(attrs.readAttributes().size()).isEqualTo(15L);
JGitVersionAttributeView.class, options); return (A) view.readAttributes(); } else if (type == HiddenAttributes.class) { final JGitHiddenAttributeView view = getFileAttributeView(path,
when(path.getPath()).thenReturn("path/to/file2.txt"); final VersionAttributes versionAttributes = new JGitVersionAttributeView(path).readAttributes();
when(path.getPath()).thenReturn("path/to/file2.txt"); final VersionAttributes versionAttributes = new JGitVersionAttributeView(path).readAttributes();