Skip to content

Fix new PR title to match github.com when branch has multiple commits#8773

Draft
Copilot wants to merge 3 commits into
mainfrom
copilot/add-dvt-setup
Draft

Fix new PR title to match github.com when branch has multiple commits#8773
Copilot wants to merge 3 commits into
mainfrom
copilot/add-dvt-setup

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jun 8, 2026

Creating a new PR via the extension always used the last commit's title, even when the branch had multiple commits — github.com uses the branch name in that case.

CreatePullRequestViewProvider.getTitleAndDescription already intended to mirror github.com (branch name for >1 commits, commit title for 1), but its commit count came solely from the GitHub compareCommits API via getTotalGitHubCommits. That call returns undefined when the compare branch has no upstream, the head GitHub repo can't be resolved by remote name, or the API otherwise fails, at which point the code set useBranchName = false unconditionally and fell back to the tip commit's title.

Changes

  • src/github/createPRViewProvider.ts: when the GitHub commit count is unavailable, fall back to a local git log via this.model.gitCommits() (already runs git log <baseRemote>/<base>..<compare>), filter out merge commits, and feed that count into the existing branch-name-vs-commit-title decision. If both sources fail, behavior is unchanged (uses tip commit). Description logic keyed off !useBranchName benefits automatically.
let totalNonMergeCommitsCount: number | undefined =
    totalCommits?.filter(c => c.parents.length < 2).length;

if (totalNonMergeCommitsCount === undefined) {
    try {
        const localCommits = await this.model.gitCommits();
        totalNonMergeCommitsCount = localCommits.filter(c => c.parents.length < 2).length;
    } catch (e) {
        Logger.debug(`Failed to retrieve local git commits as fallback for PR title for branch ${name}: ${e}`, CreatePullRequestViewProvider.ID);
    }
}

Copilot AI linked an issue Jun 8, 2026 that may be closed by this pull request
Copilot AI and others added 2 commits June 8, 2026 10:44
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix PR title mismatch between extension and GitHub Fix new PR title to match github.com when branch has multiple commits Jun 8, 2026
Copilot AI requested a review from alexr00 June 8, 2026 10:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

New PR title doesn't match behavior on github.com

2 participants