Skip to content

Commit 707c7ae

Browse files
committed
Generates title and body for GitLab merge request using AI
(vscode-gitlens-private#43, #4177)
1 parent 7135c33 commit 707c7ae

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/git/remotes/gitlab.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,11 @@ export class GitLabRemote extends RemoteProvider<GitLabRepositoryDescriptor> {
395395
protected override async getUrlForCreatePullRequest(
396396
base: { branch?: string; remote: { path: string; url: string } },
397397
head: { branch: string; remote: { path: string; url: string } },
398-
options?: { title?: string; description?: string },
398+
options?: {
399+
title?: string;
400+
description?: string;
401+
describePullRequest?: () => Promise<{ summary: string; body: string } | undefined>;
402+
},
399403
): Promise<string | undefined> {
400404
const query = new URLSearchParams({
401405
utf8: '✓',
@@ -425,6 +429,15 @@ export class GitLabRemote extends RemoteProvider<GitLabRepositoryDescriptor> {
425429
if (options?.description) {
426430
query.set('merge_request[description]', options.description);
427431
}
432+
if ((!options?.title || !options?.description) && options?.describePullRequest) {
433+
const result = await options.describePullRequest();
434+
if (result?.summary) {
435+
query.set('merge_request[title]', result.summary);
436+
}
437+
if (result?.body) {
438+
query.set('merge_request[description]', result.body);
439+
}
440+
}
428441

429442
return `${this.encodeUrl(`${this.getRepoBaseUrl(head.remote.path)}/-/merge_requests/new`)}?${query.toString()}`;
430443
}

0 commit comments

Comments
 (0)