mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-11-23 20:54:50 +03:00
Fixes a bug with generating branch names
This commit is contained in:
parent
7fe5d0c85e
commit
40cffe091b
@ -62,7 +62,7 @@ interface SummarizeCommitOpts extends BaseAIServiceOpts {
|
||||
}
|
||||
|
||||
interface SummarizeBranchOpts extends BaseAIServiceOpts {
|
||||
hunks: Hunk[];
|
||||
hunks: DiffInput[];
|
||||
branchTemplate?: Prompt;
|
||||
}
|
||||
|
||||
@ -75,8 +75,13 @@ interface SummarizePROpts extends BaseAIServiceOpts {
|
||||
prBodyTemplate?: string;
|
||||
}
|
||||
|
||||
interface DiffInput {
|
||||
filePath: string;
|
||||
diff: string;
|
||||
}
|
||||
|
||||
// Exported for testing only
|
||||
export function buildDiff(hunks: Hunk[], limit: number) {
|
||||
export function buildDiff(hunks: DiffInput[], limit: number) {
|
||||
return shuffle(hunks.map((h) => `${h.filePath} - ${h.diff}`))
|
||||
.join('\n')
|
||||
.slice(0, limit);
|
||||
|
@ -23,6 +23,7 @@
|
||||
import { isFailure } from '$lib/result';
|
||||
import { openExternalUrl } from '$lib/utils/url';
|
||||
import { BranchController } from '$lib/vbranches/branchController';
|
||||
import { listCommitFiles } from '$lib/vbranches/remoteCommits';
|
||||
import { PatchSeries, VirtualBranch, type CommitStatus } from '$lib/vbranches/types';
|
||||
import { CloudBranchesService } from '@gitbutler/shared/cloud/stacks/service';
|
||||
import { getContext, getContextStore } from '@gitbutler/shared/context';
|
||||
@ -140,7 +141,15 @@
|
||||
async function generateBranchName() {
|
||||
if (!aiGenEnabled || !currentSeries) return;
|
||||
|
||||
const hunks = currentSeries.patches.flatMap((p) => p.files.flatMap((f) => f.hunks));
|
||||
let hunk_promises = currentSeries.patches.flatMap(async (p) => {
|
||||
let files = await listCommitFiles(project.id, p.id);
|
||||
return files.flatMap((f) =>
|
||||
f.hunks.map((h) => {
|
||||
return { filePath: f.path, diff: h.diff };
|
||||
})
|
||||
);
|
||||
});
|
||||
let hunks = (await Promise.all(hunk_promises)).flat();
|
||||
|
||||
const prompt = promptService.selectedBranchPrompt(project.id);
|
||||
const messageResult = await aiService.summarizeBranch({
|
||||
|
Loading…
Reference in New Issue
Block a user