xtask: parity --check accepts a CRLF checkout of the checklist

On Windows with Git's default `core.autocrlf=true` (Git for Windows, GitHub's
`windows-latest` image), `docs/parity-checklist.md` is checked out with CRLF line
ends. `parity --check` compared it byte for byte with the generated text (LF), so
`cargo xtask ci` stopped at `parity` with "out of date" although the file was
current. Line ends are no longer a difference; any other change still is.

Co-authored-by: CRBBeesy <CRBBeesy@users.noreply.github.com>
This commit is contained in:
Cursor AgentandCRBBeesy committed 2026-10-20 03:56:00 +00:00
1 parent 23829d8c67
commit d0033570df
1 file changed
+17 -1
+17 -1
View File
@@ -70,6 +70,12 @@ pub fn render(entries: &[Entry]) -> String {
s
}
/// Whether the checked-in checklist matches the generated text. A Windows checkout with
/// `core.autocrlf=true` (Git for Windows' default) has CRLF line ends, which aren't a change.
pub fn up_to_date(current: &str, generated: &str) -> bool {
current == generated || current.replace("\r\n", "\n") == generated
}
#[cfg(feature = "engine")]
fn entries() -> Vec<Entry> {
use gridcraft_engine::catalog::CATALOG;
@@ -106,7 +112,7 @@ pub fn run(root: &Path, args: &[&str]) -> Result<(), String> {
let text = render(&entries());
if check {
let current = std::fs::read_to_string(&out).map_err(|e| format!("{}: {e}", out.display()))?;
if current != text {
if !up_to_date(&current, &text) {
return Err(format!("{} is out of date; run `cargo xtask parity`", out.display()));
}
println!("{} ({} up to date)", summary_line(), out.display());
@@ -149,4 +155,14 @@ mod tests {
fn empty_catalog_renders() {
assert!(render(&[]).contains("0 / 0 commands implemented (0.0%)"));
}
#[test]
fn a_crlf_checkout_of_the_current_checklist_is_up_to_date() {
let text = render(&[e("file.new", "File", true), e("home.bold", "Home", false)]);
assert!(up_to_date(&text, &text));
assert!(up_to_date(&text.replace('\n', "\r\n"), &text));
let stale = render(&[e("file.new", "File", false), e("home.bold", "Home", false)]);
assert!(!up_to_date(&stale, &text));
assert!(!up_to_date(&stale.replace('\n', "\r\n"), &text));
}
}