Skip to content

chore: enforce line endings, permissions, and ASCII encoding#37

Open
StrongWind1 wants to merge 6 commits intoMatrixEditor:masterfrom
StrongWind1:chore/hygiene-enforcement
Open

chore: enforce line endings, permissions, and ASCII encoding#37
StrongWind1 wants to merge 6 commits intoMatrixEditor:masterfrom
StrongWind1:chore/hygiene-enforcement

Conversation

@StrongWind1
Copy link
Copy Markdown
Contributor

Summary

Adds enforcement infrastructure to prevent the issues fixed in #36 from recurring. Four invariants are checked automatically:

  1. Line endings -- LF only, no CR bytes (exception: docs/make.bat uses CRLF)
  2. Permissions -- mode 100644 on all files, no executable bit
  3. Encoding -- ASCII only (bytes 10, 32-126) outside docs/ and README.md
  4. Python -- repo-wide ruff format + ruff check via uv run (pre-commit only)

Files added

File Purpose
.gitattributes Primary line-ending normalization (LF on commit/checkout, CRLF for docs/make.bat, binary declarations)
.githooks/pre-commit Local pre-commit hook enforcing all 4 rules. Auto-formats Python files and re-stages them
.githooks/check-hygiene.sh CI script checking rules 1-3 on all tracked files. Emits GitHub Actions ::error annotations
.github/workflows/hygiene.yml Runs check-hygiene.sh --diff on every push and PR

Activation

Contributors run once per clone:

git config core.hooksPath .githooks

Configuration sync

Three shared lists are duplicated across .gitattributes, .githooks/pre-commit, and .githooks/check-hygiene.sh with cross-reference comments:

  • BINARY_EXTENSIONS (14 types) -- .gitattributes binary declarations
  • CRLF_ALLOWLIST -- .gitattributes eol=crlf entries
  • ASCII_EXEMPT_PATTERNS -- ^docs/, ^README\.md$
  • EXEC_ALLOWLIST -- intentionally empty

Post-merge

Add Repository Hygiene as a required status check in branch protection rules for master.

Depends on

File permissions (22 files):
- Set 644 on all source files that were incorrectly marked 755
  (executable bit) across dementor/, docs/, tests/, and root configs.
- Affected: __init__.py, filters.py, paths.py, servers.py, loader.py,
  protocols/{__init__,ftp,kerberos,ldap,llmnr,mdns,netbios,ntlm,
  quic,smtp,spnego}.py, tui/{completer,commands/{config,env,ipconfig}}.py,
  assets/Dementor.toml, docs/source/tui.rst, requirements.txt

Non-ASCII replacements in dementor/ and root files (13 files):
- Em-dash (U+2014) -> ' --' in comments and docstrings
- En-dash (U+2013) -> '-'
- Right arrow (U+2192) -> '->'
- Curly/smart quotes (U+201C/U+201D) -> straight quotes
- Section sign (U+00A7) -> 'S' for spec references
- Tab (0x09) -> spaces in mysql.py
- Fix 'donwngrade' typo (U+0175) in smtp.py
- Affected: Dementor.toml, config/{toml,util}.py, db/connector.py,
  loader.py, protocols/{ftp,ntlm,smtp,ssdp}.py,
  tui/{completer,commands/{config,database}}.py, pyproject.toml,
  tests/test_db.py

Non-ASCII replacements in docs/ (14 .rst files):
- Em-dash (U+2014) -> '--'
- En-dash (U+2013) -> '-'
- Right single quote (U+2019) -> straight apostrophe
- Intentionally kept: section sign, arrows, gear emoji, double
  vertical line, dagger, pointer arrows, greater-equal sign
  (these render well in Sphinx HTML output)

Deleted:
- tests/.gitkeep (unnecessary, directory contains .py test files)
Add .gitattributes for LF line ending normalization (CRLF exception:
docs/make.bat). Add pre-commit hook and CI script enforcing four
invariants:

  1. Line endings: LF only, no CR bytes in any text file
  2. Permissions: mode 100644 on all files, no executable bit
  3. Encoding: ASCII only (bytes 10, 32-126) outside docs/ and README.md
  4. Python: repo-wide ruff format + ruff check via uv

Enforcement layers:
  - .gitattributes: automatic line-ending normalization (primary for Rule 1)
  - .githooks/pre-commit: local pre-commit check for all 4 rules
  - .githooks/check-hygiene.sh: server-side hard gate via GitHub Actions
  - .github/workflows/hygiene.yml: triggers CI script on push and PR

All three config files share synchronized lists for binary extensions,
CRLF exceptions, ASCII-exempt paths, and exec allowlists.

No functional changes. All checks pass.
@StrongWind1 StrongWind1 marked this pull request as ready for review March 25, 2026 17:20
@MatrixEditor MatrixEditor self-requested a review March 26, 2026 06:44
@MatrixEditor MatrixEditor added Type - Enhancement CI/CD Issues and requests related to the CI/CD workflows labels Mar 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI/CD Issues and requests related to the CI/CD workflows Type - Enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants