return new JGitPathInfo( null, "/", TREE ); if ( tw.getPathString().equals( gitPath ) ) { if ( tw.getFileMode( 0 ).equals( TREE ) ) { return new JGitPathInfo( tw.getObjectId( 0 ), tw.getPathString(), TREE ); } else if ( tw.getFileMode( 0 ).equals( REGULAR_FILE ) || tw.getFileMode( 0 ).equals( EXECUTABLE_FILE ) ) { final long size = tw.getObjectReader().getObjectSize( tw.getObjectId( 0 ), OBJ_BLOB ); return new JGitPathInfo( tw.getObjectId( 0 ), tw.getPathString(), REGULAR_FILE, size );
if ( !diffEntry.getNewPath().equals( DiffEntry.DEV_NULL ) ) { JGitPathInfo pathInfo = resolvePath( fs.gitRepo(), tree, diffEntry.getNewPath() ); newPath = JGitPathImpl.create( fs, "/" + pathInfo.getPath(), host, pathInfo.getObjectId(), false ); } else { newPath = null;
result.add( new JGitPathInfo( tw.getObjectId( 0 ), tw.getPathString(), tw.getFileMode( 0 ) ) );
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 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; }
@Override public boolean isDirectory() { return pathInfo.getPathType().equals( PathType.DIRECTORY ); }
@Override public long size() { return pathInfo.getSize(); }
@Override public boolean isRegularFile() { return pathInfo.getPathType().equals( PathType.FILE ); }
@Override public Object fileKey() { return pathInfo.getObjectId() == null ? null : pathInfo.getObjectId().toString(); } };