Skip to content

feat: add .gitattributes to enforce LF line endings#1550

Merged
kevincodex1 merged 3 commits into
Gitlawb:mainfrom
adityachaudhary99:feat/add-gitattributes
Jun 6, 2026
Merged

feat: add .gitattributes to enforce LF line endings#1550
kevincodex1 merged 3 commits into
Gitlawb:mainfrom
adityachaudhary99:feat/add-gitattributes

Conversation

@adityachaudhary99

@adityachaudhary99 adityachaudhary99 commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Problem

openclaude has no .gitattributes. Contributors on Windows/NTFS with default core.autocrlf=true will silently convert LF→CRLF on checkout. A subsequent git add -A stages every file, producing PRs with +600k/-600k diffs across 700+ files.

This already happened (see #1532 before cleanup) and will happen to every new Windows contributor.

Fix

Add a comprehensive .gitattributes matching the pattern used by openclaude-adjacent projects:

  • * text=auto — normalize all text files to LF on checkin
  • Explicit binary markers for images, fonts, archives, compiled Python/JS
  • Shell scripts enforce LF, batch files enforce CRLF

Impact

  • Zero code changes — config file only
  • Prevents line-ending corruption regardless of contributor's local git config
  • .gitattributes is repo-level and ships with every clone — no per-contributor setup needed

Testing

  • git add .gitattributes && git commit — 1 file, 124 lines, clean diff
  • Pre-commit hook would block any unnatural diff before it reaches a PR

Summary by CodeRabbit

  • Chores
    • Added repository configuration to enforce consistent line-ending and file-type handling across the project for more reliable cross-platform behavior.
  • Tests
    • Improved test isolation and state restoration to reduce cross-test interference and flakiness.

Prevents Windows/NTFS contributors with core.autocrlf=true from
accidentally converting the entire codebase CRLF→LF, which produces
PRs with +600k/-600k diffs across 700+ files.

- * text=auto normalizes all text files to LF on checkin
- Explicit binary markers for images, fonts, archives, compiled code
- No code changes — config-only, zero risk
@coderabbitai

coderabbitai Bot commented Jun 5, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: db302b73-b550-4bf8-9b1f-dfc608c71a80

📥 Commits

Reviewing files that changed from the base of the PR and between b310ad3 and 36abc55.

📒 Files selected for processing (3)
  • src/tools/WebSearchTool/providers/brave.test.ts
  • src/tools/WebSearchTool/providers/brave.ts
  • src/tools/WebSearchTool/providers/exa.test.ts
📜 Recent review details
⏰ Context from checks skipped due to timeout of 900000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: smoke-and-tests
🧰 Additional context used
📓 Path-based instructions (4)
**/*

⚙️ CodeRabbit configuration file

**/*: Apply the OpenClaude maintainer review rubric from AGENTS.md. Review the current diff, not stale discussion context. Separate real blockers from suggestions. Do not request changes for vague style churn. Treat approval as merge-ready from CodeRabbit's side, pending required human review and GitHub Checks. If checks are failing or unavailable, say so clearly instead of implying the PR is fully ready.

Files:

  • src/tools/WebSearchTool/providers/brave.ts
  • src/tools/WebSearchTool/providers/exa.test.ts
  • src/tools/WebSearchTool/providers/brave.test.ts
src/{components/permissions,utils/permissions,hooks/toolPermission,tools,entrypoints/sdk}/**

⚙️ CodeRabbit configuration file

src/{components/permissions,utils/permissions,hooks/toolPermission,tools,entrypoints/sdk}/**: Review permission prompts, auto-allow logic, sandbox behavior, SDK permission schemas, shell/PowerShell execution, and background execution paths as security-sensitive. Block on bypasses, unclear trust boundaries, unsafe path handling, missing user visibility, or changes that broaden allowed behavior without an explicit maintainer decision.

Files:

  • src/tools/WebSearchTool/providers/brave.ts
  • src/tools/WebSearchTool/providers/exa.test.ts
  • src/tools/WebSearchTool/providers/brave.test.ts
**

⚙️ CodeRabbit configuration file

**: # Contributing to OpenClaude

Thanks for contributing.

OpenClaude is a fast-moving open-source coding-agent CLI with support for multiple providers, local backends, MCP, and a terminal-first workflow. The best contributions here are focused, well-tested, and easy to review.

Before You Start

  • Search existing issues and discussions before opening a new thread.
  • Check open pull requests for work that overlaps with your contribution. If a PR already exists that addresses the same change, open an issue or discussion first to align on direction — duplicate PRs may be closed without review.
  • Use issues for confirmed bugs and actionable feature work.
  • Use discussions for setup help, ideas, and general community conversation.
  • For larger changes, open an issue first so the scope is clear before implementation.
  • For security reports, follow SECURITY.md.

Pull Requests

Every PR needs a reason. Your PR description must include:

  • what changed and why
  • the user or developer impact
  • the exact checks you ran
  • a linked issue when one exists, using Fixes fix: skip assertMinVersion for third-party providers #123, `Closes `#123, or another clear link
  • screenshots when the PR touches UI, terminal presentation, or the VS Code extension
  • which provider path was tested when the PR changes provider behavior

The PR author is responsible for ensuring their PR is merge-ready. PRs with merge conflicts will not be reviewed or approved until the conflicts are resolved.

Issues are the recommended starting point for anything non-trivial — opening one first helps avoid wasted effort if the change is out of scope or already being worked on. Small fixes, doc corrections, and obvious improvements can stand on their own without a linked issue, as long as the PR description explains the intent.

What Gets Closed Without Review

PRs may be closed without review...

Files:

  • src/tools/WebSearchTool/providers/brave.ts
  • src/tools/WebSearchTool/providers/exa.test.ts
  • src/tools/WebSearchTool/providers/brave.test.ts
{src/**/*.test.ts,src/**/*.test.tsx,tests/**,scripts/**/*.test.ts,vscode-extension/**/*.test.js}

⚙️ CodeRabbit configuration file

{src/**/*.test.ts,src/**/*.test.tsx,tests/**,scripts/**/*.test.ts,vscode-extension/**/*.test.js}: Review tests for meaningful coverage of the changed behavior, isolation of global/env/config state, async cleanup, fake timers, provider profile leaks, and Windows-compatible assumptions. Block when risky runtime changes lack focused regression coverage or tests assert implementation details while missing the user-visible behavior.

Files:

  • src/tools/WebSearchTool/providers/exa.test.ts
  • src/tools/WebSearchTool/providers/brave.test.ts
🔇 Additional comments (3)
src/tools/WebSearchTool/providers/brave.test.ts (1)

9-29: LGTM!

Also applies to: 31-113

src/tools/WebSearchTool/providers/exa.test.ts (1)

9-29: LGTM!

Also applies to: 31-154

src/tools/WebSearchTool/providers/brave.ts (1)

1-53: LGTM!


📝 Walkthrough

Walkthrough

Adds a repository .gitattributes to standardize EOL and text/binary handling and hardens Brave/Exa WebSearchTool tests with shared-mutation locks and env/fetch snapshot-restore; Brave provider implementation was reformatted only.

Changes

Git attributes configuration

Layer / File(s) Summary
Defaults, source/text rules, and script EOLs
.gitattributes
Adds text=auto, marks common source/config/docs as text (Python diff where applicable), and sets LF for shell/PowerShell scripts and CRLF for batch scripts (includes quickstart.sh).
Binary, archives, compiled artifacts, documents, media
.gitattributes
Marks graphics, archives, compiled artifacts, PDFs/Office, fonts, audio/video, and database files as binary.

WebSearchTool providers: tests and provider

Layer / File(s) Summary
Test isolation and shared-mutation lock
src/tools/WebSearchTool/providers/brave.test.ts, src/tools/WebSearchTool/providers/exa.test.ts
Snapshots original env vars and globalThis.fetch, acquires/releases a shared mutation lock around each test, and restores env/fetch in afterEach; existing test assertions are preserved.
Brave provider formatting-only change
src/tools/WebSearchTool/providers/brave.ts
Whitespace/line-ending normalization applied; no observable behavior or API/signature changes to request/response/hit mapping logic.

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 7
✅ Passed checks (7 passed)
Check name Status Explanation
Title check ✅ Passed Title accurately describes the main change: adding .gitattributes to enforce LF line endings, which is the primary purpose of this PR and matches the changeset.
Description check ✅ Passed Description covers problem, fix, and impact clearly. However, it deviates from the template by not using the specified Testing section format with checkboxes and actual test results.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Risk Surface Disclosed ✅ Passed PR touches search providers with API keys but contains only .gitattributes config, line-ending reformatting, and test locking—no code logic changes to auth or network behavior.
No Hidden Policy Change ✅ Passed PR contains no hidden policy changes: .gitattributes is pure line-ending config, test files add only test infrastructure (mutation locks), provider implementations unchanged in behavior or policy.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.gitattributes:
- Line 69: The .gitattributes entry marking SVGs as binary disables
diffs/merges; change the '*.svg binary' attribute to treat SVGs as text (e.g.,
replace 'binary' with 'text' or 'text eol=lf') so XML-based SVG files are
diffable/mergeable; update the '*.svg' attribute line accordingly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: c7c0d851-037e-4ccf-8082-b753d44b168c

📥 Commits

Reviewing files that changed from the base of the PR and between 1204fe2 and 89f82f1.

📒 Files selected for processing (1)
  • .gitattributes
📜 Review details
⏰ Context from checks skipped due to timeout of 900000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: smoke-and-tests
🔇 Additional comments (1)
.gitattributes (1)

1-68: LGTM!

Also applies to: 70-125

Comment thread .gitattributes Outdated
*.jpeg binary
*.gif binary
*.ico binary
*.svg binary

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Use text attributes for SVG instead of binary.

Line 69 marks *.svg as binary, which suppresses useful diffs/merges for XML-based SVG files. Prefer text normalization here.

Suggested change
-*.svg binary
+*.svg text
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
*.svg binary
*.svg text
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.gitattributes at line 69, The .gitattributes entry marking SVGs as binary
disables diffs/merges; change the '*.svg binary' attribute to treat SVGs as text
(e.g., replace 'binary' with 'text' or 'text eol=lf') so XML-based SVG files are
diffable/mergeable; update the '*.svg' attribute line accordingly.

SVGs are XML-based vector files and should be diffable/mergeable.
CodeRabbit review: Gitlawb#1550 (comment)

@adityachaudhary99 adityachaudhary99 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed the *.svg binary*.svg text in b310ad3. SVGs are XML-based and should be diffable/mergeable — good catch.

@adityachaudhary99

Copy link
Copy Markdown
Contributor Author

Hey @jatmn - tiny config PR that prevents a nasty Windows/NTFS footgun.

What: .gitattributes with * text=auto to enforce LF line endings repo-wide.

Why (my blunder): My earlier PR #1532 accidentally shipped +660k/-660k
diffs across 700+ files because Windows core.autocrlf=true silently
converted every LF→CRLF on checkout. One git add -A staged the entire
codebase. Took me hours to figure out what happened.

This .gitattributes prevents that for every future Windows contributor —
it's repo-level, ships with every clone, no per-contributor setup needed.

PR: #1550 — 1 file, 125 lines, zero code changes. CodeRabbit review
resolved (SVG text vs binary fixed in b310ad3).

Would love a review when you have a chance. Happy to adjust anything.

@kevincodex1 kevincodex1 requested a review from jatmn June 5, 2026 16:24
kevincodex1
kevincodex1 previously approved these changes Jun 5, 2026

@kevincodex1 kevincodex1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@jatmn jatmn left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I found an issue that needs to be addressed before this is ready.

Findings

  • [P2] Renormalize existing CRLF TypeScript files before adding the rule
    .gitattributes:7
    The new *.ts text attribute is being added while the repository still contains TypeScript files whose index line endings are CRLF or mixed. In a fresh checkout of this PR branch with Windows-style core.autocrlf=true, git status is dirty immediately with line-ending-only rewrites in src/tools/WebSearchTool/providers/brave.ts, src/tools/WebSearchTool/providers/brave.test.ts, and src/tools/WebSearchTool/providers/exa.test.ts (89 +89, 53 +53, and 130 +130 in git diff --numstat). That means the PR currently creates the same kind of Windows checkout noise it is intended to prevent. Please include the matching renormalization for files affected by the new attributes, or otherwise adjust the attributes so a fresh Windows checkout stays clean.

The new *.ts text attribute exposed 3 TS files with CRLF in the index.
Renormalizing so a fresh Windows checkout stays clean. Fixes jatmn's P2 finding.
@jatmn

jatmn commented Jun 5, 2026

Copy link
Copy Markdown
Collaborator

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Jun 5, 2026

Copy link
Copy Markdown

CodeRabbit chat interactions are restricted to organization members for this repository. Ask an organization member to interact with CodeRabbit, or set chat.allow_non_org_members: true in your configuration.

@jatmn

jatmn commented Jun 5, 2026

Copy link
Copy Markdown
Collaborator

@coderabbitai run pre-merge check

@coderabbitai

coderabbitai Bot commented Jun 5, 2026

Copy link
Copy Markdown

CodeRabbit chat interactions are restricted to organization members for this repository. Ask an organization member to interact with CodeRabbit, or set chat.allow_non_org_members: true in your configuration.

@jatmn jatmn left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for the update. I rechecked the previously discussed paths and do not see any remaining actionable issues from my side.

@jatmn

jatmn commented Jun 5, 2026

Copy link
Copy Markdown
Collaborator

@kevincodex1

@kevincodex1 kevincodex1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@kevincodex1 kevincodex1 merged commit 1c27957 into Gitlawb:main Jun 6, 2026
3 checks passed
hotmanxp added a commit to hotmanxp/openclaude that referenced this pull request Jun 6, 2026
Per-file port of upstream 1c27957. 1 file (.gitattributes) only.

Skipped 3 brave/exa file hunks — fork does not have
`src/tools/WebSearchTool/providers/brave.ts` or `brave.test.ts`;
the upstream commit was just renormalizing line endings in those
files (no real code change), and exa.test.ts is not in the fork
either. Applying those hunks would add the brave search provider,
which is out of scope for the LF-eol config-only change.

Source: upstream 1c27957
deagwon97 pushed a commit to deagwon97/openclaude that referenced this pull request Jun 11, 2026
* feat: add .gitattributes to enforce LF line endings

Prevents Windows/NTFS contributors with core.autocrlf=true from
accidentally converting the entire codebase CRLF→LF, which produces
PRs with +600k/-600k diffs across 700+ files.

- * text=auto normalizes all text files to LF on checkin
- Explicit binary markers for images, fonts, archives, compiled code
- No code changes — config-only, zero risk

* fix: treat SVGs as text, not binary

SVGs are XML-based vector files and should be diffable/mergeable.
CodeRabbit review: Gitlawb#1550 (comment)

* fix: renormalize CRLF TypeScript files to LF

The new *.ts text attribute exposed 3 TS files with CRLF in the index.
Renormalizing so a fresh Windows checkout stays clean. Fixes jatmn's P2 finding.
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.

3 participants