@@ -107,12 +107,12 @@ func confirmSubmission(allowPreview bool, allowMetadata bool) (Action, error) {
107107 }
108108}
109109
110- func selectTemplate (templatePaths []string , metadataType metadataStateType ) (string , error ) {
110+ func selectTemplate (nonLegacyTemplatePaths []string , legacyTemplatePath * string , metadataType metadataStateType ) (string , error ) {
111111 templateResponse := struct {
112112 Index int
113113 }{}
114- templateNames := make ([]string , 0 , len (templatePaths ))
115- for _ , p := range templatePaths {
114+ templateNames := make ([]string , 0 , len (nonLegacyTemplatePaths ))
115+ for _ , p := range nonLegacyTemplatePaths {
116116 templateNames = append (templateNames , githubtemplate .ExtractName (p ))
117117 }
118118 if metadataType == issueMetadata {
@@ -134,14 +134,19 @@ func selectTemplate(templatePaths []string, metadataType metadataStateType) (str
134134 return "" , fmt .Errorf ("could not prompt: %w" , err )
135135 }
136136
137- if templateResponse .Index == len (templatePaths ) { // the user has selected the blank template
138- return "" , nil
137+ if templateResponse .Index == len (nonLegacyTemplatePaths ) { // the user has selected the blank template
138+ if legacyTemplatePath != nil {
139+ templateContents := githubtemplate .ExtractContents (* legacyTemplatePath )
140+ return string (templateContents ), nil
141+ } else {
142+ return "" , nil
143+ }
139144 }
140- templateContents := githubtemplate .ExtractContents (templatePaths [templateResponse .Index ])
145+ templateContents := githubtemplate .ExtractContents (nonLegacyTemplatePaths [templateResponse .Index ])
141146 return string (templateContents ), nil
142147}
143148
144- func titleBodySurvey (cmd * cobra.Command , issueState * issueMetadataState , apiClient * api.Client , repo ghrepo.Interface , providedTitle , providedBody string , defs defaults , templatePaths []string , allowReviewers , allowMetadata bool ) error {
149+ func titleBodySurvey (cmd * cobra.Command , issueState * issueMetadataState , apiClient * api.Client , repo ghrepo.Interface , providedTitle , providedBody string , defs defaults , nonLegacyTemplatePaths []string , legacyTemplatePath * string , allowReviewers , allowMetadata bool ) error {
145150 editorCommand , err := determineEditor (cmd )
146151 if err != nil {
147152 return err
@@ -151,13 +156,15 @@ func titleBodySurvey(cmd *cobra.Command, issueState *issueMetadataState, apiClie
151156 templateContents := ""
152157
153158 if providedBody == "" {
154- if len (templatePaths ) > 0 {
159+ if len (nonLegacyTemplatePaths ) > 0 {
155160 var err error
156- templateContents , err = selectTemplate (templatePaths , issueState .Type )
161+ templateContents , err = selectTemplate (nonLegacyTemplatePaths , legacyTemplatePath , issueState .Type )
157162 if err != nil {
158163 return err
159164 }
160165 issueState .Body = templateContents
166+ } else if legacyTemplatePath != nil {
167+ issueState .Body = string (githubtemplate .ExtractContents (* legacyTemplatePath ))
161168 } else {
162169 issueState .Body = defs .Body
163170 }
0 commit comments