(repoPath: string)
| 20 | const STALE_LOCK_AGE_MS = 5000; // 5 seconds |
| 21 | |
| 22 | export function cleanStaleLock(repoPath: string): void { |
| 23 | const lockPath = path.join(repoPath, ".git", "index.lock"); |
| 24 | try { |
| 25 | const stat = fs.statSync(lockPath); |
| 26 | const ageMs = Date.now() - stat.mtimeMs; |
| 27 | if (ageMs > STALE_LOCK_AGE_MS) { |
| 28 | fs.unlinkSync(lockPath); |
| 29 | log.info(`Removed stale git index.lock (age: ${Math.round(ageMs / 1000)}s) at ${lockPath}`); |
| 30 | } |
| 31 | } catch { |
| 32 | // Lock doesn't exist or can't be accessed - this is fine |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | export interface WorktreeResult { |
| 37 | success: boolean; |
no outgoing calls
no test coverage detected