private JGitPathImpl composePath( final JGitPathImpl directory, final JGitPathImpl fileName, final CopyOption... options ) { 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 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 deleteAsset( final JGitPathImpl path, final DeleteOption... options ) { final Pair<PathType, ObjectId> result = checkPath( path.getFileSystem().gitRepo(), path.getRefTree(), path.getPath() ); if ( result.getK1().equals( PathType.DIRECTORY ) ) { if ( deleteNonEmptyDirectory( options ) ) { deleteResource( path, options ); return; } final List<JGitPathInfo> content = listPathContent( path.getFileSystem().gitRepo(), path.getRefTree(), path.getPath() ); if ( content.size() == 1 && content.get( 0 ).getPath().equals( path.getPath().substring( 1 ) + "/.gitignore" ) ) { delete( path.resolve( ".gitignore" ) ); deleteResource( path, options ); return; } throw new DirectoryNotEmptyException( path.toString() ); } if ( result.getK1().equals( NOT_FOUND ) ) { throw new NoSuchFileException( path.toString() ); } deleteResource( path, options ); }
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 ); }
public boolean deleteAssetIfExists( final JGitPathImpl path, final DeleteOption... options ) { final Pair<PathType, ObjectId> result = checkPath( path.getFileSystem().gitRepo(), path.getRefTree(), path.getPath() ); if ( result.getK1().equals( PathType.DIRECTORY ) ) { if ( deleteNonEmptyDirectory( options ) ) { deleteResource( path, options ); return true; } final List<JGitPathInfo> content = listPathContent( path.getFileSystem().gitRepo(), path.getRefTree(), path.getPath() ); if ( content.size() == 1 && content.get( 0 ).getPath().equals( path.getPath().substring( 1 ) + "/.gitignore" ) ) { delete( path.resolve( ".gitignore" ) ); return true; } throw new DirectoryNotEmptyException( path.toString() ); } if ( result.getK1().equals( NOT_FOUND ) ) { return false; } deleteResource( path, options ); return true; }
private void copyAsset( final JGitPathImpl source, final JGitPathImpl target, final CopyOption... options ) { 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 ) { if ( !contains( options, StandardCopyOption.REPLACE_EXISTING ) ) { throw new FileAlreadyExistsException( target.toString() ); } } if ( sourceResult.getK1() == NOT_FOUND ) { throw new NoSuchFileException( target.toString() ); } if ( sourceResult.getK1() == DIRECTORY ) { copyDirectory( source, target, options ); return; } copyFile( source, target, options ); }