Skip to content

Commit 3e24502

Browse files
committed
🔧 Refactor commit output and logging for cleaner presentation
- Simplify commit message and output display using a consistent separator - Remove duplicate logging and reduce verbosity in commit and cache processes - Enhance test setup for commit cache by explicitly enabling cache
1 parent 5f89cdc commit 3e24502

File tree

2 files changed

+10
-13
lines changed

2 files changed

+10
-13
lines changed

src/commands/commit.ts

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ const generateCommitMessageFromGitDiff = async ({
8484
commitGenerationSpinner.stop('📝 Commit message generated');
8585
Logger.spinnerSuccess('Commit message generated');
8686

87-
const separator = '——————————————————';
87+
const separator = '─'.repeat(50);
8888
const messageBox = `Generated commit message:\n│ ${chalk.grey(separator)}\n│ ${commitMessage}\n│ ${chalk.grey(separator)}`;
8989
outro(messageBox);
9090
// Remove duplicate logging
@@ -125,8 +125,8 @@ const generateCommitMessageFromGitDiff = async ({
125125
await CommitCache.clearCache();
126126
Logger.debug('Cleared commit cache');
127127

128-
outro(stdout);
129-
Logger.info(stdout);
128+
// Only output git commit result once
129+
outro(`│ ${stdout}`);
130130

131131
const remotes = await getGitRemotes();
132132

@@ -354,7 +354,7 @@ export async function commit(
354354
Logger.spinner('Files counted');
355355

356356
Logger.info('Found cached commit message');
357-
const separator = '——————————————————';
357+
const separator = '─'.repeat(50);
358358
const useCachedMessage = await confirm({
359359
message: `Found cached commit message for the same files. Use it?\n│ ${chalk.grey(separator)}\n│ ${cachedCommit.message}\n│ ${chalk.grey(separator)}`
360360
});
@@ -387,15 +387,8 @@ export async function commit(
387387
await CommitCache.clearCache();
388388
Logger.debug('Cleared commit cache');
389389

390-
// Combine the output into a single message
391-
const commitOutput = [
392-
stdout,
393-
`Logs: ${Logger.getLogPath()}`
394-
].join('\n│ ');
395-
outro(commitOutput);
396-
397-
// Remove duplicate logging
398-
Logger.debug('Commit output:', stdout);
390+
// Only output git commit result once
391+
outro(`│ ${stdout}`);
399392

400393
process.exit(0);
401394
} catch (error: any) {

test/unit/commitCache.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ describe('CommitCache', () => {
2222
echo "test" > test.txt
2323
git add test.txt
2424
`);
25+
26+
// Ensure cache is enabled for tests
27+
process.env.OCO_ENABLE_CACHE = 'true';
2528
});
2629

2730
beforeEach(() => {
@@ -37,6 +40,7 @@ describe('CommitCache', () => {
3740
afterAll(() => {
3841
// Clean up test repositories
3942
execSync(`rm -rf "${TEST_DIR}"`);
43+
delete process.env.OCO_ENABLE_CACHE;
4044
});
4145

4246
it('should save and retrieve commit message', async () => {

0 commit comments

Comments
 (0)