()
| 790 | } |
| 791 | |
| 792 | export async function keepWorktree(): Promise<void> { |
| 793 | if (!currentWorktreeSession) { |
| 794 | return |
| 795 | } |
| 796 | |
| 797 | try { |
| 798 | const { worktreePath, originalCwd, worktreeBranch } = currentWorktreeSession |
| 799 | |
| 800 | // Change back to original directory first |
| 801 | process.chdir(originalCwd) |
| 802 | |
| 803 | // Clear the session but keep the worktree intact |
| 804 | currentWorktreeSession = null |
| 805 | |
| 806 | // Update config |
| 807 | saveCurrentProjectConfig(current => ({ |
| 808 | ...current, |
| 809 | activeWorktreeSession: undefined, |
| 810 | })) |
| 811 | |
| 812 | logForDebugging( |
| 813 | `Linked worktree preserved at: ${worktreePath}${worktreeBranch ? ` on branch: ${worktreeBranch}` : ''}`, |
| 814 | ) |
| 815 | logForDebugging( |
| 816 | `You can continue working there by running: cd ${worktreePath}`, |
| 817 | ) |
| 818 | } catch (error) { |
| 819 | logForDebugging(`Error keeping worktree: ${error}`, { |
| 820 | level: 'error', |
| 821 | }) |
| 822 | } |
| 823 | } |
| 824 | |
| 825 | export async function cleanupWorktree(): Promise<void> { |
| 826 | if (!currentWorktreeSession) { |
no test coverage detected