11import { window } from 'vscode' ;
2+ import type { Sources } from '../constants.telemetry' ;
23import type { Container } from '../container' ;
34import type { GitRemote } from '../git/models/remote' ;
45import type { RemoteResource } from '../git/models/remoteResource' ;
@@ -17,6 +18,8 @@ export interface CreatePullRequestOnRemoteCommandArgs {
1718 repoPath : string ;
1819
1920 clipboard ?: boolean ;
21+ source ?: Sources ;
22+ useAI ?: boolean ;
2023}
2124
2225@command ( )
@@ -74,26 +77,31 @@ export class CreatePullRequestOnRemoteCommand extends GlCommandBase {
7477 branch : args . compare ,
7578 remote : { path : compareRemote . path , url : compareRemote . url , name : compareRemote . name } ,
7679 } ,
77- describePullRequest : async (
78- completedResource : RemoteResource & { type : RemoteResourceType . CreatePullRequest } ,
79- ) => {
80- const base = completedResource . base ;
81- const compare = completedResource . compare ;
82- if ( ! base ?. remote || ! compare ?. remote || ! base ?. branch || ! compare ?. branch ) {
83- return undefined ;
84- }
85- const baseRef = `${ base . remote . name } /${ base . branch } ` ;
86- const compareRef = `${ compare . remote . name } /${ compare . branch } ` ;
87- try {
88- const result = await this . container . ai . generatePullRequestMessage ( repo , baseRef , compareRef , {
89- source : 'scm-input' ,
90- } ) ;
91- return result ?. parsed ;
92- } catch ( e ) {
93- void window . showErrorMessage ( `Unable to generate pull request message: ${ e } ` ) ;
94- return undefined ;
95- }
96- } ,
80+ describePullRequest : ! args . useAI
81+ ? undefined
82+ : async ( completedResource : RemoteResource & { type : RemoteResourceType . CreatePullRequest } ) => {
83+ const base = completedResource . base ;
84+ const compare = completedResource . compare ;
85+ if ( ! base ?. remote || ! compare ?. remote || ! base ?. branch || ! compare ?. branch ) {
86+ return undefined ;
87+ }
88+ const baseRef = `${ base . remote . name } /${ base . branch } ` ;
89+ const compareRef = `${ compare . remote . name } /${ compare . branch } ` ;
90+ try {
91+ const result = await this . container . ai . generatePullRequestMessage (
92+ repo ,
93+ baseRef ,
94+ compareRef ,
95+ {
96+ source : args . source ?? 'scm-input' ,
97+ } ,
98+ ) ;
99+ return result ?. parsed ;
100+ } catch ( e ) {
101+ void window . showErrorMessage ( `Unable to generate pull request message: ${ e } ` ) ;
102+ return undefined ;
103+ }
104+ } ,
97105 } ;
98106
99107 void ( await executeCommand < OpenOnRemoteCommandArgs > ( 'gitlens.openOnRemote' , {
0 commit comments