git丢弃EOL差异

function discardGitEOL()
{
    const execSync = require('child_process').execSync;

    let options = {encoding: "utf8"};

    let git = "\"C:/Program Files (x86)/SmartGit/git/bin/git.exe\"";

    let stdout = execSync(`${git} status --short`, options);

    stdout = stdout.split("\n");

    for(let i = 0; i < stdout.length;i++)
    {
        let status = stdout[i].substring(1, 2);
        let filename = stdout[i].substring(3);

        if(status != "M")
            continue;

        console.log(`git diff ${filename}`);

        let diff = execSync(`${git} diff ${filename}`, options);

        if(diff == "")
        {
            console.log(`git checkout -- ${filename}`);
            execSync(`${git} checkout -- ${filename}`, options);
        }
    }
}

你可能感兴趣的:(git丢弃EOL差异)