Skip to content

Commit d211702

Browse files
committed
Includes log to generating Pull Request details
(vscode-gitlens-private#43, #4177)
1 parent e32f100 commit d211702

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/plus/ai/aiProviderService.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,10 +532,21 @@ export class AIProviderService implements Disposable {
532532
): Promise<AISummarizeResult | undefined> {
533533
const diff = await repo.git.diff().getDiff?.(compareRef, baseRef);
534534

535+
const log = await this.container.git.commits(repo.path).getLog(`${baseRef}..${compareRef}`);
536+
const commits: [string, number][] = [];
537+
for (const [_sha, commit] of log?.commits ?? []) {
538+
commits.push([commit.message ?? '', commit.date.getTime()]);
539+
}
540+
541+
if (!diff?.contents && !commits.length) {
542+
throw new Error('No changes found to generate a pull request message from.');
543+
}
544+
535545
const result = await this.sendRequest(
536546
'generate-commitMessage',
537547
() => ({
538-
diff: diff?.contents ?? '[no code changes]',
548+
diff: diff?.contents ?? '',
549+
data: commits.sort((a, b) => a[1] - b[1]).map(c => c[0]),
539550
context: options?.context ?? '',
540551
instructions: configuration.get('ai.generateCommitMessage.customInstructions') ?? '',
541552
}),

0 commit comments

Comments
 (0)