Skip to content

Commit f4f5585

Browse files
author
Tulga Tsogtgerel
committed
fix: correct change detection logic in commitAndPush function
- Replace unreliable git diff --cached --quiet check with git status --porcelain - Add better logging to show detected changes - Fixes issue where changes were made but not committed due to incorrect detection
1 parent 0b472f7 commit f4f5585

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

assistant/src/index.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -226,22 +226,26 @@ async function commitAndPush(
226226
// Stage all changes
227227
await exec.exec('git', ['add', '-A']);
228228

229-
// Check if there are changes to commit
230-
let hasChanges = false;
231-
await exec.exec('git', ['diff', '--cached', '--quiet'], {
232-
ignoreReturnCode: true,
229+
// Check if there are changes to commit using git status
230+
let statusOutput = '';
231+
await exec.exec('git', ['status', '--porcelain'], {
233232
listeners: {
234-
errline: () => {
235-
hasChanges = true;
233+
stdout: (data: Buffer) => {
234+
statusOutput += data.toString();
236235
},
237236
},
238237
});
239238

239+
const hasChanges = statusOutput.trim().length > 0;
240+
240241
if (!hasChanges) {
241242
core.info('ℹ️ No changes to commit');
242243
return;
243244
}
244245

246+
core.info(`📝 Changes detected:\n${statusOutput}`);
247+
248+
245249
// Commit changes
246250
const commitMessage = `feat: implement changes requested in comment #${commentId}
247251

0 commit comments

Comments
 (0)