Skip to content

Commit 045c75c

Browse files
Copilotalexr00
andcommitted
Add branchName option to pullRequestDescription setting
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
1 parent 1ab5d7b commit 045c75c

3 files changed

Lines changed: 13 additions & 1 deletion

File tree

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,14 @@
146146
"enum": [
147147
"template",
148148
"commit",
149+
"branchName",
149150
"none",
150151
"Copilot"
151152
],
152153
"enumDescriptions": [
153154
"%githubPullRequests.pullRequestDescription.template%",
154155
"%githubPullRequests.pullRequestDescription.commit%",
156+
"%githubPullRequests.pullRequestDescription.branchName%",
155157
"%githubPullRequests.pullRequestDescription.none%",
156158
"%githubPullRequests.pullRequestDescription.copilot%"
157159
],

package.nls.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
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",
66
"githubPullRequests.pullRequestDescription.commit": "Use the latest commit message only",
7+
"githubPullRequests.pullRequestDescription.branchName": "Use the branch name as the pull request title",
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.",
910
"githubPullRequests.defaultCreateOption.description": "The create option that the \"Create\" button will default to when creating a pull request.",

src/github/createPRViewProvider.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -682,11 +682,20 @@ 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' | 'branchName' | 'none' | 'Copilot'>(PULL_REQUEST_DESCRIPTION);
686686
if (descrptionSource === 'none') {
687687
return { title, description };
688688
}
689689

690+
// If branchName is selected, use the branch name as the title
691+
if (descrptionSource === 'branchName') {
692+
const name = compareBranch.name;
693+
if (name) {
694+
title = `${name.charAt(0).toUpperCase()}${name.slice(1)}`;
695+
}
696+
return { title, description };
697+
}
698+
690699
// Use same default as GitHub, if there is only one commit, use the commit, otherwise use the branch name, as long as it is not the default branch.
691700
// By default, the base branch we use for comparison is the base branch of origin. Compare this to the
692701
// compare branch if it has a GitHub remote.

0 commit comments

Comments
 (0)