private JGitPathImpl composePath(final JGitPathImpl directory, final JGitPathImpl fileName) { if (directory.getPath().endsWith("/")) { return toPathImpl(getPath(URI.create(directory.toUri().toString() + fileName.toString(false)))); } return toPathImpl(getPath(URI.create(directory.toUri().toString() + "/" + fileName.toString(false)))); }
private JGitPathImpl composePath(final JGitPathImpl directory, final JGitPathImpl fileName, final CopyOption... options) { if (directory.getPath().endsWith("/")) { return toPathImpl(getPath(URI.create(directory.toUri().toString() + uriEncode(fileName.toString(false))))); } return toPathImpl(getPath(URI.create(directory.toUri().toString() + "/" + uriEncode(fileName.toString(false))))); }
private void copyBranch(final JGitPathImpl source, final JGitPathImpl target) { checkCondition("source and target should have same file system", hasSameFileSystem(source, target)); if (existsBranch(target)) { throw new FileAlreadyExistsException(target.toString()); } if (!existsBranch(source)) { throw new NoSuchFileException(target.toString()); } createBranch(source, target); }
@Override public boolean isHidden(final Path path) throws IllegalArgumentException, IOException, SecurityException { checkNotNull("path", path); final JGitPathImpl gPath = toPathImpl(path); if (gPath.getFileName() == null) { return false; } return toPathImpl(path.getFileName()).toString(false).startsWith("."); }
private void copyBranch(final JGitPathImpl source, final JGitPathImpl target) { checkCondition("source and taget should have same setup", !hasSameFileSystem(source, target)); if (existsBranch(target)) { throw new FileAlreadyExistsException(target.toString()); } if (!existsBranch(source)) { throw new NoSuchFileException(target.toString()); } createBranch(source, target); }
@Override public boolean isHidden(final Path path) throws IllegalArgumentException, IOException, SecurityException { checkNotNull("path", path); final JGitPathImpl gPath = toPathImpl(path); if (gPath.getFileName() == null) { return false; } return toPathImpl(path.getFileName()).toString(false).startsWith("."); }
public void deleteBranch(final JGitPathImpl path) { final Ref branch = getBranch(path.getFileSystem().gitRepo(), path.getRefTree()); if (branch == null) { throw new NoSuchFileException(path.toString()); } JGitUtil.deleteBranch(path.getFileSystem().gitRepo(), branch); }
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())); } }
public void deleteAsset(final JGitPathImpl path) { final Pair<PathType, ObjectId> result = checkPath(path.getFileSystem().gitRepo(), path.getRefTree(), path.getPath()); if (result.getK1().equals(PathType.DIRECTORY)) { throw new DirectoryNotEmptyException(path.toString()); } if (result.getK1().equals(NOT_FOUND)) { throw new NoSuchFileException(path.toString()); } JGitUtil.delete(path.getFileSystem().gitRepo(), path.getRefTree(), path.getPath(), null, null, "delete {" + path.getPath() + "}", null, null); }
public void deleteAsset(final JGitPathImpl path, final DeleteOption... options) { final PathInfo result = path.getFileSystem().getGit().getPathInfo(path.getRefTree(), path.getPath()); if (result.getPathType().equals(PathType.DIRECTORY)) { if (deleteNonEmptyDirectory(options)) { deleteResource(path, options); return; } final List<PathInfo> content = path.getFileSystem().getGit().listPathContent(path.getRefTree(), path.getPath()); if (content.size() == 1 && content.get(0).getPath().equals(path.getPath().substring(1) + "/.gitkeep")) { delete(path.resolve(".gitkeep")); deleteResource(path, options); return; } throw new DirectoryNotEmptyException(path.toString()); } if (result.getPathType().equals(NOT_FOUND)) { throw new NoSuchFileException(path.toString()); } deleteResource(path, options); }
private void copyAsset(final JGitPathImpl source, final JGitPathImpl target) { final Pair<PathType, ObjectId> sourceResult = checkPath(source.getFileSystem().gitRepo(), source.getRefTree(), source.getPath()); final Pair<PathType, ObjectId> targetResult = checkPath(target.getFileSystem().gitRepo(), target.getRefTree(), target.getPath()); if (!isRoot(target) && targetResult.getK1() != NOT_FOUND) { throw new FileAlreadyExistsException(target.toString()); } if (sourceResult.getK1() == NOT_FOUND) { throw new NoSuchFileException(target.toString()); } if (sourceResult.getK1() == DIRECTORY) { copyDirectory(source, target); return; } copyFile(source, target); }
public boolean deleteAssetIfExists(final JGitPathImpl path, final DeleteOption... options) { final PathInfo result = path.getFileSystem().getGit().getPathInfo(path.getRefTree(), path.getPath()); if (result.getPathType().equals(PathType.DIRECTORY)) { if (deleteNonEmptyDirectory(options)) { deleteResource(path, options); return true; } final List<PathInfo> content = path.getFileSystem().getGit().listPathContent(path.getRefTree(), path.getPath()); if (content.size() == 1 && content.get(0).getPath().equals(path.getPath().substring(1) + "/.gitkeep")) { delete(path.resolve(".gitkeep")); return true; } throw new DirectoryNotEmptyException(path.toString()); } if (result.getPathType().equals(NOT_FOUND)) { return false; } deleteResource(path, options); return true; }
public void deleteBranch(final JGitPathImpl path) { final Ref branch = path.getFileSystem().getGit().getRef(path.getRefTree()); if (branch == null) { throw new NoSuchFileException(path.toString()); } try { path.getFileSystem().lock(); path.getFileSystem().getGit().deleteRef(branch); } finally { path.getFileSystem().unlock(); } }
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); }
public boolean deleteAssetIfExists(final JGitPathImpl path) { final Pair<PathType, ObjectId> result = checkPath(path.getFileSystem().gitRepo(), path.getRefTree(), path.getPath()); if (result.getK1().equals(PathType.DIRECTORY)) { throw new DirectoryNotEmptyException(path.toString()); } if (result.getK1().equals(NOT_FOUND)) { return false; } JGitUtil.delete(path.getFileSystem().gitRepo(), path.getRefTree(), path.getPath(), null, null, "delete {" + path.getPath() + "}", null, null); return true; }