Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions apps/code/src/main/services/git/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1254,12 +1254,14 @@ ${truncatedDiff}${contextSection}`;
]);

const head = currentBranch ?? undefined;
const [branchDiff, stagedDiff, unstagedDiff, commits] = await Promise.all([
getDiffAgainstRemote(directoryPath, defaultBranch),
getStagedDiff(directoryPath),
getUnstagedDiff(directoryPath),
getCommitsBetweenBranches(directoryPath, defaultBranch, head, 30),
]);
const [branchDiff, stagedDiff, unstagedDiff, commits, conventions] =
await Promise.all([
getDiffAgainstRemote(directoryPath, defaultBranch),
getStagedDiff(directoryPath),
getUnstagedDiff(directoryPath),
getCommitsBetweenBranches(directoryPath, defaultBranch, head, 30),
getCommitConventions(directoryPath),
]);

const uncommittedDiff = [stagedDiff, unstagedDiff]
.filter(Boolean)
Expand All @@ -1283,6 +1285,12 @@ ${truncatedDiff}${contextSection}`;
)}`
: "";

const conventionHint = conventions.conventionalCommits
? `- Use conventional commit format for the title (e.g., "feat(scope): description"). Common prefixes: ${
conventions.commonPrefixes.join(", ") || "feat, fix, docs, chore"
}.`
: "";

const system = `You are a PR description generator. Generate a title and detailed description for a pull request.

Output format (use exactly this format):
Expand All @@ -1295,6 +1303,7 @@ Rules for the title:
- Short and descriptive (max 72 chars)
- Use imperative mood ("Add feature" not "Added feature")
- Be specific about what the PR accomplishes
${conventionHint}

Rules for the body:
- Start with a TL;DR section (1-2 sentences summarizing the change)
Expand Down Expand Up @@ -1326,6 +1335,7 @@ ${truncatedDiff || "(no diff available)"}${contextSection}`;
diffLength: fullDiff.length,
hasTemplate: !!prTemplate.template,
hasConversationContext: !!conversationContext,
conventionalCommits: conventions.conventionalCommits,
});

const response = await this.llmGateway.prompt(
Expand Down
Loading