Skip to content
Draft
Show file tree
Hide file tree
Changes from 4 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
28 changes: 8 additions & 20 deletions src/@types/vscode.proposed.chatSessionsProvider.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<ChatSessionItem>;

// #endregion
}

Expand Down Expand Up @@ -241,6 +221,14 @@ declare module 'vscode' {
*/
readonly onDidChangeChatSessionOptions?: Event<ChatSessionOptionChangeEvent>;

/**
* 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<void>;

/**
* Provides the chat session content for a given uri.
*
Expand Down
15 changes: 10 additions & 5 deletions src/github/loggingOctokit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -164,11 +164,16 @@ export async function compareCommits(remote: GitHubRemote, octokit: LoggingOctok
};

try {
const { data } = await octokit.call(octokit.api.repos.compareCommits, {
// Use three-dot syntax when excluding merge commits to show only changes unique to the head branch
// since it diverged from the base. This naturally excludes changes from merge commits.
// Two-dot syntax (default) shows all changes between base and head, including merge commits.
const dotSeparator = excludeMergeCommits ? '...' : '..';
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot GitHub doesn't appear to support '..'.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're absolutely right! The GitHub API only supports three-dot notation (...), not two-dot (..). I've updated the implementation to:

  • Use the standard compareCommits API with separate base and head parameters for the default comparison
  • Only use three-dot syntax (...) via compareCommitsWithBasehead when excluding merge commits

Fixed in commit 47a70ef.

const basehead = `${base.repositoryCloneUrl.owner}:${compareWithBaseRef}${dotSeparator}${head.repositoryCloneUrl.owner}:${head.sha}`;

const { data } = await octokit.call(octokit.api.repos.compareCommitsWithBasehead, {
repo: remote.repositoryName,
owner: remote.owner,
base: `${base.repositoryCloneUrl.owner}:${compareWithBaseRef}`,
head: `${head.repositoryCloneUrl.owner}:${head.sha}`,
basehead,
});
const MAX_FILE_CHANGES_IN_COMPARE_COMMITS = 100;

Expand Down
2 changes: 1 addition & 1 deletion src/github/pullRequestModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1793,7 +1793,7 @@ export class PullRequestModel extends IssueModel<PullRequest> 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) {
Expand Down