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; }
assertNotNull(git.listPathContent("master", "path/to/")); assertNotNull(git.listPathContent("master", "path/to/")); assertNotNull(git.listPathContent("master", "path/to/")); assertNotNull(git.listPathContent("master", "path/to/")); } catch (Exception ex) { assertNotNull(git.listPathContent("master", "path/to/")); fail("forced to fail!");
assertNotNull(git.listPathContent("master", "path/to/")); assertNotNull(git.listPathContent("master", "path/to/")); assertNotNull(git.listPathContent("master", "path/to/")); assertNotNull(git.listPathContent("master", "path/to/")); } catch (Exception ex) { assertNotNull(git.listPathContent("master", "path/to/")); fail("forced to fail!");
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); }
final List<PathInfo> pathContent = gPath.getFileSystem().getGit().listPathContent(gPath.getRefTree(), gPath.getPath());