mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-03-19 10:43:08 +00:00
refactor: Improve all git operations, add stash support, add improved pull request flow, add worktree file copy options, address code review comments, add cherry pick options
This commit is contained in:
@@ -202,6 +202,7 @@ export interface CreatePROptions {
|
||||
prBody?: string;
|
||||
baseBranch?: string;
|
||||
draft?: boolean;
|
||||
remote?: string;
|
||||
}
|
||||
|
||||
// Re-export types from electron.d.ts for external use
|
||||
@@ -2195,6 +2196,15 @@ function createMockWorktreeAPI(): WorktreeAPI {
|
||||
};
|
||||
},
|
||||
|
||||
generatePRDescription: async (worktreePath: string, baseBranch?: string) => {
|
||||
console.log('[Mock] Generating PR description for:', { worktreePath, baseBranch });
|
||||
return {
|
||||
success: true,
|
||||
title: 'Add new feature implementation',
|
||||
body: '## Summary\n- Added new feature\n\n## Changes\n- Implementation details here',
|
||||
};
|
||||
},
|
||||
|
||||
push: async (worktreePath: string, force?: boolean, remote?: string) => {
|
||||
const targetRemote = remote || 'origin';
|
||||
console.log('[Mock] Pushing worktree:', { worktreePath, force, remote: targetRemote });
|
||||
@@ -2249,22 +2259,24 @@ function createMockWorktreeAPI(): WorktreeAPI {
|
||||
};
|
||||
},
|
||||
|
||||
pull: async (worktreePath: string) => {
|
||||
console.log('[Mock] Pulling latest changes for:', worktreePath);
|
||||
pull: async (worktreePath: string, remote?: string) => {
|
||||
const targetRemote = remote || 'origin';
|
||||
console.log('[Mock] Pulling latest changes for:', { worktreePath, remote: targetRemote });
|
||||
return {
|
||||
success: true,
|
||||
result: {
|
||||
branch: 'main',
|
||||
pulled: true,
|
||||
message: 'Pulled latest changes',
|
||||
message: `Pulled latest changes from ${targetRemote}`,
|
||||
},
|
||||
};
|
||||
},
|
||||
|
||||
checkoutBranch: async (worktreePath: string, branchName: string) => {
|
||||
checkoutBranch: async (worktreePath: string, branchName: string, baseBranch?: string) => {
|
||||
console.log('[Mock] Creating and checking out branch:', {
|
||||
worktreePath,
|
||||
branchName,
|
||||
baseBranch,
|
||||
});
|
||||
return {
|
||||
success: true,
|
||||
@@ -2303,6 +2315,8 @@ function createMockWorktreeAPI(): WorktreeAPI {
|
||||
previousBranch: 'main',
|
||||
currentBranch: branchName,
|
||||
message: `Switched to branch '${branchName}'`,
|
||||
hasConflicts: false,
|
||||
stashedChanges: false,
|
||||
},
|
||||
};
|
||||
},
|
||||
@@ -2631,6 +2645,101 @@ function createMockWorktreeAPI(): WorktreeAPI {
|
||||
console.log('[Mock] Unsubscribing from test runner events');
|
||||
};
|
||||
},
|
||||
|
||||
getCommitLog: async (worktreePath: string, limit?: number) => {
|
||||
console.log('[Mock] Getting commit log:', { worktreePath, limit });
|
||||
return {
|
||||
success: true,
|
||||
result: {
|
||||
branch: 'main',
|
||||
commits: [
|
||||
{
|
||||
hash: 'abc1234567890',
|
||||
shortHash: 'abc1234',
|
||||
author: 'Mock User',
|
||||
authorEmail: 'mock@example.com',
|
||||
date: new Date().toISOString(),
|
||||
subject: 'Mock commit message',
|
||||
body: '',
|
||||
files: ['src/index.ts', 'package.json'],
|
||||
},
|
||||
],
|
||||
total: 1,
|
||||
},
|
||||
};
|
||||
},
|
||||
stashPush: async (worktreePath: string, message?: string, files?: string[]) => {
|
||||
console.log('[Mock] Stash push:', { worktreePath, message, files });
|
||||
return {
|
||||
success: true,
|
||||
result: {
|
||||
stashed: true,
|
||||
branch: 'main',
|
||||
message: message || 'WIP on main',
|
||||
},
|
||||
};
|
||||
},
|
||||
stashList: async (worktreePath: string) => {
|
||||
console.log('[Mock] Stash list:', { worktreePath });
|
||||
return {
|
||||
success: true,
|
||||
result: {
|
||||
stashes: [],
|
||||
total: 0,
|
||||
},
|
||||
};
|
||||
},
|
||||
stashApply: async (worktreePath: string, stashIndex: number, pop?: boolean) => {
|
||||
console.log('[Mock] Stash apply:', { worktreePath, stashIndex, pop });
|
||||
return {
|
||||
success: true,
|
||||
result: {
|
||||
applied: true,
|
||||
hasConflicts: false,
|
||||
operation: pop ? ('pop' as const) : ('apply' as const),
|
||||
stashIndex,
|
||||
message: `Stash ${pop ? 'popped' : 'applied'} successfully`,
|
||||
},
|
||||
};
|
||||
},
|
||||
stashDrop: async (worktreePath: string, stashIndex: number) => {
|
||||
console.log('[Mock] Stash drop:', { worktreePath, stashIndex });
|
||||
return {
|
||||
success: true,
|
||||
result: {
|
||||
dropped: true,
|
||||
stashIndex,
|
||||
message: `Stash stash@{${stashIndex}} dropped successfully`,
|
||||
},
|
||||
};
|
||||
},
|
||||
cherryPick: async (
|
||||
worktreePath: string,
|
||||
commitHashes: string[],
|
||||
options?: { noCommit?: boolean }
|
||||
) => {
|
||||
console.log('[Mock] Cherry-pick:', { worktreePath, commitHashes, options });
|
||||
return {
|
||||
success: true,
|
||||
result: {
|
||||
cherryPicked: true,
|
||||
commitHashes,
|
||||
branch: 'main',
|
||||
message: `Cherry-picked ${commitHashes.length} commit(s) successfully`,
|
||||
},
|
||||
};
|
||||
},
|
||||
getBranchCommitLog: async (worktreePath: string, branchName?: string, limit?: number) => {
|
||||
console.log('[Mock] Get branch commit log:', { worktreePath, branchName, limit });
|
||||
return {
|
||||
success: true,
|
||||
result: {
|
||||
branch: branchName || 'main',
|
||||
commits: [],
|
||||
total: 0,
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -2121,6 +2121,8 @@ export class HttpApiClient implements ElectronAPI {
|
||||
this.post('/api/worktree/commit', { worktreePath, message, files }),
|
||||
generateCommitMessage: (worktreePath: string) =>
|
||||
this.post('/api/worktree/generate-commit-message', { worktreePath }),
|
||||
generatePRDescription: (worktreePath: string, baseBranch?: string) =>
|
||||
this.post('/api/worktree/generate-pr-description', { worktreePath, baseBranch }),
|
||||
push: (worktreePath: string, force?: boolean, remote?: string) =>
|
||||
this.post('/api/worktree/push', { worktreePath, force, remote }),
|
||||
createPR: (worktreePath: string, options?: CreatePROptions) =>
|
||||
@@ -2133,9 +2135,10 @@ export class HttpApiClient implements ElectronAPI {
|
||||
featureId,
|
||||
filePath,
|
||||
}),
|
||||
pull: (worktreePath: string) => this.post('/api/worktree/pull', { worktreePath }),
|
||||
checkoutBranch: (worktreePath: string, branchName: string) =>
|
||||
this.post('/api/worktree/checkout-branch', { worktreePath, branchName }),
|
||||
pull: (worktreePath: string, remote?: string) =>
|
||||
this.post('/api/worktree/pull', { worktreePath, remote }),
|
||||
checkoutBranch: (worktreePath: string, branchName: string, baseBranch?: string) =>
|
||||
this.post('/api/worktree/checkout-branch', { worktreePath, branchName, baseBranch }),
|
||||
listBranches: (worktreePath: string, includeRemote?: boolean) =>
|
||||
this.post('/api/worktree/list-branches', { worktreePath, includeRemote }),
|
||||
switchBranch: (worktreePath: string, branchName: string) =>
|
||||
@@ -2216,6 +2219,19 @@ export class HttpApiClient implements ElectronAPI {
|
||||
startTests: (worktreePath: string, options?: { projectPath?: string; testFile?: string }) =>
|
||||
this.post('/api/worktree/start-tests', { worktreePath, ...options }),
|
||||
stopTests: (sessionId: string) => this.post('/api/worktree/stop-tests', { sessionId }),
|
||||
getCommitLog: (worktreePath: string, limit?: number) =>
|
||||
this.post('/api/worktree/commit-log', { worktreePath, limit }),
|
||||
stashPush: (worktreePath: string, message?: string, files?: string[]) =>
|
||||
this.post('/api/worktree/stash-push', { worktreePath, message, files }),
|
||||
stashList: (worktreePath: string) => this.post('/api/worktree/stash-list', { worktreePath }),
|
||||
stashApply: (worktreePath: string, stashIndex: number, pop?: boolean) =>
|
||||
this.post('/api/worktree/stash-apply', { worktreePath, stashIndex, pop }),
|
||||
stashDrop: (worktreePath: string, stashIndex: number) =>
|
||||
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 }),
|
||||
getBranchCommitLog: (worktreePath: string, branchName?: string, limit?: number) =>
|
||||
this.post('/api/worktree/branch-commit-log', { worktreePath, branchName, limit }),
|
||||
getTestLogs: (worktreePath?: string, sessionId?: string): Promise<TestLogsResponse> => {
|
||||
const params = new URLSearchParams();
|
||||
if (worktreePath) params.append('worktreePath', worktreePath);
|
||||
@@ -2582,6 +2598,7 @@ export class HttpApiClient implements ElectronAPI {
|
||||
showInitScriptIndicator?: boolean;
|
||||
defaultDeleteBranchWithWorktree?: boolean;
|
||||
autoDismissInitScriptIndicator?: boolean;
|
||||
worktreeCopyFiles?: string[];
|
||||
lastSelectedSessionId?: string;
|
||||
testCommand?: string;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user