feat: add git stash management

Add a Stashes dialog with create, apply, pop, and drop actions
Include untracked files automatically when stashing
Show file counts for current changes and stash entries
This commit is contained in:
Bohdan Triapitsyn
2026-05-05 23:39:20 +03:00
parent c80c2b62a8
commit 93267927ff
19 changed files with 754 additions and 109 deletions
+36 -20
View File
@@ -277,6 +277,42 @@ export async function handleStandardGitBridgeMessage(message: BridgeMessageInput
return { id, type, success: true, data: result };
}
case 'api:git/stashes': {
const { directory } = (payload || {}) as { directory?: string };
const dirError = requireDirectory(id, type, directory);
if (dirError) return dirError;
return { id, type, success: true, data: { stashes: await gitService.listGitStashes(directory!) } };
}
case 'api:git/stashes/file-counts': {
const { directory, refs } = (payload || {}) as { directory?: string; refs?: string[] };
const dirError = requireDirectory(id, type, directory);
if (dirError) return dirError;
return { id, type, success: true, data: { counts: await gitService.countGitStashFiles(directory!, refs ?? []) } };
}
case 'api:git/stash': {
const { directory, message } = (payload || {}) as { directory?: string; message?: string };
const dirError = requireDirectory(id, type, directory);
if (dirError) return dirError;
return { id, type, success: true, data: await gitService.stashGitChanges(directory!, { message }) };
}
case 'api:git/stash/apply':
case 'api:git/stash/pop':
case 'api:git/stash/drop': {
const { directory, ref } = (payload || {}) as { directory?: string; ref?: string };
const dirError = requireDirectory(id, type, directory);
if (dirError) return dirError;
const stashRef = ref || 'stash@{0}';
const data = type === 'api:git/stash/apply'
? await gitService.applyGitStash(directory!, { ref: stashRef })
: type === 'api:git/stash/pop'
? await gitService.popGitStash(directory!, { ref: stashRef })
: await gitService.dropGitStash(directory!, { ref: stashRef });
return { id, type, success: true, data };
}
case 'api:git/remotes': {
const { directory, method, remote } = (payload || {}) as {
directory?: string;
@@ -357,26 +393,6 @@ export async function handleStandardGitBridgeMessage(message: BridgeMessageInput
return { id, type, success: true, data: result };
}
case 'api:git/stash': {
const { directory, message, includeUntracked } = (payload || {}) as {
directory?: string;
message?: string;
includeUntracked?: boolean;
};
const dirError = requireDirectory(id, type, directory);
if (dirError) return dirError;
const result = await gitService.stash(directory!, { message, includeUntracked });
return { id, type, success: true, data: result };
}
case 'api:git/stash/pop': {
const { directory } = (payload || {}) as { directory?: string };
const dirError = requireDirectory(id, type, directory);
if (dirError) return dirError;
const result = await gitService.stashPop(directory!);
return { id, type, success: true, data: result };
}
case 'api:git/log': {
const { directory, maxCount, from, to, file } = (payload || {}) as {
directory?: string;