Skip to content

Commit d845ad7

Browse files
Enhance generate rebase function with commits mode support
1 parent ab05f71 commit d845ad7

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

src/commands/generateRebase.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,11 @@ export class GenerateCommitsCommand extends GlCommandBase {
8585
createReference(uncommitted, svc.path, { refType: 'revision' }),
8686
createReference('HEAD', svc.path, { refType: 'revision' }),
8787
args?.source ?? { source: 'commandPalette' },
88-
{ title: 'Generate Commits', progress: { location: ProgressLocation.Notification } },
88+
{
89+
title: 'Generate Commits',
90+
progress: { location: ProgressLocation.Notification },
91+
generateCommits: true,
92+
},
8993
);
9094
} catch (ex) {
9195
Logger.error(ex, 'GenerateCommitsCommand', 'execute');
@@ -165,7 +169,12 @@ export async function generateRebase(
165169
head: GitReference,
166170
base: GitReference,
167171
source: Source,
168-
options?: { title?: string; cancellation?: CancellationToken; progress?: ProgressOptions },
172+
options?: {
173+
title?: string;
174+
cancellation?: CancellationToken;
175+
progress?: ProgressOptions;
176+
generateCommits?: boolean;
177+
},
169178
): Promise<void> {
170179
const { title, ...aiOptions } = options ?? {};
171180

src/plus/ai/aiProviderService.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -871,6 +871,7 @@ export class AIProviderService implements Disposable {
871871
context?: string;
872872
generating?: Deferred<AIModel>;
873873
progress?: ProgressOptions;
874+
generateCommits?: boolean;
874875
},
875876
): Promise<AIRebaseResult | undefined> {
876877
const result: Mutable<AIRebaseResult> = {
@@ -968,7 +969,7 @@ export class AIProviderService implements Disposable {
968969
const messages: AIChatMessage[] = [{ role: 'user', content: prompt }];
969970
return messages;
970971
},
971-
m => `Generating rebase with ${m.name}...`,
972+
m => `Generating ${options?.generateCommits ? 'commits' : 'rebase'} with ${m.name}...`,
972973
source,
973974
m => ({
974975
key: 'ai/generate',
@@ -990,7 +991,7 @@ export class AIProviderService implements Disposable {
990991
result.commits = JSON.parse(content) as AIRebaseResult['commits'];
991992
} catch {
992993
debugger;
993-
throw new Error('Unable to parse rebase result');
994+
throw new Error(`Unable to parse ${options?.generateCommits ? 'commits' : 'rebase'} result`);
994995
}
995996

996997
return {

0 commit comments

Comments
 (0)