@@ -807,7 +807,31 @@ export class CreatePullRequestViewProvider extends BaseCreatePullRequestViewProv
807807 const templates = await this . _folderRepositoryManager . getAllPullRequestTemplates ( this . model . baseOwner ) ;
808808
809809 if ( ! templates || templates . length === 0 ) {
810- vscode . window . showQuickPick ( [ vscode . l10n . t ( 'No pull request templates found' ) ] ) ;
810+ // No templates found - show helpful options
811+ const learnMore = vscode . l10n . t ( 'Learn More' ) ;
812+ const createTemplate = vscode . l10n . t ( 'Create Template' ) ;
813+ const selected = await vscode . window . showQuickPick (
814+ [
815+ {
816+ label : createTemplate ,
817+ description : vscode . l10n . t ( 'Create a new pull request template' )
818+ } ,
819+ {
820+ label : learnMore ,
821+ description : vscode . l10n . t ( 'Open GitHub documentation' )
822+ }
823+ ] ,
824+ {
825+ placeHolder : vscode . l10n . t ( 'No pull request templates found' ) ,
826+ ignoreFocusOut : true
827+ }
828+ ) ;
829+
830+ if ( selected ?. label === learnMore ) {
831+ vscode . env . openExternal ( vscode . Uri . parse ( 'https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/creating-a-pull-request-template-for-your-repository' ) ) ;
832+ } else if ( selected ?. label === createTemplate ) {
833+ await this . createPullRequestTemplate ( ) ;
834+ }
811835 return this . _replyMessage ( message , undefined ) ;
812836 }
813837
@@ -838,6 +862,83 @@ export class CreatePullRequestViewProvider extends BaseCreatePullRequestViewProv
838862 return this . _replyMessage ( message , undefined ) ;
839863 }
840864
865+ private async createPullRequestTemplate ( ) : Promise < void > {
866+ // Show options for where to create the template
867+ const templateLocations = [
868+ {
869+ label : '.github/pull_request_template.md' ,
870+ description : vscode . l10n . t ( 'Default location for a single template' )
871+ } ,
872+ {
873+ label : 'docs/pull_request_template.md' ,
874+ description : vscode . l10n . t ( 'Alternative location in docs folder' )
875+ } ,
876+ {
877+ label : '.github/PULL_REQUEST_TEMPLATE/template.md' ,
878+ description : vscode . l10n . t ( 'For multiple templates' )
879+ }
880+ ] ;
881+
882+ const selected = await vscode . window . showQuickPick ( templateLocations , {
883+ placeHolder : vscode . l10n . t ( 'Choose where to create the pull request template' ) ,
884+ ignoreFocusOut : true
885+ } ) ;
886+
887+ if ( ! selected ) {
888+ return ;
889+ }
890+
891+ // Get the repository root
892+ const workspaceFolder = this . _folderRepositoryManager . repository . rootUri ;
893+ const templatePath = vscode . Uri . joinPath ( workspaceFolder , selected . label ) ;
894+
895+ // Default template content
896+ const templateContent = `## Description
897+ <!-- Please include a summary of the changes and the related issue. -->
898+
899+ ## Type of change
900+ <!-- Please delete options that are not relevant. -->
901+ - [ ] Bug fix (non-breaking change which fixes an issue)
902+ - [ ] New feature (non-breaking change which adds functionality)
903+ - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
904+ - [ ] Documentation update
905+
906+ ## How Has This Been Tested?
907+ <!-- Please describe the tests that you ran to verify your changes. -->
908+
909+ ## Checklist:
910+ - [ ] My code follows the style guidelines of this project
911+ - [ ] I have performed a self-review of my code
912+ - [ ] I have commented my code, particularly in hard-to-understand areas
913+ - [ ] I have made corresponding changes to the documentation
914+ - [ ] My changes generate no new warnings
915+ - [ ] I have added tests that prove my fix is effective or that my feature works
916+ - [ ] New and existing unit tests pass locally with my changes
917+ ` ;
918+
919+ try {
920+ // Create parent directories if they don't exist
921+ const parentDir = vscode . Uri . joinPath ( templatePath , '..' ) ;
922+ await vscode . workspace . fs . createDirectory ( parentDir ) ;
923+
924+ // Create the template file
925+ const encoder = new TextEncoder ( ) ;
926+ await vscode . workspace . fs . writeFile ( templatePath , encoder . encode ( templateContent ) ) ;
927+
928+ // Open the file for editing
929+ const document = await vscode . workspace . openTextDocument ( templatePath ) ;
930+ await vscode . window . showTextDocument ( document ) ;
931+
932+ vscode . window . showInformationMessage (
933+ vscode . l10n . t ( 'Pull request template created at {0}' , selected . label )
934+ ) ;
935+ } catch ( error ) {
936+ vscode . window . showErrorMessage (
937+ vscode . l10n . t ( 'Failed to create pull request template: {0}' , error instanceof Error ? error . message : String ( error ) )
938+ ) ;
939+ }
940+ }
941+
841942 protected async detectBaseMetadata ( defaultCompareBranch : Branch ) : Promise < BaseBranchMetadata | undefined > {
842943 const owner = this . model . compareOwner ;
843944 const repositoryName = this . model . repositoryName ;
0 commit comments