Make git identity configurable in settings

This commit is contained in:
Alex Gleason committed 2025-10-14 20:36:29 -05:00
1 parent 51f7a42d3e
commit e4c3fc8b05
13 files changed
+270 -108

No files matched your search

-35
View File
@@ -75,14 +75,6 @@ describe('GitCommitTool', () => {
expect(mockGitInstance.commit).toHaveBeenCalledWith({
dir: '/test/project',
message: 'Add new feature',
author: {
name: 'shakespeare.diy',
email: '[email protected]',
},
committer: {
name: 'shakespeare.diy',
email: '[email protected]',
},
});
expect(result).toContain('✅ Successfully committed 2 files (abcd123)');
expect(result).toContain('Add new feature');
@@ -179,34 +171,7 @@ describe('GitCommitTool', () => {
expect(result).toContain('📊 Changes:');
});
it('should use git config when available', async () => {
// Mock .git directory exists
vi.mocked(mockFS.stat).mockResolvedValue({
isDirectory: () => true,
isFile: () => false,
});
// Mock git config
vi.mocked(mockGitInstance.getConfig)
.mockResolvedValueOnce('John Doe') // user.name
.mockResolvedValueOnce('[email protected]'); // user.email
const result = await tool.execute({ message: 'Test commit' });
expect(mockGitInstance.commit).toHaveBeenCalledWith({
dir: '/test/project',
message: 'Test commit',
author: {
name: 'John Doe',
email: '[email protected]',
},
committer: {
name: 'John Doe',
email: '[email protected]',
},
});
expect(result).toContain('✅ Successfully committed');
});
it('should handle very long commit message', async () => {
// Mock .git directory exists
+1 -25
View File
@@ -89,34 +89,10 @@ export class GitCommitTool implements Tool<GitCommitParams> {
// Default to 'main' if we can't get the current branch
}
// Get author info (use default if not configured)
const author = {
name: 'shakespeare.diy',
email: '[email protected]',
};
// Try to get configured author from git config
try {
const configName = await this.git.getConfig({
dir: this.cwd,
path: 'user.name',
});
const configEmail = await this.git.getConfig({
dir: this.cwd,
path: 'user.email',
});
if (configName) author.name = configName;
if (configEmail) author.email = configEmail;
} catch {
// Use defaults if config is not set
}
// Commit the changes
// Commit the changes (author/committer will be set automatically by Git class)
const commitSha = await this.git.commit({
dir: this.cwd,
message: message.trim(),
author,
committer: author,
});
// Get short hash (first 7 characters)