Skip to content

Commit 34f5ca1

Browse files
committed
Fixes error case when there are no changes
1 parent c485aac commit 34f5ca1

File tree

2 files changed

+2
-8
lines changed

2 files changed

+2
-8
lines changed

src/commands/generateCommitMessage.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { TextEditor, Uri } from 'vscode';
2-
import { ProgressLocation, window } from 'vscode';
2+
import { ProgressLocation } from 'vscode';
33
import type { Sources } from '../constants.telemetry';
44
import type { Container } from '../container';
55
import { GitUri } from '../git/gitUri';
@@ -82,12 +82,6 @@ export class GenerateCommitMessageCommand extends ActiveEditorCommand {
8282
}`;
8383
} catch (ex) {
8484
Logger.error(ex, 'GenerateCommitMessageCommand');
85-
86-
if (ex instanceof Error && ex.message.startsWith('No changes')) {
87-
void window.showInformationMessage('No changes to generate a commit message from.');
88-
return;
89-
}
90-
9185
void showGenericErrorMessage(ex.message);
9286
}
9387
}

src/plus/ai/aiProviderService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1847,7 +1847,7 @@ export class AIProviderService implements Disposable {
18471847
let diff = await changesOrRepo.git.diff.getDiff?.(uncommittedStaged);
18481848
if (!diff?.contents) {
18491849
diff = await changesOrRepo.git.diff.getDiff?.(uncommitted);
1850-
if (!diff?.contents) throw new Error('No changes to generate a commit message from.');
1850+
if (!diff?.contents) throw new AINoRequestDataError('No changes to generate a commit message from.');
18511851
}
18521852
if (options?.cancellation?.isCancellationRequested) return undefined;
18531853

0 commit comments

Comments
 (0)