MCPcopy
hub / github.com/codeaashu/claude-code / keepWorktree

Function keepWorktree

src/utils/worktree.ts:780–811  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

778}
779
780export 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
813export async function cleanupWorktree(): Promise<void> {
814 if (!currentWorktreeSession) {

Callers 2

callFunction · 0.85
handleSelectFunction · 0.85

Calls 2

saveCurrentProjectConfigFunction · 0.85
logForDebuggingFunction · 0.85

Tested by

no test coverage detected