Skip to content

feat(lint): fail on text files committed with CRLF line endings - #581

Closed
DevSecNinja wants to merge 4 commits into
mainfrom
steward/lint-line-endings
Closed

DevSecNinja wants to merge 4 commits into
mainfrom
steward/lint-line-endings

Conversation

@DevSecNinja

Copy link
Copy Markdown
Owner

Description

A new line endings linter reports every text file committed with CRLF or mixed line endings. Closes #580. Part of DevSecNinja/repo-steward#204.

Stacked on #579 (the .gitattributes template); 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: reads git ls-files --eol -z and reports i/crlf and i/mixed paths unless their attributes contain -text (which binary sets). eol=crlf paths 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 an eol=crlf/-text rule). Needs only git: no mise, no network.
  • lint.yml: inputs lint-line-endings (default true) and lint-line-endings-blocking (default true; false reports warnings only), a line-endings job and the same step in all-linters.
  • lint-include.yml: the same inputs (lint-line-endings off by default, the blocking switch unchanged).
  • Tests: tests/lint-scripts.sh (LF, -text, binary, binary content and eol=crlf pass; 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: docs/architecture.md (how it works, inputs table), workflow-templates/lint.yml, and the .gitattributes template 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: true already are. The switch flips it to warnings if the owner prefers.

scripts/lint/line-endings.sh is committed as 100644: repo-steward commits through the signed createCommitOnBranch API, which can't set the executable bit. The workflow runs it with bash, like every other script; a follow-up git update-index --chmod=+x would match the others.

Checklist

  • Linting passes locally: shellcheck, shfmt, dprint, actionlint, yamlfmt, ruff on the changed files
  • Tests pass locally: 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
  • Commit messages follow Conventional Commits
  • Documentation updated

DevSecNinja and others added 2 commits November 18, 2026 15:26
Refs #578

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Refs #580

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@DevSecNinja
DevSecNinja requested a balanced review from Copilot November 18, 2026 14:26
@coderabbitai

coderabbitai Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You'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.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1292d382-0c1c-4811-a43c-4cce09af6cad
Commits

Reviewing files that changed from the base of the PR and between 6a14626 and b21593b.

Files selected for processing: 14

  • .github/workflows/config-sync.yml
  • .github/workflows/lint-include.yml
  • .github/workflows/lint.yml
  • config-sync/templates/.gitattributes
  • config-sync/templates/README.md
  • docs/architecture.md
  • scripts/config-sync/sync-files.sh
  • scripts/lint/line-endings.sh
  • tests/config-sync-renovate-stub.sh
  • tests/config-sync-scripts.sh
  • tests/lint-include.py
  • tests/lint-job-modes-contract.sh
  • tests/lint-scripts.sh
  • workflow-templates/lint.yml
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 -text exceptions.
  • 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

Comment thread scripts/lint/line-endings.sh Resolved
Comment thread scripts/lint/line-endings.sh Resolved
DevSecNinja and others added 2 commits November 18, 2026 15:39
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>
Base automatically changed from steward/gitattributes-template to main November 18, 2026 14:45
DevSecNinja added a commit that referenced this pull request Nov 18, 2026
Same change as #581 (including its review fixes), on top of #579's squash merge.

Refs #580

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@DevSecNinja

Copy link
Copy Markdown
Owner Author

Replaced by #584: same content on top of #579's squash merge. This stacked branch conflicts with main now, and repo-steward doesn't force-push to rebase it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(lint): fail on text files committed with CRLF line endings

2 participants