src/utils/directory.js
function read(repoState, dirName) {
    dirName = PathUtils.norm(dirName);

    const workingState = repoState.getCurrentState();
    const changes = workingState.getChanges();
    const treeEntries = WorkingUtils.getMergedTreeEntries(workingState);

    const files = [];

    treeEntries.forEach((treeEntry, filepath) => {
        // Ignore git submodules
        if (treeEntry.getType() !== TreeEntry.TYPES.BLOB) return;
        if (!PathUtils.contains(dirName, filepath)) return;

        const innerPath = PathUtils.norm(filepath.replace(dirName, ''));
        const isDirectory = innerPath.indexOf('/') >= 0;
        // Make it shallow
        const name = innerPath.split('/')[0];

        const file = new File({
            path: Path.join(dirName, name),
            type: isDirectory ? FILETYPE.DIRECTORY : FILETYPE.FILE,
            change: changes.get(filepath),
            fileSize: treeEntry.blobSize
        });

        files.push(file);
    });

    // Remove duplicate from entries within directories
    return uniqueBy(files, (file) => {
        return file.getName();
    });
}
function read(repoState, dirName) {
    dirName = PathUtils.norm(dirName);

    const workingState = repoState.getCurrentState();
    const changes = workingState.getChanges();
    const treeEntries = WorkingUtils.getMergedTreeEntries(workingState);

    const files = [];

    treeEntries.forEach((treeEntry, filepath) => {
        // Ignore git submodules
        if (treeEntry.getType() !== TreeEntry.TYPES.BLOB) return;
        if (!PathUtils.contains(dirName, filepath)) return;

        const innerPath = PathUtils.norm(filepath.replace(dirName, ''));
        const isDirectory = innerPath.indexOf('/') >= 0;
        // Make it shallow
        const name = innerPath.split('/')[0];

        const file = new File({
            path: Path.join(dirName, name),
            type: isDirectory ? FILETYPE.DIRECTORY : FILETYPE.FILE,
            change: changes.get(filepath),
            fileSize: treeEntry.blobSize
        });

        files.push(file);
    });

    // Remove duplicate from entries within directories
    return uniqueBy(files, (file) => {
        return file.getName();
    });
}
List files in a directory (shallow)
@param {RepositoryState} repoState
@param {Path} dirName
@return {Array<File>}