korekt-cli 0.9.6 → 0.9.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "korekt-cli",
3
- "version": "0.9.6",
3
+ "version": "0.9.7",
4
4
  "description": "AI-powered code review CLI - Keep your kode korekt",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -259,6 +259,64 @@ describe('runLocalReview - branch fetching', () => {
259
259
  });
260
260
  });
261
261
 
262
+ describe('runLocalReview - no files changed', () => {
263
+ beforeEach(() => {
264
+ vi.mock('execa');
265
+ vi.spyOn(console, 'error').mockImplementation(() => {});
266
+ });
267
+
268
+ afterEach(() => {
269
+ vi.restoreAllMocks();
270
+ });
271
+
272
+ it('should return payload with empty changed_files when diff has no files', async () => {
273
+ vi.mocked(execa).mockImplementation(async (cmd, args) => {
274
+ const command = [cmd, ...args].join(' ');
275
+
276
+ if (command.includes('remote get-url origin')) {
277
+ return { stdout: 'https://github.com/user/repo.git' };
278
+ }
279
+ if (command.includes('rev-parse --abbrev-ref HEAD')) {
280
+ return { stdout: 'feature-branch' };
281
+ }
282
+ if (command === 'git rev-parse HEAD') {
283
+ return { stdout: 'abc123def456789' };
284
+ }
285
+ if (command.includes('rev-parse --show-toplevel')) {
286
+ return { stdout: '/path/to/repo' };
287
+ }
288
+ if (command.includes('rev-parse --verify main')) {
289
+ return { stdout: 'commit-hash' };
290
+ }
291
+ if (command === 'git fetch origin main') {
292
+ return { stdout: '' };
293
+ }
294
+ if (command.includes('merge-base origin/main HEAD')) {
295
+ return { stdout: 'abc123' };
296
+ }
297
+ if (command.includes('log --no-merges --pretty=%B---EOC---')) {
298
+ return { stdout: 'feat: some commit---EOC---' };
299
+ }
300
+ if (command.includes('log --no-merges --format=%ae|%an')) {
301
+ return { stdout: 'user@example.com|User Name' };
302
+ }
303
+ // No files changed
304
+ if (command.includes('diff --name-status')) {
305
+ return { stdout: '' };
306
+ }
307
+
308
+ return { stdout: '' };
309
+ });
310
+
311
+ const result = await runLocalReview('main');
312
+
313
+ expect(result).not.toBeNull();
314
+ expect(result.changed_files).toEqual([]);
315
+ expect(result.source_branch).toBe('feature-branch');
316
+ expect(result.destination_branch).toBe('main');
317
+ });
318
+ });
319
+
262
320
  describe('runLocalReview - fork point detection', () => {
263
321
  beforeEach(() => {
264
322
  vi.mock('execa');
package/src/index.js CHANGED
@@ -165,6 +165,12 @@ program
165
165
  process.exit(1);
166
166
  }
167
167
 
168
+ // Exit successfully if no files to review (common in CI when PR has no code changes)
169
+ if (payload.changed_files.length === 0) {
170
+ log(chalk.green('āœ“ No files changed to review. Exiting successfully.'));
171
+ return;
172
+ }
173
+
168
174
  // If dry-run, just show the payload and exit
169
175
  if (options.dryRun) {
170
176
  log(chalk.yellow('\nšŸ“‹ Dry Run - Payload that would be sent:\n'));