Files
orca/src/main/worktree-prunable-git-file.ts
T
OrcaWin 2847bbe9e8 [comment audit] Consolidate completed code comment cleanup
Combine the completed comment cleanup from 319 stacked PRs into one change against `main`, so the full CI suite validates the combined result once. This replaces the previous audit stack; no additional audit work is included.

The change shortens redundant comments across 2,753 source and shell-snapshot files (25,235 net lines removed). Conflicts preserve current-main executable code. Runtime behavior, test assertions, directives, licenses, generated notices, SAFETY rationales, and compatibility markers are preserved. The audit tracker remains local, outside the repository.

Validation:
- Equivalent source/emitted AST and executable tokens across all 2,750 source files, with separate checks for embedded shell, SQL, JavaScript, CSS, and generated fixtures.
- Identical executable lines in the three shell snapshots; protected comments unchanged.
- Changed-code quality gate passed with no new findings.
- 358 tests passed, 2 skipped across 23 focused test files.
- `git diff --check` passed.
2026-10-23 13:15:45 -07:00

42 lines
1.5 KiB
TypeScript

import { isENOENT } from './ipc/filesystem-path-containment'
import type { GitWorktreeInfo } from '../shared/worktree/types'
import type { LocalWorktreeFilesystemOptions } from './local-worktree-filesystem'
import { getLocalWorktreePathAccess, toLocalWorktreeRuntimePath } from './local-worktree-filesystem'
/** Malformed .git paths must never resolve cleanup to a parent checkout. */
export async function isPrunableGitFileWorktree(
worktree: GitWorktreeInfo,
options: LocalWorktreeFilesystemOptions = {}
): Promise<boolean> {
if (
worktree.prunable !== true ||
worktree.isMainWorktree ||
worktree.isBare ||
worktree.locked ||
!worktree.branch.startsWith('refs/heads/') ||
worktree.branch === 'refs/heads/' ||
!worktree.head ||
worktree.path.split(/[\\/]/).at(-1) !== '.git'
) {
return false
}
const access = getLocalWorktreePathAccess(options)
const entry = await access
.statPath(toLocalWorktreeRuntimePath(worktree.path, options))
.catch((error: unknown) => {
// A vanished marker leaves missing-path recovery to its existing stricter gate.
if (isENOENT(error)) {
return null
}
throw error
})
if (!entry || typeof entry !== 'object') {
return false
}
// WSL returns the owning guest's lstat-equivalent type; native lstat rejects symlinks too.
return (
('type' in entry && entry.type === 'file') ||
('isFile' in entry && typeof entry.isFile === 'function' && entry.isFile() === true)
)
}