private void moveBranch(final JGitPathImpl source, final JGitPathImpl target, final CopyOption... options) { checkCondition("source and target should have same file system", hasSameFileSystem(source, target)); if (!exists(source)) { throw new NoSuchFileException(target.toString()); } boolean targetExists = existsBranch(target); if (targetExists && !contains(options, StandardCopyOption.REPLACE_EXISTING)) { throw new FileAlreadyExistsException(target.toString()); } if (!targetExists) { createBranch(source, target); deleteBranch(source); } else { commit(target, buildCommitInfo("reverting from {" + source.getPath() + "}", Arrays.asList(options)), new RevertCommitContent(source.getRefTree())); } }
final JGitPathImpl gPath = toPathImpl(path); if (exists(path)) { if (!shouldCreateOrOpenAByteChannel(options)) { throw new FileAlreadyExistsException(path.toString());
assertThat(provider.exists(dir)).isEqualTo(false);
assertThat(provider.exists(dir)).isEqualTo(false);
@Test public void testCreateDirectory() { final URI newRepo = URI.create("git://xcreatedir-test-repo"); provider.newFileSystem(newRepo, EMPTY_ENV); final JGitPathImpl path = (JGitPathImpl) provider.getPath(URI.create("git://master@xcreatedir-test-repo/some/path/to/")); final PathInfo result = path.getFileSystem().getGit().getPathInfo(path.getRefTree(), path.getPath()); assertThat(result.getPathType()).isEqualTo(PathType.NOT_FOUND); provider.createDirectory(path); final PathInfo resultAfter = path.getFileSystem().getGit().getPathInfo(path.getRefTree(), path.getPath()); assertThat(resultAfter.getPathType()).isEqualTo(PathType.DIRECTORY); final Path gitkeepPath = path.resolve(".gitkeep"); assertThat(provider.exists(gitkeepPath)).isEqualTo(true); try { provider.createDirectory(path); failBecauseExceptionWasNotThrown(FileAlreadyExistsException.class); } catch (FileAlreadyExistsException ignored) { } }
@Test public void testCreateDirectory() { final URI newRepo = URI.create("git://xcreatedir-test-repo"); provider.newFileSystem(newRepo, EMPTY_ENV); final JGitPathImpl path = (JGitPathImpl) provider.getPath(URI.create("git://master@xcreatedir-test-repo/some/path/to/")); final PathInfo result = path.getFileSystem().getGit().getPathInfo(path.getRefTree(), path.getPath()); assertThat(result.getPathType()).isEqualTo(PathType.NOT_FOUND); provider.createDirectory(path); final PathInfo resultAfter = path.getFileSystem().getGit().getPathInfo(path.getRefTree(), path.getPath()); assertThat(resultAfter.getPathType()).isEqualTo(PathType.DIRECTORY); final Path gitkeepPath = path.resolve(".gitkeep"); assertThat(provider.exists(gitkeepPath)).isEqualTo(true); try { provider.createDirectory(path); failBecauseExceptionWasNotThrown(FileAlreadyExistsException.class); } catch (FileAlreadyExistsException ignored) { } }