feat: Redesign git changes to split stage/unstaged files. (#1359)
* feat: Redesign git changes to split stage/unstaged files. Signed-off-by: Paolo Insogna <paolo@cowtech.it> * fixup Signed-off-by: Paolo Insogna <paolo@cowtech.it> * fixup Signed-off-by: Paolo Insogna <paolo@cowtech.it> * refactor: streamline git changes panel * fix: label staged and working diff tabs * fix: isolate staged and working diff files * fix: scope staged and working diff updates * fix: scope git row revert to working changes --------- Signed-off-by: Paolo Insogna <paolo@cowtech.it> Co-authored-by: Bohdan Triapitsyn <artmore@protonmail.com>
This commit is contained in:
committed by
GitHub
co-authored by
Bohdan Triapitsyn
parent
9af0de0056
commit
e16097b05d
@@ -217,25 +217,48 @@ export async function handleStandardGitBridgeMessage(message: BridgeMessageInput
|
||||
}
|
||||
|
||||
case 'api:git/revert': {
|
||||
const { directory, path: filePath } = (payload || {}) as { directory?: string; path?: string };
|
||||
const { directory, path: filePath, scope } = (payload || {}) as { directory?: string; path?: string; scope?: 'all' | 'working' };
|
||||
if (!directory || !filePath) {
|
||||
return { id, type, success: false, error: 'Directory and path are required' };
|
||||
}
|
||||
await gitService.revertGitFile(directory, filePath);
|
||||
await gitService.revertGitFile(directory, filePath, { scope });
|
||||
return { id, type, success: true, data: { success: true } };
|
||||
}
|
||||
|
||||
case 'api:git/stage': {
|
||||
const { directory, path: filePath, paths } = (payload || {}) as { directory?: string; path?: string; paths?: string[] };
|
||||
const filePaths = (Array.isArray(paths) ? paths : [filePath])
|
||||
.filter((value): value is string => typeof value === 'string' && value.trim().length > 0);
|
||||
if (!directory || filePaths.length === 0) {
|
||||
return { id, type, success: false, error: 'Directory and path are required' };
|
||||
}
|
||||
await gitService.stageGitFiles(directory, filePaths);
|
||||
return { id, type, success: true, data: { success: true } };
|
||||
}
|
||||
|
||||
case 'api:git/unstage': {
|
||||
const { directory, path: filePath, paths } = (payload || {}) as { directory?: string; path?: string; paths?: string[] };
|
||||
const filePaths = (Array.isArray(paths) ? paths : [filePath])
|
||||
.filter((value): value is string => typeof value === 'string' && value.trim().length > 0);
|
||||
if (!directory || filePaths.length === 0) {
|
||||
return { id, type, success: false, error: 'Directory and path are required' };
|
||||
}
|
||||
await gitService.unstageGitFiles(directory, filePaths);
|
||||
return { id, type, success: true, data: { success: true } };
|
||||
}
|
||||
|
||||
case 'api:git/commit': {
|
||||
const { directory, message, addAll, files } = (payload || {}) as {
|
||||
const { directory, message, addAll, files, stageFiles } = (payload || {}) as {
|
||||
directory?: string;
|
||||
message?: string;
|
||||
addAll?: boolean;
|
||||
files?: string[];
|
||||
stageFiles?: string[];
|
||||
};
|
||||
if (!directory || !message) {
|
||||
return { id, type, success: false, error: 'Directory and message are required' };
|
||||
}
|
||||
const result = await gitService.createGitCommit(directory, message, { addAll, files });
|
||||
const result = await gitService.createGitCommit(directory, message, { addAll, files, stageFiles });
|
||||
return { id, type, success: true, data: result };
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user