MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / stashToCleanState

Function stashToCleanState

source code/utils/git.ts:431–463  ·  view source on GitHub ↗
(message?: string)

Source from the content-addressed store, hash-verified

429 * @returns Promise<boolean> - true if stash was successful, false otherwise
430 */
431export const stashToCleanState = async (message?: string): Promise<boolean> => {
432 try {
433 const stashMessage =
434 message || `Claude Code auto-stash - ${new Date().toISOString()}`
435
436 // First, check if we have untracked files
437 const { untracked } = await getFileStatus()
438
439 // If we have untracked files, add them to the index first
440 // This prevents them from being deleted
441 if (untracked.length > 0) {
442 const { code: addCode } = await execFileNoThrow(
443 gitExe(),
444 ['add', ...untracked],
445 { preserveOutputOnError: false },
446 )
447
448 if (addCode !== 0) {
449 return false
450 }
451 }
452
453 // Now stash everything (staged and unstaged changes)
454 const { code } = await execFileNoThrow(
455 gitExe(),
456 ['stash', 'push', '--message', stashMessage],
457 { preserveOutputOnError: false },
458 )
459 return code === 0
460 } catch (_) {
461 return false
462 }
463}
464
465export type GitRepoState = {
466 commitHash: string

Callers 1

handleStashFunction · 0.85

Calls 2

getFileStatusFunction · 0.85
execFileNoThrowFunction · 0.85

Tested by

no test coverage detected