Skip to content

feat: Enhance .gitattributes with canonical patterns from gitattributes/gitattributes #914

@rjmurillo

Description

@rjmurillo

Summary

Align .gitattributes with canonical patterns from gitattributes/gitattributes to improve cross-platform compatibility, diff rendering, and binary file handling.

Current State

The repository has a solid foundation:

  • Global LF normalization (* text=auto eol=lf) to fix YAML frontmatter parsing issues
  • Custom merge strategies for HANDOFF.md and handoffs
  • Markdown diff rendering (*.md diff=markdown)

Gap Analysis

Missing from Common.gitattributes

Category Pattern Benefit
Documents *.mdx text diff=markdown MDX support
Documents *.txt text Explicit text handling
Graphics *.png binary Prevent corruption
Graphics *.jpg binary, *.jpeg binary Prevent corruption
Graphics *.gif binary, *.ico binary Prevent corruption
Graphics *.svg text Treat as diffable text
Scripts *.sh text eol=lf Unix scripts (bootstrap-vm.sh exists)
Serialization *.json text Explicit text handling
Serialization *.yaml text, *.yml text Explicit text handling
Serialization *.toml text, *.xml text Explicit text handling
Archives *.zip binary, *.gz binary, etc. Prevent corruption
Patches *.patch -text Preserve line endings
Export .gitattributes export-ignore Exclude from archives
Export .gitignore export-ignore Exclude from archives

Missing from PowerShell.gitattributes

Pattern Note
*.psm1 text Module files
*.psd1 text Data files
*.ps1xml text Format files
*.pssc text Session config
*.psrc text Role capability
*.cdxml text CDXML files

Note: Template uses eol=crlf but our global eol=lf is intentional per Copilot CLI issue #694/#673. PowerShell 7+ handles LF fine cross-platform.

Missing from Python.gitattributes

Pattern Benefit
*.py text diff=python Python-aware diffs
*.pyw text diff=python Python scripts
*.pyi text diff=python Type stubs
*.ipynb text eol=lf Jupyter notebooks
*.pyc binary export-ignore Compiled bytecode
*.pyo binary export-ignore Optimized bytecode
*.pyd binary Python DLLs
*.pickle binary Serialized data

Missing from Markdown.gitattributes

Pattern Benefit
*.md linguist-detectable GitHub language stats

Missing from VS Code / DevContainer

Pattern Benefit
.vscode/*.json linguist-language=JSON-with-Comments Proper syntax highlighting on GitHub
.devcontainer.json linguist-language=JSON-with-Comments JSONC support

Proposed Structure

Reorganize into logical sections following the canonical template structure:

  1. Line Ending Normalization (existing)
  2. Documents (markdown, text files)
  3. Graphics (binary images)
  4. Scripts (shell, PowerShell)
  5. Serialization (JSON, YAML, TOML, XML)
  6. Python (source and binaries)
  7. Archives (compressed files)
  8. Patches (preserve line endings)
  9. GitHub/Linguist (language detection, syntax highlighting)
  10. Export (archive exclusions)
  11. Custom Merge Strategies (existing HANDOFF.md, handoffs)

Acceptance Criteria

  • Add explicit text attribute to markdown files: *.md text diff=markdown
  • Add binary declarations for common image formats
  • Add PowerShell file type declarations (*.psm1, *.psd1, etc.)
  • Add Python file type declarations with diff=python
  • Add shell script declarations (*.sh, *.bash, etc.)
  • Add serialization format declarations (JSON, YAML, TOML, XML)
  • Add archive binary declarations
  • Add patch file handling (*.patch -text)
  • Add linguist attributes for GitHub rendering
  • Add export-ignore for git metadata files
  • Preserve existing custom merge strategies
  • Maintain LF-first decision (override template CRLF recommendations)

References

Metadata

Metadata

Labels

area-infrastructureBuild, CI/CD, configurationenhancementNew feature or requestpriority:P2Normal: Standard enhancement or bug fix, moderate impact

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions