private boolean existsBranch(final JGitPathImpl path) { return hasBranch(path.getFileSystem().gitRepo(), path.getRefTree()); }
public void close() throws java.io.IOException { super.close(); String name = null; String email = null; String message = null; TimeZone timeZone = null; Date when = null; if (options != null && options.length > 0) { for (final OpenOption option : options) { if (option instanceof JGitOp) { final JGitOp op = (JGitOp) option; name = op.name; email = op.email; message = op.message; timeZone = op.timeZone; when = op.when; break; } } } commit(gPath.getFileSystem().gitRepo(), gPath.getRefTree(), gPath.getPath(), file, name, email, message, timeZone, when); } };
@Override protected BasicFileAttributes newAttrs() { return JGitUtil.buildBasicFileAttributes(this.getFileSystem().gitRepo(), this.getRefTree(), this.getPath()); }
private void createBranch(final JGitPathImpl source, final JGitPathImpl target) { JGitUtil.createBranch(source.getFileSystem().gitRepo(), source.getRefTree(), target.getRefTree()); }
@Override public FileStore getFileStore(final Path path) throws IOException, SecurityException { checkNotNull("path", path); return new JGitFileStore(toPathImpl(path).getFileSystem().gitRepo().getRepository()); }
@Override public void createDirectory(final Path path, final FileAttribute<?>... attrs) throws UnsupportedOperationException, FileAlreadyExistsException, IOException, SecurityException { checkNotNull("path", path); final JGitPathImpl gPath = toPathImpl(path); final Pair<PathType, ObjectId> result = checkPath(gPath.getFileSystem().gitRepo(), gPath.getRefTree(), gPath.getPath()); if (!result.getK1().equals(NOT_FOUND)) { throw new FileAlreadyExistsException(path.toString()); } try { final OutputStream outputStream = newOutputStream(path.resolve(".gitignore")); outputStream.write("# empty\n".getBytes()); outputStream.close(); } catch (final Exception e) { throw new IOException(e); } }
@Override public InputStream newInputStream(final Path path, final OpenOption... options) throws IllegalArgumentException, UnsupportedOperationException, NoSuchFileException, IOException, SecurityException { checkNotNull("path", path); final JGitPathImpl gPath = toPathImpl(path); return resolveInputStream(gPath.getFileSystem().gitRepo(), gPath.getRefTree(), gPath.getPath()); }
@Override public void checkAccess(final Path path, final AccessMode... modes) throws UnsupportedOperationException, NoSuchFileException, AccessDeniedException, IOException, SecurityException { checkNotNull("path", path); final JGitPathImpl gPath = toPathImpl(path); final Pair<PathType, ObjectId> result = checkPath(gPath.getFileSystem().gitRepo(), gPath.getRefTree(), gPath.getPath()); if (result.getK1().equals(NOT_FOUND)) { throw new NoSuchFileException(path.toString()); } }
@Override public boolean isSameFile(final Path pathA, final Path pathB) throws IOException, SecurityException { checkNotNull("pathA", pathA); checkNotNull("pathB", pathB); final JGitPathImpl gPathA = toPathImpl(pathA); final JGitPathImpl gPathB = toPathImpl(pathB); final Pair<PathType, ObjectId> resultA = checkPath(gPathA.getFileSystem().gitRepo(), gPathA.getRefTree(), gPathA.getPath()); final Pair<PathType, ObjectId> resultB = checkPath(gPathB.getFileSystem().gitRepo(), gPathB.getRefTree(), gPathB.getPath()); if (resultA.getK1() == PathType.FILE && resultA.getK2().equals(resultB.getK2())) { return true; } return pathA.equals(pathB); }
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; }
final Pair<PathType, ObjectId> result = checkPath(gPath.getFileSystem().gitRepo(), gPath.getRefTree(), gPath.getPath());
private void copyDirectory(final JGitPathImpl source, final JGitPathImpl target) { final List<JGitPathImpl> directories = new ArrayList<JGitPathImpl>(); for (final Path path : newDirectoryStream(source, null)) { final JGitPathImpl gPath = toPathImpl(path); final Pair<PathType, ObjectId> pathResult = checkPath(gPath.getFileSystem().gitRepo(), gPath.getRefTree(), gPath.getPath()); if (pathResult.getK1() == DIRECTORY) { directories.add(gPath); continue; } final JGitPathImpl gTarget = composePath(target, (JGitPathImpl) gPath.getFileName()); copyFile(gPath, gTarget); } for (final JGitPathImpl directory : directories) { createDirectory(composePath(target, (JGitPathImpl) directory.getFileName())); } }
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); }
@Override public <V extends FileAttributeView> V getFileAttributeView(final Path path, final Class<V> type, final LinkOption... options) throws NoSuchFileException { checkNotNull("path", path); checkNotNull("type", type); final JGitPathImpl gPath = toPathImpl(path); final Pair<PathType, ObjectId> pathResult = checkPath(gPath.getFileSystem().gitRepo(), gPath.getRefTree(), gPath.getPath()); if (pathResult.getK1().equals(NOT_FOUND)) { throw new NoSuchFileException(path.toString()); } if (type == BasicFileAttributeView.class || type == JGitFileAttributeView.class) { return (V) new JGitFileAttributeView(gPath); } return null; }
@Override public <A extends BasicFileAttributes> A readAttributes(final Path path, final Class<A> type, final LinkOption... options) throws NoSuchFileException, UnsupportedOperationException, IOException, SecurityException { checkNotNull("path", path); checkNotNull("type", type); final JGitPathImpl gPath = toPathImpl(path); final Pair<PathType, ObjectId> pathResult = checkPath(gPath.getFileSystem().gitRepo(), gPath.getRefTree(), gPath.getPath()); if (pathResult.getK1().equals(NOT_FOUND)) { throw new NoSuchFileException(path.toString()); } if (type == BasicFileAttributes.class || type == JGitFileAttributes.class) { final JGitFileAttributeView view = getFileAttributeView(path, JGitFileAttributeView.class, options); return (A) view.readAttributes(); } return null; }
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); }
commit(origin.gitRepo(), "master", "user1",