diff --git a/src/@types/vscode.proposed.chatSessionsProvider.d.ts b/src/@types/vscode.proposed.chatSessionsProvider.d.ts index 772fc387b9..2ec68c1731 100644 --- a/src/@types/vscode.proposed.chatSessionsProvider.d.ts +++ b/src/@types/vscode.proposed.chatSessionsProvider.d.ts @@ -49,26 +49,6 @@ declare module 'vscode' { */ readonly onDidCommitChatSessionItem: Event<{ original: ChatSessionItem /** untitled */; modified: ChatSessionItem /** newly created */ }>; - /** - * DEPRECATED: Will be removed! - * Creates a new chat session. - * - * @param options Options for the new session including an optional initial prompt and history - * @param token A cancellation token - * @returns Metadata for the chat session - */ - provideNewChatSessionItem?(options: { - /** - * The chat request that initiated the session creation - */ - readonly request: ChatRequest; - - /** - * Additional metadata to use for session creation - */ - metadata?: any; - }, token: CancellationToken): ProviderResult; - // #endregion } @@ -241,6 +221,14 @@ declare module 'vscode' { */ readonly onDidChangeChatSessionOptions?: Event; + /** + * Event that the provider can fire to signal that the available provider options have changed. + * + * When fired, the editor will re-query {@link ChatSessionContentProvider.provideChatSessionProviderOptions} + * and update the UI to reflect the new option groups. + */ + readonly onDidChangeChatSessionProviderOptions?: Event; + /** * Provides the chat session content for a given uri. * diff --git a/src/github/loggingOctokit.ts b/src/github/loggingOctokit.ts index 09813b75ae..c6b83f0975 100644 --- a/src/github/loggingOctokit.ts +++ b/src/github/loggingOctokit.ts @@ -150,8 +150,8 @@ export class LoggingOctokit { } } -export async function compareCommits(remote: GitHubRemote, octokit: LoggingOctokit, base: GitHubRef, head: GitHubRef, compareWithBaseRef: string, prNumber: number, logId: string): Promise<{ mergeBaseSha: string; files: IRawFileChange[] }> { - Logger.debug(`Comparing commits for ${remote.owner}/${remote.repositoryName} with base ${base.repositoryCloneUrl.owner}:${compareWithBaseRef} and head ${head.repositoryCloneUrl.owner}:${head.sha}`, logId); +export async function compareCommits(remote: GitHubRemote, octokit: LoggingOctokit, base: GitHubRef, head: GitHubRef, compareWithBaseRef: string, prNumber: number, logId: string, excludeMergeCommits: boolean = false): Promise<{ mergeBaseSha: string; files: IRawFileChange[] }> { + Logger.debug(`Comparing commits for ${remote.owner}/${remote.repositoryName} with base ${base.repositoryCloneUrl.owner}:${compareWithBaseRef} and head ${head.repositoryCloneUrl.owner}:${head.sha}${excludeMergeCommits ? ' (excluding merge commits)' : ''}`, logId); let files: IRawFileChange[] | undefined; let mergeBaseSha: string | undefined; @@ -164,12 +164,27 @@ export async function compareCommits(remote: GitHubRemote, octokit: LoggingOctok }; try { - const { data } = await octokit.call(octokit.api.repos.compareCommits, { - repo: remote.repositoryName, - owner: remote.owner, - base: `${base.repositoryCloneUrl.owner}:${compareWithBaseRef}`, - head: `${head.repositoryCloneUrl.owner}:${head.sha}`, - }); + let data: any; + if (excludeMergeCommits) { + // Use three-dot syntax to show only changes unique to the head branch since it diverged from the base. + // This naturally excludes changes from merge commits. + const basehead = `${base.repositoryCloneUrl.owner}:${compareWithBaseRef}...${head.repositoryCloneUrl.owner}:${head.sha}`; + const response = await octokit.call(octokit.api.repos.compareCommitsWithBasehead, { + repo: remote.repositoryName, + owner: remote.owner, + basehead, + }); + data = response.data; + } else { + // Use the default comparison (equivalent to two-dot) which shows all changes between base and head. + const response = await octokit.call(octokit.api.repos.compareCommits, { + repo: remote.repositoryName, + owner: remote.owner, + base: `${base.repositoryCloneUrl.owner}:${compareWithBaseRef}`, + head: `${head.repositoryCloneUrl.owner}:${head.sha}`, + }); + data = response.data; + } const MAX_FILE_CHANGES_IN_COMPARE_COMMITS = 100; if (data.files && data.files.length >= MAX_FILE_CHANGES_IN_COMPARE_COMMITS) { @@ -191,5 +206,5 @@ export async function compareCommits(remote: GitHubRemote, octokit: LoggingOctok throw e; } } - return { mergeBaseSha, files }; + return { mergeBaseSha: mergeBaseSha!, files: files! }; } diff --git a/src/github/pullRequestModel.ts b/src/github/pullRequestModel.ts index d984d19b93..37ef4769a8 100644 --- a/src/github/pullRequestModel.ts +++ b/src/github/pullRequestModel.ts @@ -1793,7 +1793,7 @@ export class PullRequestModel extends IssueModel implements IPullRe } Logger.debug(`Comparing commits for ${remote.owner}/${remote.repositoryName} with base ${this.base.repositoryCloneUrl.owner}:${compareWithBaseRef} and head ${this.head!.repositoryCloneUrl.owner}:${this.head!.sha}`, PullRequestModel.ID); - const { files, mergeBaseSha } = await compareCommits(remote, octokit, this.base, this.head!, compareWithBaseRef, this.number, PullRequestModel.ID); + const { files, mergeBaseSha } = await compareCommits(remote, octokit, this.base, this.head!, compareWithBaseRef, this.number, PullRequestModel.ID, this._showChangesSinceReview); this.mergeBase = mergeBaseSha; if (oldHasChangesSinceReview !== undefined && oldHasChangesSinceReview !== this.hasChangesSinceLastReview && this.hasChangesSinceLastReview && this._showChangesSinceReview) {