Skip to content

Commit 7fe6164

Browse files
Copilotalexr00
andcommitted
Replace createFromTemplate setting with templatePrompt option in pullRequestDescription
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
1 parent 704675f commit 7fe6164

File tree

3 files changed

+7
-29
lines changed

3 files changed

+7
-29
lines changed

package.json

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -145,34 +145,21 @@
145145
"type": "string",
146146
"enum": [
147147
"template",
148+
"templatePrompt",
148149
"commit",
149150
"none",
150151
"Copilot"
151152
],
152153
"enumDescriptions": [
153154
"%githubPullRequests.pullRequestDescription.template%",
155+
"%githubPullRequests.pullRequestDescription.templatePrompt%",
154156
"%githubPullRequests.pullRequestDescription.commit%",
155157
"%githubPullRequests.pullRequestDescription.none%",
156158
"%githubPullRequests.pullRequestDescription.copilot%"
157159
],
158160
"default": "template",
159161
"description": "%githubPullRequests.pullRequestDescription.description%"
160162
},
161-
"githubPullRequests.createFromTemplate": {
162-
"type": "string",
163-
"enum": [
164-
"none",
165-
"first",
166-
"prompt"
167-
],
168-
"enumDescriptions": [
169-
"%githubPullRequests.createFromTemplate.none%",
170-
"%githubPullRequests.createFromTemplate.first%",
171-
"%githubPullRequests.createFromTemplate.prompt%"
172-
],
173-
"default": "first",
174-
"description": "%githubPullRequests.createFromTemplate.description%"
175-
},
176163
"githubPullRequests.defaultCreateOption": {
177164
"type": "string",
178165
"enum": [

package.nls.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,10 @@
33
"description": "Pull Request and Issue Provider for GitHub",
44
"githubPullRequests.pullRequestDescription.description": "The description used when creating pull requests.",
55
"githubPullRequests.pullRequestDescription.template": "Use a pull request template and commit description, or just use the commit description if no templates were found",
6+
"githubPullRequests.pullRequestDescription.templatePrompt": "Prompt to select from available pull request templates when multiple templates exist, otherwise use the first template",
67
"githubPullRequests.pullRequestDescription.commit": "Use the latest commit message only",
78
"githubPullRequests.pullRequestDescription.none": "Do not have a default description",
89
"githubPullRequests.pullRequestDescription.copilot": "Generate a pull request title and description from GitHub Copilot. Requires that the GitHub Copilot extension is installed and authenticated. Will fall back to `commit` if Copilot is not set up.",
9-
"githubPullRequests.createFromTemplate.description": "When multiple pull request templates are available, choose which template to use.",
10-
"githubPullRequests.createFromTemplate.none": "Do not use any template",
11-
"githubPullRequests.createFromTemplate.first": "Use the first template found",
12-
"githubPullRequests.createFromTemplate.prompt": "Prompt to choose which template to use",
1310
"githubPullRequests.defaultCreateOption.description": "The create option that the \"Create\" button will default to when creating a pull request.",
1411
"githubPullRequests.defaultCreateOption.lastUsed": "The most recently used create option.",
1512
"githubPullRequests.defaultCreateOption.create": "The pull request will be created.",

src/github/createPRViewProvider.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ export class CreatePullRequestViewProvider extends BaseCreatePullRequestViewProv
682682
protected async getTitleAndDescription(compareBranch: Branch, baseBranch: string): Promise<{ title: string, description: string }> {
683683
let title: string = '';
684684
let description: string = '';
685-
const descrptionSource = vscode.workspace.getConfiguration(PR_SETTINGS_NAMESPACE).get<'commit' | 'template' | 'none' | 'Copilot'>(PULL_REQUEST_DESCRIPTION);
685+
const descrptionSource = vscode.workspace.getConfiguration(PR_SETTINGS_NAMESPACE).get<'commit' | 'template' | 'templatePrompt' | 'none' | 'Copilot'>(PULL_REQUEST_DESCRIPTION);
686686
if (descrptionSource === 'none') {
687687
return { title, description };
688688
}
@@ -699,7 +699,7 @@ export class CreatePullRequestViewProvider extends BaseCreatePullRequestViewProv
699699
const [totalCommits, lastCommit, pullRequestTemplate] = await Promise.all([
700700
this.getTotalGitHubCommits(compareBranch, baseBranch),
701701
name ? titleAndBodyFrom(promiseWithTimeout(this._folderRepositoryManager.getTipCommitMessage(name), 5000)) : undefined,
702-
descrptionSource === 'template' ? this.getPullRequestTemplate() : undefined
702+
descrptionSource === 'template' ? this._folderRepositoryManager.getPullRequestTemplateBody(this.model.baseOwner) : (descrptionSource === 'templatePrompt' ? this.getPullRequestTemplate() : undefined)
703703
]);
704704
const totalNonMergeCommits = totalCommits?.filter(commit => commit.parents.length < 2);
705705

@@ -757,23 +757,17 @@ export class CreatePullRequestViewProvider extends BaseCreatePullRequestViewProv
757757
}
758758

759759
private async getPullRequestTemplate(): Promise<string | undefined> {
760-
const createFromTemplate = vscode.workspace.getConfiguration(PR_SETTINGS_NAMESPACE).get<'none' | 'first' | 'prompt'>('createFromTemplate', 'first');
761-
762-
if (createFromTemplate === 'none') {
763-
return undefined;
764-
}
765-
766760
const templates = await this._folderRepositoryManager.getAllPullRequestTemplates(this.model.baseOwner);
767761

768762
if (!templates || templates.length === 0) {
769763
return undefined;
770764
}
771765

772-
if (templates.length === 1 || createFromTemplate === 'first') {
766+
if (templates.length === 1) {
773767
return templates[0];
774768
}
775769

776-
// createFromTemplate === 'prompt' and multiple templates exist
770+
// Multiple templates exist - show quick pick
777771
const selectedTemplate = await vscode.window.showQuickPick(
778772
templates.map((template, index) => {
779773
// Try to extract a meaningful name from the template (first line or first few chars)

0 commit comments

Comments
 (0)