src/utils/file.js
function stat(repoState, filepath) {
    const workingState = repoState.getCurrentState();

    // Lookup potential changes
    const change = workingState.getChanges().get(filepath);
    // Lookup file entry
    const treeEntry = workingState.getTreeEntries().get(filepath);

    // Determine SHA of the blob
    let blobSHA;
    if (change) {
        blobSHA = change.getSha();
    } else {
        blobSHA = treeEntry.getSha();
    }

    // Get the blob from change or cache
    let blob;
    if (blobSHA) {
        // Get content from cache
        blob = repoState.getCache().getBlob(blobSHA);
    } else {
        // No sha, so it must be in changes
        blob = change.getContent();
    }

    let fileSize;
    if (blob) {
        fileSize = blob.getByteLength();
    } else {
        // It might have been moved (but not fetched)
        const originalEntry = workingState.getTreeEntries().find((entry) => {
            return entry.getSha() === blobSHA;
        });
        fileSize = originalEntry.getBlobSize();
    }

    return new File({
        type: FILETYPE.FILE,
        fileSize,
        path: filepath,
        content: blob
    });
}
function stat(repoState, filepath) {
    const workingState = repoState.getCurrentState();

    // Lookup potential changes
    const change = workingState.getChanges().get(filepath);
    // Lookup file entry
    const treeEntry = workingState.getTreeEntries().get(filepath);

    // Determine SHA of the blob
    let blobSHA;
    if (change) {
        blobSHA = change.getSha();
    } else {
        blobSHA = treeEntry.getSha();
    }

    // Get the blob from change or cache
    let blob;
    if (blobSHA) {
        // Get content from cache
        blob = repoState.getCache().getBlob(blobSHA);
    } else {
        // No sha, so it must be in changes
        blob = change.getContent();
    }

    let fileSize;
    if (blob) {
        fileSize = blob.getByteLength();
    } else {
        // It might have been moved (but not fetched)
        const originalEntry = workingState.getTreeEntries().find((entry) => {
            return entry.getSha() === blobSHA;
        });
        fileSize = originalEntry.getBlobSize();
    }

    return new File({
        type: FILETYPE.FILE,
        fileSize,
        path: filepath,
        content: blob
    });
}
Stat details about a file.
@param {RepositoryState} repoState
@param {Path} filepath
@return {File}