diff --git a/src/issues/issueFeatureRegistrar.ts b/src/issues/issueFeatureRegistrar.ts index 33e2b2118c..54eae151e9 100644 --- a/src/issues/issueFeatureRegistrar.ts +++ b/src/issues/issueFeatureRegistrar.ts @@ -786,6 +786,8 @@ export class IssueFeatureRegistrar extends Disposable { ...options, title: template.title, body: template.body, + labels: template.labels, + assignees: template.assignees, }; } this.makeNewIssueFile(uri, options); @@ -1136,7 +1138,7 @@ export class IssueFeatureRegistrar extends Disposable { await vscode.workspace.fs.delete(bodyPath); const assigneeLine = `${ASSIGNEES} ${options?.assignees && options.assignees.length > 0 ? options.assignees.map(value => '@' + value).join(', ') + ' ' : '' }`; - const labelLine = `${LABELS} `; + const labelLine = `${LABELS} ${options?.labels && options.labels.length > 0 ? options.labels.join(', ') + ' ' : ''}`; const milestoneLine = `${MILESTONE} `; const projectsLine = `${PROJECTS} `; const cached = this._newIssueCache.get(); @@ -1283,14 +1285,14 @@ ${options?.body ?? ''}\n return choice?.repo; } - private async chooseTemplate(folderManager: FolderRepositoryManager): Promise<{ title: string | undefined, body: string | undefined } | undefined> { + private async chooseTemplate(folderManager: FolderRepositoryManager): Promise { const templateUris = await folderManager.getIssueTemplates(); if (templateUris.length === 0) { - return { title: undefined, body: undefined }; + return { title: undefined, body: undefined, labels: undefined, assignees: undefined, name: undefined, about: undefined }; } interface IssueChoice extends vscode.QuickPickItem { - template: { title: string | undefined, body: string | undefined } | undefined; + template: IssueTemplate | undefined; } const templates = await Promise.all( templateUris @@ -1316,7 +1318,7 @@ ${options?.body ?? ''}\n }); choices.push({ label: vscode.l10n.t('Blank issue'), - template: { title: undefined, body: undefined } + template: { title: undefined, body: undefined, labels: undefined, assignees: undefined, name: undefined, about: undefined } }); const selectedTemplate = await vscode.window.showQuickPick(choices, { @@ -1343,8 +1345,12 @@ ${options?.body ?? ''}\n const title = template.match(/title:\s*(.*)/)?.[1]?.replace(/^["']|["']$/g, ''); const name = template.match(/name:\s*(.*)/)?.[1]?.replace(/^["']|["']$/g, ''); const about = template.match(/about:\s*(.*)/)?.[1]?.replace(/^["']|["']$/g, ''); + const labelsMatch = template.match(/labels:\s*(.*)/)?.[1]; + const labels = labelsMatch ? labelsMatch.split(',').map(label => label.trim()).filter(label => label) : undefined; + const assigneesMatch = template.match(/assignees:\s*(.*)/)?.[1]; + const assignees = assigneesMatch ? assigneesMatch.split(',').map(assignee => assignee.trim()).filter(assignee => assignee) : undefined; const body = template.match(/---([\s\S]*)---([\s\S]*)/)?.[2]; - return { title, name, about, body }; + return { title, name, about, labels, assignees, body }; } private parseYamlTemplate(parsed: YamlIssueTemplate): IssueTemplate { @@ -1352,6 +1358,10 @@ ${options?.body ?? ''}\n const about = parsed.description || parsed.about; const title = parsed.title; + // Extract labels and assignees from YAML + const labels = parsed.labels && Array.isArray(parsed.labels) ? parsed.labels : undefined; + const assignees = parsed.assignees && Array.isArray(parsed.assignees) ? parsed.assignees : undefined; + // Convert YAML body fields to markdown let body = ''; if (parsed.body && Array.isArray(parsed.body)) { @@ -1396,7 +1406,7 @@ ${options?.body ?? ''}\n } } - return { title, name, about, body: body.trim() || undefined }; + return { title, name, about, labels, assignees, body: body.trim() || undefined }; } private async doCreateIssue( diff --git a/src/issues/issueFile.ts b/src/issues/issueFile.ts index de3302d62d..69e0ef6ca3 100644 --- a/src/issues/issueFile.ts +++ b/src/issues/issueFile.ts @@ -14,6 +14,7 @@ export interface NewIssueFileOptions { title?: string; body?: string; assignees?: string[] | undefined, + labels?: string[] | undefined, remote?: Remote, } diff --git a/src/issues/util.ts b/src/issues/util.ts index 39a82e5709..e751ec9d81 100644 --- a/src/issues/util.ts +++ b/src/issues/util.ts @@ -91,6 +91,8 @@ export interface IssueTemplate { name: string | undefined, about: string | undefined, title: string | undefined, + labels: string[] | undefined, + assignees: string[] | undefined, body: string | undefined }