async function getNewFileContent()

in pull-request-evaluator/lib/github-client/pr.js [144:169]


async function getNewFileContent(owner, repo, file, diffsha) {

    let newContent = "";

    try {
        const contents = await githubClient.repos.getContent({
            owner: owner,
            repo: repo,
            path: file.filename,
            ref: diffsha
        });
        if (contents.data != null) {
            if (!Array.isArray(contents.data)) {
                if (contents.data.type === 'file' && contents.data.content != null) {
                    newContent = Buffer.from(contents.data.content, 'base64').toString();
                }
            }
        }
    } catch (err) {
        console.log(err);
        return "";
    }

    return newContent;

}