if (!contains(options, StandardCopyOption.REPLACE_EXISTING)) { throw new FileAlreadyExistsException(target.toString());
if (!contains(options, StandardCopyOption.REPLACE_EXISTING)) { throw new FileAlreadyExistsException(target.toString());
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())); } }
private void copyAssetContent(final JGitPathImpl source, final JGitPathImpl target, final CopyOption... options) { final PathInfo sourceResult = source.getFileSystem().getGit().getPathInfo(source.getRefTree(), source.getPath()); final PathInfo targetResult = target.getFileSystem().getGit().getPathInfo(target.getRefTree(), target.getPath()); if (!isRoot(target) && targetResult.getPathType() != NOT_FOUND) { if (!contains(options, StandardCopyOption.REPLACE_EXISTING)) { throw new FileAlreadyExistsException(target.toString()); } } if (sourceResult.getPathType() == NOT_FOUND) { throw new NoSuchFileException(target.toString()); } if (sourceResult.getPathType() == DIRECTORY) { copyDirectory(source, target, options); return; } copyFile(source, target, options); }