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