Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,14 @@
"enum": [
"template",
"commit",
"branchName",
"none",
"Copilot"
],
"enumDescriptions": [
"%githubPullRequests.pullRequestDescription.template%",
"%githubPullRequests.pullRequestDescription.commit%",
"%githubPullRequests.pullRequestDescription.branchName%",
"%githubPullRequests.pullRequestDescription.none%",
"%githubPullRequests.pullRequestDescription.copilot%"
],
Expand Down
1 change: 1 addition & 0 deletions package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"githubPullRequests.pullRequestDescription.description": "The description used when creating pull requests.",
"githubPullRequests.pullRequestDescription.template": "Use a pull request template and commit description, or just use the commit description if no templates were found.",
"githubPullRequests.pullRequestDescription.commit": "Use the latest commit message only.",
"githubPullRequests.pullRequestDescription.branchName": "Use the branch name as the pull request title",
"githubPullRequests.pullRequestDescription.none": "Do not have a default description.",
"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.",
"githubPullRequests.defaultCreateOption.description": "The create option that the \"Create\" button will default to when creating a pull request.",
Expand Down
24 changes: 18 additions & 6 deletions src/github/createPRViewProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ export abstract class BaseCreatePullRequestViewProvider<T extends BasePullReques
}
commands.setContext(contexts.CREATE_PR_PERMISSIONS, viewerPermission);

const useCopilot: boolean = !!this.getTitleAndDescriptionProvider('Copilot') && (vscode.workspace.getConfiguration(PR_SETTINGS_NAMESPACE).get<'commit' | 'template' | 'none' | 'Copilot'>(PULL_REQUEST_DESCRIPTION) === 'Copilot');
const useCopilot: boolean = !!this.getTitleAndDescriptionProvider('Copilot') && (vscode.workspace.getConfiguration(PR_SETTINGS_NAMESPACE).get<'commit' | 'template' | 'branchName' | 'none' | 'Copilot'>(PULL_REQUEST_DESCRIPTION) === 'Copilot');
const defaultTitleAndDescriptionProvider = this.getTitleAndDescriptionProvider()?.title;
if (defaultTitleAndDescriptionProvider) {
/* __GDPR__
Expand Down Expand Up @@ -709,8 +709,21 @@ export class CreatePullRequestViewProvider extends BaseCreatePullRequestViewProv
protected async getTitleAndDescription(compareBranch: Branch, baseBranch: string): Promise<{ title: string, description: string }> {
let title: string = '';
let description: string = '';
const descrptionSource = vscode.workspace.getConfiguration(PR_SETTINGS_NAMESPACE).get<'commit' | 'template' | 'none' | 'Copilot'>(PULL_REQUEST_DESCRIPTION);
if (descrptionSource === 'none') {
const descriptionSource = vscode.workspace.getConfiguration(PR_SETTINGS_NAMESPACE).get<'commit' | 'template' | 'branchName' | 'none' | 'Copilot'>(PULL_REQUEST_DESCRIPTION);
if (descriptionSource === 'none') {
return { title, description };
}

const name = compareBranch.name;
const branchNameTitle = (name: string) => {
return `${name.charAt(0).toUpperCase()}${name.slice(1)}`;
};

// If branchName is selected, use the branch name as the title
if (descriptionSource === 'branchName') {
if (name) {
title = branchNameTitle(name);
}
return { title, description };
}

Expand All @@ -722,11 +735,10 @@ export class CreatePullRequestViewProvider extends BaseCreatePullRequestViewProv
let useBranchName = this._pullRequestDefaults.base === compareBranch.name;
Logger.debug(`Compare branch name: ${compareBranch.name}, Base branch name: ${this._pullRequestDefaults.base}`, CreatePullRequestViewProvider.ID);
try {
const name = compareBranch.name;
const [totalCommits, lastCommit, pullRequestTemplate] = await Promise.all([
this.getTotalGitHubCommits(compareBranch, baseBranch),
name ? titleAndBodyFrom(promiseWithTimeout(this._folderRepositoryManager.getTipCommitMessage(name), 5000)) : undefined,
descrptionSource === 'template' ? this.getPullRequestTemplate() : undefined
descriptionSource === 'template' ? this.getPullRequestTemplate() : undefined
]);
const totalNonMergeCommits = totalCommits?.filter(commit => commit.parents.length < 2);

Expand All @@ -748,7 +760,7 @@ export class CreatePullRequestViewProvider extends BaseCreatePullRequestViewProv
}
// Set title
if (useBranchName && name) {
title = `${name.charAt(0).toUpperCase()}${name.slice(1)}`;
title = branchNameTitle(name);
} else if (name && lastCommit) {
title = lastCommit.title;
}
Expand Down