feat: Add git log parsing and rebase endpoint with input validation

This commit is contained in:
gsxdsm
2026-02-18 00:31:31 -08:00
parent e6e04d57bc
commit d30296d559
42 changed files with 2826 additions and 376 deletions

View File

@@ -2259,15 +2259,23 @@ function createMockWorktreeAPI(): WorktreeAPI {
};
},
pull: async (worktreePath: string, remote?: string) => {
pull: async (worktreePath: string, remote?: string, stashIfNeeded?: boolean) => {
const targetRemote = remote || 'origin';
console.log('[Mock] Pulling latest changes for:', { worktreePath, remote: targetRemote });
console.log('[Mock] Pulling latest changes for:', {
worktreePath,
remote: targetRemote,
stashIfNeeded,
});
return {
success: true,
result: {
branch: 'main',
pulled: true,
message: `Pulled latest changes from ${targetRemote}`,
hasLocalChanges: false,
hasConflicts: false,
stashed: false,
stashRestored: false,
},
};
},
@@ -2696,6 +2704,7 @@ function createMockWorktreeAPI(): WorktreeAPI {
result: {
applied: true,
hasConflicts: false,
conflictFiles: [] as string[],
operation: pop ? ('pop' as const) : ('apply' as const),
stashIndex,
message: `Stash ${pop ? 'popped' : 'applied'} successfully`,
@@ -2740,6 +2749,17 @@ function createMockWorktreeAPI(): WorktreeAPI {
},
};
},
rebase: async (worktreePath: string, ontoBranch: string) => {
console.log('[Mock] Rebase:', { worktreePath, ontoBranch });
return {
success: true,
result: {
branch: 'current-branch',
ontoBranch,
message: `Successfully rebased onto ${ontoBranch}`,
},
};
},
};
}

View File

@@ -2135,8 +2135,8 @@ export class HttpApiClient implements ElectronAPI {
featureId,
filePath,
}),
pull: (worktreePath: string, remote?: string) =>
this.post('/api/worktree/pull', { worktreePath, remote }),
pull: (worktreePath: string, remote?: string, stashIfNeeded?: boolean) =>
this.post('/api/worktree/pull', { worktreePath, remote, stashIfNeeded }),
checkoutBranch: (worktreePath: string, branchName: string, baseBranch?: string) =>
this.post('/api/worktree/checkout-branch', { worktreePath, branchName, baseBranch }),
listBranches: (worktreePath: string, includeRemote?: boolean) =>
@@ -2230,6 +2230,8 @@ export class HttpApiClient implements ElectronAPI {
this.post('/api/worktree/stash-drop', { worktreePath, stashIndex }),
cherryPick: (worktreePath: string, commitHashes: string[], options?: { noCommit?: boolean }) =>
this.post('/api/worktree/cherry-pick', { worktreePath, commitHashes, options }),
rebase: (worktreePath: string, ontoBranch: string) =>
this.post('/api/worktree/rebase', { worktreePath, ontoBranch }),
getBranchCommitLog: (worktreePath: string, branchName?: string, limit?: number) =>
this.post('/api/worktree/branch-commit-log', { worktreePath, branchName, limit }),
getTestLogs: (worktreePath?: string, sessionId?: string): Promise<TestLogsResponse> => {