From cb374cf51e7f9905992edc5ea1efdb1739918ec3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 8 Jun 2026 10:36:34 +0000 Subject: [PATCH 1/3] Initial plan From e48b0946bd76f4b894a87fa2ea0b0e9e5e7158b2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 8 Jun 2026 10:44:06 +0000 Subject: [PATCH 2/3] Use local git log as fallback for PR title commit count Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com> --- src/github/createPRViewProvider.ts | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/github/createPRViewProvider.ts b/src/github/createPRViewProvider.ts index f0be3b4f33..c8a56fea2d 100644 --- a/src/github/createPRViewProvider.ts +++ b/src/github/createPRViewProvider.ts @@ -786,13 +786,25 @@ export class CreatePullRequestViewProvider extends BaseCreatePullRequestViewProv name ? titleAndBodyFrom(promiseWithTimeout(this._folderRepositoryManager.getTipCommitMessage(name), 5000)) : undefined, descriptionSource === 'template' ? this.getPullRequestTemplate() : undefined ]); - const totalNonMergeCommits = totalCommits?.filter(commit => commit.parents.length < 2); + let totalNonMergeCommitsCount: number | undefined = totalCommits?.filter(commit => commit.parents.length < 2).length; - Logger.debug(`Total commits: ${totalNonMergeCommits?.length}`, CreatePullRequestViewProvider.ID); - if (totalNonMergeCommits === undefined) { - // There is no upstream branch. Use the last commit as the title and description. + // If we couldn't determine the number of commits from GitHub (e.g. no upstream, or the compare API + // call failed), fall back to the local git log so that we can still match github.com's behavior of + // using the branch name when there is more than one commit. + if (totalNonMergeCommitsCount === undefined) { + try { + const localCommits = await this.model.gitCommits(); + totalNonMergeCommitsCount = localCommits.filter(commit => commit.parents.length < 2).length; + } catch (e) { + Logger.debug(`Error while getting local commits for PR title: ${e}`, CreatePullRequestViewProvider.ID); + } + } + + Logger.debug(`Total commits: ${totalNonMergeCommitsCount}`, CreatePullRequestViewProvider.ID); + if (totalNonMergeCommitsCount === undefined) { + // We couldn't determine the number of commits at all. Use the last commit as the title and description. useBranchName = false; - } else if (totalNonMergeCommits && totalNonMergeCommits.length > 1) { + } else if (totalNonMergeCommitsCount > 1) { const defaultBranch = await origin.getDefaultBranch(); useBranchName = defaultBranch !== compareBranch.name; } From 2dc0b1fce91fddb24cd0c323a50eca64c0ff3b29 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 8 Jun 2026 10:46:10 +0000 Subject: [PATCH 3/3] Improve fallback debug log message Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com> --- src/github/createPRViewProvider.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/github/createPRViewProvider.ts b/src/github/createPRViewProvider.ts index c8a56fea2d..1a9d245633 100644 --- a/src/github/createPRViewProvider.ts +++ b/src/github/createPRViewProvider.ts @@ -796,7 +796,7 @@ export class CreatePullRequestViewProvider extends BaseCreatePullRequestViewProv const localCommits = await this.model.gitCommits(); totalNonMergeCommitsCount = localCommits.filter(commit => commit.parents.length < 2).length; } catch (e) { - Logger.debug(`Error while getting local commits for PR title: ${e}`, CreatePullRequestViewProvider.ID); + Logger.debug(`Failed to retrieve local git commits as fallback for PR title for branch ${name}: ${e}`, CreatePullRequestViewProvider.ID); } }