diff --git a/src/components/Shakespeare/ChatPane.tsx b/src/components/Shakespeare/ChatPane.tsx index 2e255b70..4c6a956a 100644 --- a/src/components/Shakespeare/ChatPane.tsx +++ b/src/components/Shakespeare/ChatPane.tsx @@ -92,7 +92,7 @@ export const ChatPane = forwardRef(({ const customTools = useMemo(() => { const git = new Git(fs); const baseTools = { - git_commit: new GitCommitTool(fs, cwd), + git_commit: new GitCommitTool(fs, cwd, git), text_editor_view: new TextEditorViewTool(fs, cwd), text_editor_write: new TextEditorWriteTool(fs, cwd), text_editor_str_replace: new TextEditorStrReplaceTool(fs, cwd), diff --git a/src/lib/commands/git/clone.ts b/src/lib/commands/git/clone.ts index 7fc8d5ec..2c440e39 100644 --- a/src/lib/commands/git/clone.ts +++ b/src/lib/commands/git/clone.ts @@ -57,15 +57,10 @@ export class GitCloneCommand implements GitSubcommand { // Clone the repository await this.git.clone({ - - http, dir: targetPath, url: repository, singleBranch: options.singleBranch, depth: options.depth, - corsProxy: (url.hostname === 'github.com' || url.hostname === 'gitlab.com') - ? 'https://cors.isomorphic-git.org' - : undefined, }); return createSuccessResult(`Cloning into '${targetDir}'...\ndone.\n`); diff --git a/src/lib/commands/git/commit.ts b/src/lib/commands/git/commit.ts index ac370474..c8f17cf7 100644 --- a/src/lib/commands/git/commit.ts +++ b/src/lib/commands/git/commit.ts @@ -56,12 +56,12 @@ export class GitCommitCommand implements GitSubcommand { try { const configName = await this.git.getConfig({ - + dir: this.pwd, path: 'user.name', }); const configEmail = await this.git.getConfig({ - + dir: this.pwd, path: 'user.email', }); @@ -76,7 +76,7 @@ export class GitCommitCommand implements GitSubcommand { // Get the last commit message if amending try { const commits = await this.git.log({ - + dir: this.pwd, depth: 1, }); @@ -95,7 +95,7 @@ export class GitCommitCommand implements GitSubcommand { let currentBranch = 'main'; try { currentBranch = await this.git.currentBranch({ - + dir: this.pwd, }) || 'main'; } catch { @@ -103,8 +103,7 @@ export class GitCommitCommand implements GitSubcommand { } // Create the commit - const commitOptions: { - fs: JSRuntimeFS; + let commitOptions: { dir: string; message: string; author: { name: string; email: string }; @@ -121,7 +120,6 @@ export class GitCommitCommand implements GitSubcommand { // For amend, we need to reset to the parent of the current commit try { const commits = await this.git.log({ - dir: this.pwd, depth: 2, }); diff --git a/src/lib/tools/GitCommitTool.test.ts b/src/lib/tools/GitCommitTool.test.ts index 382ecc02..f5915e72 100644 --- a/src/lib/tools/GitCommitTool.test.ts +++ b/src/lib/tools/GitCommitTool.test.ts @@ -1,5 +1,6 @@ import { describe, it, expect, vi, beforeEach } from 'vitest'; import { GitCommitTool } from './GitCommitTool'; +import { Git } from '../git'; import type { JSRuntimeFS } from '../JSRuntime'; // Mock the Git class @@ -33,10 +34,12 @@ const mockFS: JSRuntimeFS = { describe('GitCommitTool', () => { let tool: GitCommitTool; + let mockGit: Git; beforeEach(() => { vi.clearAllMocks(); - tool = new GitCommitTool(mockFS, '/test/project'); + mockGit = mockGitInstance as unknown as Git; + tool = new GitCommitTool(mockFS, '/test/project', mockGit); // Setup default mocks mockGitInstance.statusMatrix.mockResolvedValue([ diff --git a/src/lib/tools/GitCommitTool.ts b/src/lib/tools/GitCommitTool.ts index 5f99dacc..123839a9 100644 --- a/src/lib/tools/GitCommitTool.ts +++ b/src/lib/tools/GitCommitTool.ts @@ -19,9 +19,9 @@ export class GitCommitTool implements Tool { message: z.string().describe('Commit message text'), }); - constructor(fs: JSRuntimeFS, cwd: string) { + constructor(fs: JSRuntimeFS, cwd: string, git: Git) { this.fs = fs; - this.git = new Git(fs); + this.git = git; this.cwd = cwd; }