Skip to content

git lfs fix#256

Merged
AviPeltz merged 6 commits intomainfrom
golden-meadow-78
Dec 4, 2025
Merged

git lfs fix#256
AviPeltz merged 6 commits intomainfrom
golden-meadow-78

Conversation

@AviPeltz
Copy link
Copy Markdown
Collaborator

@AviPeltz AviPeltz commented Dec 4, 2025

Description

Related Issues

Type of Change

  • Bug fix
  • New feature
  • Documentation
  • Refactor
  • Other (please describe):

Testing

Screenshots (if applicable)

Additional Notes

Summary by CodeRabbit

  • Bug Fixes

    • Improved error handling around Git worktree operations with clearer guidance when Git LFS is missing or when filesystem errors occur.
  • Improvements

    • Enhanced Git LFS detection and pre-checks to avoid failed operations on LFS-enabled repos.
    • More robust environment handling for git commands to ensure consistent behavior across shells and platforms.
  • New Features

    • Cached shell-environment retrieval and a utility to verify git-lfs availability before actions.

✏️ Tip: You can customize this high-level summary in your review settings.

@vercel
Copy link
Copy Markdown

vercel Bot commented Dec 4, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
website Ready Ready Preview Comment Dec 4, 2025 9:02pm

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Dec 4, 2025

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 55.56% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Description check ⚠️ Warning The pull request description is mostly empty with no meaningful content provided for key sections including Description, Related Issues, Testing, and Additional Notes. Add a clear description of the changes, link any related issues, document the testing performed, and provide additional context about the Git LFS fix and refactoring work.
Title check ❓ Inconclusive The title 'git lfs fix' is vague and does not clearly convey what specific issue is being fixed or what changes were made to address it. Revise the title to be more descriptive and specific, such as 'Fix git-lfs detection and error handling in worktree operations' to better communicate the main change.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch golden-meadow-78

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

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

@AviPeltz AviPeltz marked this pull request as ready for review December 4, 2025 20:37
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
apps/desktop/src/lib/trpc/routers/workspaces/utils/git.ts (2)

22-35: Comment contradicts implementation.

Line 33 states "Shell env wins for PATH, but base env preserved for everything else," but { ...baseEnv, ...shellEnv } means shellEnv overwrites all overlapping keys, not just PATH.

If the intent is truly to only take PATH from the shell environment while preserving runtime vars (credentials, proxy, SSH_AUTH_SOCK), consider:

-	// Shell env wins for PATH, but base env preserved for everything else
-	return { ...baseEnv, ...shellEnv };
+	// Take PATH from shell env (for homebrew tools like git-lfs),
+	// but preserve process.env for runtime vars (credentials, proxy, etc.)
+	return { ...baseEnv, PATH: shellEnv.PATH || baseEnv.PATH };

Alternatively, if the current behavior is intentional (shell env takes precedence for everything), update the docstring and comment to match.


42-43: Prefer static import for consistency.

mkdir is already statically imported from node:fs/promises at line 3. Consider adding readFile and stat to that import rather than using a dynamic import, which adds overhead and is inconsistent.

At line 3:

-import { mkdir } from "node:fs/promises";
+import { mkdir, readFile, stat } from "node:fs/promises";

Then update line 43:

-	const { readFile, stat } = await import("node:fs/promises");
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 229d3e8 and 808dd51.

📒 Files selected for processing (2)
  • apps/desktop/src/lib/trpc/routers/workspaces/utils/git.ts (3 hunks)
  • apps/desktop/src/lib/trpc/routers/workspaces/utils/shell-env.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
apps/desktop/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (apps/desktop/AGENTS.md)

For Electron interprocess communication, ALWAYS use tRPC as defined in src/lib/trpc

Files:

  • apps/desktop/src/lib/trpc/routers/workspaces/utils/shell-env.ts
  • apps/desktop/src/lib/trpc/routers/workspaces/utils/git.ts
apps/desktop/**/*.{ts,tsx}

📄 CodeRabbit inference engine (apps/desktop/AGENTS.md)

apps/desktop/**/*.{ts,tsx}: Please use alias as defined in tsconfig.json when possible
Prefer zustand for state management if it makes sense. Do not use effect unless absolutely necessary

Files:

  • apps/desktop/src/lib/trpc/routers/workspaces/utils/shell-env.ts
  • apps/desktop/src/lib/trpc/routers/workspaces/utils/git.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Avoid using any type - use explicit types instead for type safety
Use camelCase for variable and function names following existing codebase patterns
Keep diffs minimal with targeted edits only - avoid unnecessary changes when making modifications
Follow existing patterns and match the codebase style when writing new code

Files:

  • apps/desktop/src/lib/trpc/routers/workspaces/utils/shell-env.ts
  • apps/desktop/src/lib/trpc/routers/workspaces/utils/git.ts
apps/desktop/src/lib/**/*.ts

📄 CodeRabbit inference engine (AGENTS.md)

Never import Node.js modules in shared code like src/lib/electron-router-dom.ts - this code runs in both main and renderer processes

Files:

  • apps/desktop/src/lib/trpc/routers/workspaces/utils/shell-env.ts
  • apps/desktop/src/lib/trpc/routers/workspaces/utils/git.ts
🧠 Learnings (2)
📚 Learning: 2025-11-28T01:03:47.963Z
Learnt from: CR
Repo: superset-sh/superset PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-28T01:03:47.963Z
Learning: Applies to apps/desktop/src/main/index.ts : Load `.env` file with `override: true` at the start of the main process before any imports

Applied to files:

  • apps/desktop/src/lib/trpc/routers/workspaces/utils/shell-env.ts
📚 Learning: 2025-11-28T01:03:47.963Z
Learnt from: CR
Repo: superset-sh/superset PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-28T01:03:47.963Z
Learning: Applies to **/*.{ts,tsx} : Keep diffs minimal with targeted edits only - avoid unnecessary changes when making modifications

Applied to files:

  • apps/desktop/src/lib/trpc/routers/workspaces/utils/git.ts
🧬 Code graph analysis (1)
apps/desktop/src/lib/trpc/routers/workspaces/utils/git.ts (1)
apps/desktop/src/lib/trpc/routers/workspaces/utils/shell-env.ts (2)
  • getShellEnvironment (22-69)
  • checkGitLfsAvailable (74-86)
🔇 Additional comments (7)
apps/desktop/src/lib/trpc/routers/workspaces/utils/git.ts (4)

1-14: LGTM!

Imports are appropriate for the new LFS support functionality. Using promisify for execFile follows standard Node.js patterns.


109-138: Good proactive LFS detection and error handling.

The early detection of missing git-lfs provides a much better user experience than cryptic filter-process errors. Using execFile with an argument array avoids shell injection and escaping issues.


163-184: LGTM!

Consistent implementation with createWorktree, using execFile with merged environment and proper error handling.


264-272: Consider using merged environment for fetch operations.

fetchDefaultBranch uses simpleGit without the merged shell environment. If this fetch retrieves new LFS-tracked files, it could fail if git-lfs isn't in the default PATH.

Since createWorktree already validates LFS availability and sets up the merged environment, this may work in practice. However, for consistency you might want to verify that simpleGit inherits the environment correctly, or consider switching to execFile like the worktree operations.

apps/desktop/src/lib/trpc/routers/workspaces/utils/shell-env.ts (3)

1-10: LGTM!

Cache setup with 60-second TTL is reasonable for shell environment that rarely changes during runtime.


22-69: Well-implemented shell environment capture.

Good choices:

  • Using -lc (not -ilc) avoids TTY issues from interactive dotfiles
  • Correct parsing handles values containing = characters
  • Graceful fallback to process.env on failure
  • 10-second timeout prevents hanging on broken shell configs

74-95: LGTM!

checkGitLfsAvailable is a clean boolean check, and clearShellEnvCache is useful for testing. The 5-second timeout is appropriate for a simple version check.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
apps/desktop/src/lib/trpc/routers/workspaces/utils/git.ts (1)

148-174: Consider narrowing the LFS error detection conditions.

The LFS error detection at lines 157-162 is overly broad:

  • Line 161: (lowerError.includes("lfs") && lowerError.includes("not")) could match unrelated errors like "conflicts" or "not found" that happen to contain "lfs" elsewhere
  • Line 162: (lowerError.includes("lfs") && usesLfs) catches any error mentioning "lfs" when the repo uses LFS, potentially masking network issues, permissions errors, or other git failures with a misleading "git-lfs not found" message

Consider tightening the conditions to match specific LFS failure patterns:

 		// Broad check for LFS-related errors:
 		// - "git-lfs" / "filter-process" (original)
 		// - "smudge filter lfs failed"
 		// - "git: 'lfs' is not a git command"
-		// - Any mention of "lfs" when we detected LFS usage
 		const isLfsError =
 			lowerError.includes("git-lfs") ||
 			lowerError.includes("filter-process") ||
-			lowerError.includes("smudge") ||
-			(lowerError.includes("lfs") && lowerError.includes("not")) ||
-			(lowerError.includes("lfs") && usesLfs);
+			lowerError.includes("smudge filter lfs") ||
+			(lowerError.includes("lfs") && lowerError.includes("is not a git command"));
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 808dd51 and 9186549.

📒 Files selected for processing (1)
  • apps/desktop/src/lib/trpc/routers/workspaces/utils/git.ts (3 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
apps/desktop/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (apps/desktop/AGENTS.md)

For Electron interprocess communication, ALWAYS use tRPC as defined in src/lib/trpc

Files:

  • apps/desktop/src/lib/trpc/routers/workspaces/utils/git.ts
apps/desktop/**/*.{ts,tsx}

📄 CodeRabbit inference engine (apps/desktop/AGENTS.md)

apps/desktop/**/*.{ts,tsx}: Please use alias as defined in tsconfig.json when possible
Prefer zustand for state management if it makes sense. Do not use effect unless absolutely necessary

Files:

  • apps/desktop/src/lib/trpc/routers/workspaces/utils/git.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Avoid using any type - use explicit types instead for type safety
Use camelCase for variable and function names following existing codebase patterns
Keep diffs minimal with targeted edits only - avoid unnecessary changes when making modifications
Follow existing patterns and match the codebase style when writing new code

Files:

  • apps/desktop/src/lib/trpc/routers/workspaces/utils/git.ts
apps/desktop/src/lib/**/*.ts

📄 CodeRabbit inference engine (AGENTS.md)

Never import Node.js modules in shared code like src/lib/electron-router-dom.ts - this code runs in both main and renderer processes

Files:

  • apps/desktop/src/lib/trpc/routers/workspaces/utils/git.ts
🧠 Learnings (1)
📚 Learning: 2025-11-28T01:03:47.963Z
Learnt from: CR
Repo: superset-sh/superset PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-28T01:03:47.963Z
Learning: Applies to **/*.{ts,tsx} : Keep diffs minimal with targeted edits only - avoid unnecessary changes when making modifications

Applied to files:

  • apps/desktop/src/lib/trpc/routers/workspaces/utils/git.ts
🧬 Code graph analysis (1)
apps/desktop/src/lib/trpc/routers/workspaces/utils/git.ts (1)
apps/desktop/src/lib/trpc/routers/workspaces/utils/shell-env.ts (2)
  • getShellEnvironment (22-69)
  • checkGitLfsAvailable (74-86)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Build
🔇 Additional comments (3)
apps/desktop/src/lib/trpc/routers/workspaces/utils/git.ts (3)

1-15: LGTM! Clean import setup.

The imports and promisified execFileAsync are well-structured for the enhanced Git operations.


37-88: LGTM! Comprehensive LFS detection.

The hybrid approach with fast-path optimization and multiple attribute source checks is thorough. The isEnoent helper cleanly handles expected ENOENT errors.


177-198: LGTM! Clean refactor to execFileAsync.

The switch from simple-git to execFileAsync with proper environment merging and error handling is well-implemented.

Comment thread apps/desktop/src/lib/trpc/routers/workspaces/utils/git.ts
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.

1 participant