Skip to content
Draft
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
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
33 changes: 24 additions & 9 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,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) {
Expand All @@ -191,5 +206,5 @@ export async function compareCommits(remote: GitHubRemote, octokit: LoggingOctok
throw e;
}
}
return { mergeBaseSha, files };
return { mergeBaseSha: mergeBaseSha!, files: files! };
}
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