MCPcopy
hub / github.com/claude-code-best/claude-code / loadChanges

Function loadChanges

src/components/WorktreeExitDialog.tsx:35–79  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

33
34 useEffect(() => {
35 async function loadChanges() {
36 let changeLines: string[] = [];
37 const gitStatus = await execFileNoThrow('git', ['status', '--porcelain']);
38 if (gitStatus.stdout) {
39 changeLines = gitStatus.stdout.split('\n').filter(_ => _.trim() !== '');
40 setChanges(changeLines);
41 }
42
43 // Check for commits to eject
44 if (worktreeSession) {
45 // Get commits in worktree that are not in original branch
46 const { stdout: commitsStr } = await execFileNoThrow('git', [
47 'rev-list',
48 '--count',
49 `${worktreeSession.originalHeadCommit}..HEAD`,
50 ]);
51 const count = parseInt(commitsStr.trim(), 10) || 0;
52 setCommitCount(count);
53
54 // If no changes and no commits, clean up silently
55 if (changeLines.length === 0 && count === 0) {
56 setStatus('removing');
57 void cleanupWorktree()
58 .then(() => {
59 process.chdir(worktreeSession.originalCwd);
60 setCwd(worktreeSession.originalCwd);
61 recordWorktreeExit();
62 getPlansDirectory.cache.clear?.();
63 setResultMessage('Worktree removed (no changes)');
64 })
65 .catch(error => {
66 logForDebugging(`Failed to clean up worktree: ${error}`, {
67 level: 'error',
68 });
69 setResultMessage('Worktree cleanup failed, exiting anyway');
70 })
71 .then(() => {
72 setStatus('done');
73 });
74 return;
75 } else {
76 setStatus('asking');
77 }
78 }
79 }
80 void loadChanges();
81 // eslint-disable-next-line react-hooks/exhaustive-deps
82 }, [worktreeSession]);

Callers 1

WorktreeExitDialogFunction · 0.85

Calls 7

setStatusFunction · 0.85
cleanupWorktreeFunction · 0.85
setCwdFunction · 0.85
recordWorktreeExitFunction · 0.85
execFileNoThrowFunction · 0.50
logForDebuggingFunction · 0.50
clearMethod · 0.45

Tested by

no test coverage detected