@Override public FileSystem getFileSystem(final URI uri) throws IllegalArgumentException, FileSystemNotFoundException, SecurityException { checkNotNull("uri", uri); checkCondition("uri scheme not supported", uri.getScheme().equals(getScheme()) || uri.getScheme().equals("default")); checkURI("uri", uri); final JGitFileSystem fileSystem = fileSystems.get(extractRepoName(uri)); if (fileSystem == null) { throw new FileSystemNotFoundException(); } return fileSystem; }
throws IllegalArgumentException, IOException, SecurityException, FileSystemAlreadyExistsException { checkNotNull("uri", uri); checkCondition("uri scheme not supported", uri.getScheme().equals(getScheme()) || uri.getScheme().equals("default")); checkURI("uri", uri); checkNotNull("env", env); final URI initURI = URI.create(getScheme() + "://master@" + name + "/readme.md"); final JGitOp op = setupOp(env); final OutputStream stream = newOutputStream(getPath(initURI), op);
@Override public Path getPath(final URI uri) throws IllegalArgumentException, FileSystemNotFoundException, SecurityException { checkNotNull("uri", uri); checkCondition("uri scheme not supported", uri.getScheme().equals(getScheme()) || uri.getScheme().equals("default")); checkURI("uri", uri); if (LOG.isDebugEnabled()) { LOG.debug("Accessing uri " + uri.toString()); } Path path; JGitFileSystem fileSystem = deepLookupFSFrom(uri); String branch = extractBranchFrom(uri); String host = buildHostFrom(fileSystem, branch); String pathStr = buildPathFrom(uri, host); path = JGitPathImpl.create(fileSystem, pathStr, host, false); return path; }
@Override public Path getPath(final URI uri) throws IllegalArgumentException, FileSystemNotFoundException, SecurityException { checkNotNull("uri", uri); checkCondition("uri scheme not supported", uri.getScheme().equals(getScheme()) || uri.getScheme().equals("default")); checkURI("uri", uri); final JGitFileSystem fileSystem = fileSystems.get(extractRepoName(uri)); if (fileSystem == null) { throw new FileSystemNotFoundException(); } try { return JGitPathImpl.create(fileSystem, URIUtil.decode(extractPath(uri)), extractHost(uri), false); } catch (final URIException e) { return null; } }
uri); checkCondition("uri scheme not supported", uri.getScheme().equals(getScheme()) || uri.getScheme().equals("default")); checkURI("uri", uri); final URI initURI = URI.create(getScheme() + "://master@" + fsName + "/readme.md"); final OutputStream stream = newOutputStream(getPath(initURI), (CommentedOption) null);
@Test public void testPathBranchRooted() throws IOException, GitAPIException { final JGitFileSystemProvider fsProvider = mock(JGitFileSystemProvider.class); when(fsProvider.isDefault()).thenReturn(false); when(fsProvider.getScheme()).thenReturn("git"); final Git git = setupGit(); final JGitFileSystemImpl fileSystem = new JGitFileSystemImpl(fsProvider, null, git, createFSLock(git), "my-repo", CredentialsProvider.getDefault(), null, null); final Path path = fileSystem.getPath("test-branch", "/path/to/some/place.txt"); AssertionsForClassTypes.assertThat(path).isNotNull(); assertThat(path.isAbsolute()).isTrue(); assertThat(path.toString()).isEqualTo("/path/to/some/place.txt"); assertThat(path.toUri().toString()).isEqualTo("git://test-branch@my-repo/path/to/some/place.txt"); assertThat(path.getNameCount()).isEqualTo(4); assertThat(path.getName(0).toString()).isNotNull().isEqualTo("path"); assertThat(path.getRoot().toString()).isNotNull().isEqualTo("/"); }
@Test public void testPathNonBranchRooted() throws IOException, GitAPIException { final JGitFileSystemProvider fsProvider = mock(JGitFileSystemProvider.class); when(fsProvider.isDefault()).thenReturn(false); when(fsProvider.getScheme()).thenReturn("git"); final Git git = setupGit(); final JGitFileSystemImpl fileSystem = new JGitFileSystemImpl(fsProvider, null, git, createFSLock(git), "my-repo", CredentialsProvider.getDefault(), null, null); final Path path = fileSystem.getPath("/path/to/some/place.txt"); AssertionsForClassTypes.assertThat(path).isNotNull(); assertThat(path.isAbsolute()).isTrue(); assertThat(path.toString()).isEqualTo("/path/to/some/place.txt"); assertThat(path.toUri().toString()).isEqualTo("git://master@my-repo/path/to/some/place.txt"); assertThat(path.getNameCount()).isEqualTo(4); assertThat(path.getName(0).toString()).isNotNull().isEqualTo("path"); assertThat(path.getRoot().toString()).isNotNull().isEqualTo("/"); }
@Test public void testPathNonBranchNonRooted() throws IOException, GitAPIException { final JGitFileSystemProvider fsProvider = mock(JGitFileSystemProvider.class); when(fsProvider.isDefault()).thenReturn(false); when(fsProvider.getScheme()).thenReturn("git"); final Git git = setupGit(); final JGitFileSystemImpl fileSystem = new JGitFileSystemImpl(fsProvider, null, git, createFSLock(git), "my-repo", CredentialsProvider.getDefault(), null, null); final Path path = fileSystem.getPath("path/to/some/place.txt"); AssertionsForClassTypes.assertThat(path).isNotNull(); assertThat(path.isAbsolute()).isFalse(); assertThat(path.toString()).isEqualTo("path/to/some/place.txt"); assertThat(path.toUri().toString()).isEqualTo("git://master@my-repo/:path/to/some/place.txt"); assertThat(path.getNameCount()).isEqualTo(4); assertThat(path.getName(0).toString()).isNotNull().isEqualTo("path"); assertThat(path.getRoot().toString()).isNotNull().isEqualTo(""); }
@Test public void testPathBranchNonRooted() throws IOException, GitAPIException { final JGitFileSystemProvider fsProvider = mock(JGitFileSystemProvider.class); when(fsProvider.isDefault()).thenReturn(false); when(fsProvider.getScheme()).thenReturn("git"); final Git git = setupGit(); final JGitFileSystemImpl fileSystem = new JGitFileSystemImpl(fsProvider, null, git, createFSLock(git), "my-repo", CredentialsProvider.getDefault(), null, null); final Path path = fileSystem.getPath("test-branch", "path/to/some/place.txt"); AssertionsForClassTypes.assertThat(path).isNotNull(); assertThat(path.isAbsolute()).isFalse(); assertThat(path.toString()).isEqualTo("path/to/some/place.txt"); assertThat(path.toUri().toString()).isEqualTo("git://test-branch@my-repo/:path/to/some/place.txt"); assertThat(path.getNameCount()).isEqualTo(4); assertThat(path.getName(0).toString()).isNotNull().isEqualTo("path"); assertThat(path.getRoot().toString()).isNotNull().isEqualTo(""); }
@Test public void testPathBranchNonRooted2() throws IOException, GitAPIException { final JGitFileSystemProvider fsProvider = mock(JGitFileSystemProvider.class); when(fsProvider.isDefault()).thenReturn(false); when(fsProvider.getScheme()).thenReturn("git"); final Git git = setupGit(); final JGitFileSystemImpl fileSystem = new JGitFileSystemImpl(fsProvider, null, git, createFSLock(git), "my-repo", CredentialsProvider.getDefault(), null, null); final Path path = fileSystem.getPath("test-branch", "path/to", "some/place.txt"); AssertionsForClassTypes.assertThat(path).isNotNull(); assertThat(path.isAbsolute()).isFalse(); assertThat(path.toString()).isEqualTo("path/to/some/place.txt"); assertThat(path.toUri().toString()).isEqualTo("git://test-branch@my-repo/:path/to/some/place.txt"); assertThat(path.getNameCount()).isEqualTo(4); assertThat(path.getName(0).toString()).isNotNull().isEqualTo("path"); assertThat(path.getRoot().toString()).isNotNull().isEqualTo(""); }
@Test public void testPathNonBranchRooted() throws IOException, GitAPIException { final JGitFileSystemProvider fsProvider = mock(JGitFileSystemProvider.class); when(fsProvider.isDefault()).thenReturn(false); when(fsProvider.getScheme()).thenReturn("git"); final Git git = setupGit(); final JGitFileSystemImpl fileSystem = new JGitFileSystemImpl(fsProvider, null, git, createFSLock(git), "my-repo", CredentialsProvider.getDefault(), null, null); final Path path = fileSystem.getPath("/path/to/some/place.txt"); AssertionsForClassTypes.assertThat(path).isNotNull(); assertThat(path.isAbsolute()).isTrue(); assertThat(path.toString()).isEqualTo("/path/to/some/place.txt"); assertThat(path.toUri().toString()).isEqualTo("git://master@my-repo/path/to/some/place.txt"); assertThat(path.getNameCount()).isEqualTo(4); assertThat(path.getName(0).toString()).isNotNull().isEqualTo("path"); assertThat(path.getRoot().toString()).isNotNull().isEqualTo("/"); }
@Test public void testPathBranchRooted() throws IOException, GitAPIException { final JGitFileSystemProvider fsProvider = mock(JGitFileSystemProvider.class); when(fsProvider.isDefault()).thenReturn(false); when(fsProvider.getScheme()).thenReturn("git"); final Git git = setupGit(); final JGitFileSystemImpl fileSystem = new JGitFileSystemImpl(fsProvider, null, git, createFSLock(git), "my-repo", CredentialsProvider.getDefault(), null, null); final Path path = fileSystem.getPath("test-branch", "/path/to/some/place.txt"); AssertionsForClassTypes.assertThat(path).isNotNull(); assertThat(path.isAbsolute()).isTrue(); assertThat(path.toString()).isEqualTo("/path/to/some/place.txt"); assertThat(path.toUri().toString()).isEqualTo("git://test-branch@my-repo/path/to/some/place.txt"); assertThat(path.getNameCount()).isEqualTo(4); assertThat(path.getName(0).toString()).isNotNull().isEqualTo("path"); assertThat(path.getRoot().toString()).isNotNull().isEqualTo("/"); }
@Test public void testPathBranchNonRooted() throws IOException, GitAPIException { final JGitFileSystemProvider fsProvider = mock(JGitFileSystemProvider.class); when(fsProvider.isDefault()).thenReturn(false); when(fsProvider.getScheme()).thenReturn("git"); final Git git = setupGit(); final JGitFileSystemImpl fileSystem = new JGitFileSystemImpl(fsProvider, null, git, createFSLock(git), "my-repo", CredentialsProvider.getDefault(), null, null); final Path path = fileSystem.getPath("test-branch", "path/to/some/place.txt"); AssertionsForClassTypes.assertThat(path).isNotNull(); assertThat(path.isAbsolute()).isFalse(); assertThat(path.toString()).isEqualTo("path/to/some/place.txt"); assertThat(path.toUri().toString()).isEqualTo("git://test-branch@my-repo/:path/to/some/place.txt"); assertThat(path.getNameCount()).isEqualTo(4); assertThat(path.getName(0).toString()).isNotNull().isEqualTo("path"); assertThat(path.getRoot().toString()).isNotNull().isEqualTo(""); }
@Test public void testPathNonBranchNonRooted() throws IOException, GitAPIException { final JGitFileSystemProvider fsProvider = mock(JGitFileSystemProvider.class); when(fsProvider.isDefault()).thenReturn(false); when(fsProvider.getScheme()).thenReturn("git"); final Git git = setupGit(); final JGitFileSystemImpl fileSystem = new JGitFileSystemImpl(fsProvider, null, git, createFSLock(git), "my-repo", CredentialsProvider.getDefault(), null, null); final Path path = fileSystem.getPath("path/to/some/place.txt"); AssertionsForClassTypes.assertThat(path).isNotNull(); assertThat(path.isAbsolute()).isFalse(); assertThat(path.toString()).isEqualTo("path/to/some/place.txt"); assertThat(path.toUri().toString()).isEqualTo("git://master@my-repo/:path/to/some/place.txt"); assertThat(path.getNameCount()).isEqualTo(4); assertThat(path.getName(0).toString()).isNotNull().isEqualTo("path"); assertThat(path.getRoot().toString()).isNotNull().isEqualTo(""); }
@Test public void testPathBranchRooted2() throws IOException, GitAPIException { final JGitFileSystemProvider fsProvider = mock(JGitFileSystemProvider.class); when(fsProvider.isDefault()).thenReturn(false); when(fsProvider.getScheme()).thenReturn("git"); final Git git = setupGit(); final JGitFileSystemImpl fileSystem = new JGitFileSystemImpl(fsProvider, null, git, createFSLock(git), "my-repo", CredentialsProvider.getDefault(), null, null); final Path path = fileSystem.getPath("test-branch", "/path/to", "some/place.txt"); AssertionsForClassTypes.assertThat(path).isNotNull(); assertThat(path.isAbsolute()).isTrue(); assertThat(path.toString()).isEqualTo("/path/to/some/place.txt"); assertThat(path.toUri().toString()).isEqualTo("git://test-branch@my-repo/path/to/some/place.txt"); assertThat(path.getNameCount()).isEqualTo(4); assertThat(path.getName(0).toString()).isNotNull().isEqualTo("path"); assertThat(path.getRoot().toString()).isNotNull().isEqualTo("/"); }
@Test public void testPathBranchNonRooted2() throws IOException, GitAPIException { final JGitFileSystemProvider fsProvider = mock(JGitFileSystemProvider.class); when(fsProvider.isDefault()).thenReturn(false); when(fsProvider.getScheme()).thenReturn("git"); final Git git = setupGit(); final JGitFileSystemImpl fileSystem = new JGitFileSystemImpl(fsProvider, null, git, createFSLock(git), "my-repo", CredentialsProvider.getDefault(), null, null); final Path path = fileSystem.getPath("test-branch", "path/to", "some/place.txt"); AssertionsForClassTypes.assertThat(path).isNotNull(); assertThat(path.isAbsolute()).isFalse(); assertThat(path.toString()).isEqualTo("path/to/some/place.txt"); assertThat(path.toUri().toString()).isEqualTo("git://test-branch@my-repo/:path/to/some/place.txt"); assertThat(path.getNameCount()).isEqualTo(4); assertThat(path.getName(0).toString()).isNotNull().isEqualTo("path"); assertThat(path.getRoot().toString()).isNotNull().isEqualTo(""); }
@Test public void testPathBranchRooted2() throws IOException, GitAPIException { final JGitFileSystemProvider fsProvider = mock(JGitFileSystemProvider.class); when(fsProvider.isDefault()).thenReturn(false); when(fsProvider.getScheme()).thenReturn("git"); final Git git = setupGit(); final JGitFileSystemImpl fileSystem = new JGitFileSystemImpl(fsProvider, null, git, createFSLock(git), "my-repo", CredentialsProvider.getDefault(), null, null); final Path path = fileSystem.getPath("test-branch", "/path/to", "some/place.txt"); AssertionsForClassTypes.assertThat(path).isNotNull(); assertThat(path.isAbsolute()).isTrue(); assertThat(path.toString()).isEqualTo("/path/to/some/place.txt"); assertThat(path.toUri().toString()).isEqualTo("git://test-branch@my-repo/path/to/some/place.txt"); assertThat(path.getNameCount()).isEqualTo(4); assertThat(path.getName(0).toString()).isNotNull().isEqualTo("path"); assertThat(path.getRoot().toString()).isNotNull().isEqualTo("/"); }
uri); checkCondition("uri scheme not supported", uri.getScheme().equals(getScheme()) || uri.getScheme().equals("default")); checkURI("uri", uri);