fix: export patches not retaining CRLF line endings (#28360)

When a patch targets a file using CRLF line endings, they need to be
retained in the patch file. Otherwise the patch will fail to apply
due to being unable to find surrounding lines with matching whitespace.
This commit is contained in:
Samuel Maddock 2021-03-25 01:49:53 -04:00 committed by GitHub
parent 7918ddb026
commit b9b734c9c4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 16 deletions

View file

@ -207,7 +207,7 @@ const LINTERS = [{
console.warn(`Patch file '${f}' has no description. Every patch must contain a justification for why the patch exists and the plan for its removal.`);
return false;
}
const trailingWhitespace = patchText.split('\n').filter(line => line.startsWith('+')).some(line => /\s+$/.test(line));
const trailingWhitespace = patchText.split(/\r?\n/).some(line => line.startsWith('+') && /\s+$/.test(line));
if (trailingWhitespace) {
console.warn(`Patch file '${f}' has trailing whitespace on some lines.`);
return false;