Repository navigation
feat(lint): fail on text files committed with CRLF line endings - #581
DevSecNinja wants to merge 4 commits into
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 43 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
There was a problem hiding this comment.
🟡 Changes recommended
The linter can falsely pass when git ls-files fails and strips leading or trailing tabs from filenames, causing annotations to target incorrect paths.
2 open issues
What changed in this PR
Adds a CRLF check to the shared lint workflows, complementing the .gitattributes bootstrap in #579 and addressing #580.
Changes:
- Detects committed CRLF or mixed line endings using Git’s index metadata, respecting
-textexceptions. - Adds the check to both job modes with blocking and warning-only options.
- Extends tests and documents configuration and normalization guidance.
Verification used static inspection and isolated shell checks. Repository tests and linters were not run because repository execution was not authorized.
| File | Description |
|---|---|
workflow-templates/lint.yml |
Adds commented configuration examples and release guidance. |
tests/lint-scripts.sh |
Covers detection, exceptions, escaping, and blocking options. |
tests/lint-job-modes-contract.sh |
Includes line endings in the job-mode contract. |
tests/lint-include.py |
Classifies the blocking input as an option. |
scripts/lint/line-endings.sh |
Implements detection and workflow annotations. |
docs/architecture.md |
Documents behavior, inputs, and remediation. |
config-sync/templates/README.md |
Connects normalization guidance to the new check. |
config-sync/templates/.gitattributes |
Adds comments describing lint enforcement. |
.github/workflows/lint.yml |
Enables the check by default in both job modes. |
.github/workflows/lint-include.yml |
Exposes and forwards opt-in configuration. |
Review effort: Balanced
Split each git ls-files record at its first tab only, so paths keep their own tabs, and scan into a file so a failing git ls-files stops the linter instead of reporting no CRLF (Copilot review on #581). Carries the eol reset fix of the lower PR. Refs #580 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…-all A dangling .gitattributes symlink counts as existing, so the template isn't written through it; a quoted "*" catch-all counts as the LF default; the warning says to replace a conflicting catch-all (CodeRabbit review on #579). Refs #580 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Description
A new
line endingslinter reports every text file committed with CRLF or mixed line endings. Closes #580. Part of DevSecNinja/repo-steward#204.Stacked on #579 (the
.gitattributestemplate); this PR's base is that branch. It updates the template comment and README to point at the check.Changes
scripts/lint/line-endings.sh: readsgit ls-files --eol -zand reportsi/crlfandi/mixedpaths unless their attributes contain-text(whichbinarysets).eol=crlfpaths are stored with LF, so they pass. Annotations are capped at 50, paths are escaped for workflow commands, and the closing message names the fix (git add --renormalize .with* text=auto eol=lf, or aneol=crlf/-textrule). Needs only git: no mise, no network.lint.yml: inputslint-line-endings(defaulttrue) andlint-line-endings-blocking(defaulttrue;falsereports warnings only), aline-endingsjob and the same step inall-linters.lint-include.yml: the same inputs (lint-line-endingsoff by default, the blocking switch unchanged).tests/lint-scripts.sh(LF,-text,binary, binary content andeol=crlfpass; CRLF, mixed and an escaped path fail; warn mode; bad switch value),tests/lint-job-modes-contract.sh(new linter job),tests/lint-include.py(the blocking switch is an option, not a linter).docs/architecture.md(how it works, inputs table),workflow-templates/lint.yml, and the.gitattributestemplate and README.Fail by default (T139 is still open with the owner): after the cleanup PRs every managed repository is LF in the index, and the five callers with
lint-fail-on-error: truealready are. The switch flips it to warnings if the owner prefers.scripts/lint/line-endings.shis committed as100644: repo-steward commits through the signedcreateCommitOnBranchAPI, which can't set the executable bit. The workflow runs it withbash, like every other script; a follow-upgit update-index --chmod=+xwould match the others.Checklist
tests/lint-scripts.sh,tests/lint-job-modes-contract.sh,tests/lint-include.py,tests/lint-inline-scripts.py,tests/workflow-script-fetch.py,tests/workflow-job-conditions.py,tests/app-key-confinement.py, plus the config-sync tests