fix: commit changes in empty git repo before Continue Working On (#246637)

This commit is contained in:
Joyce Er
2025-04-15 08:49:08 -07:00
committed by GitHub
parent bea03b50a6
commit 516f9c731a
@@ -82,9 +82,23 @@ export class GitEditSessionIdentityProvider implements vscode.EditSessionIdentit
await repository.status();
// If this branch hasn't been published to the remote yet,
// ensure that it is published before Continue On is invoked
if (!repository.HEAD?.upstream && repository.HEAD?.type === RefType.Head) {
if (!repository.HEAD?.commit) {
// Handle publishing empty repository with no commits
const yes = vscode.l10n.t('Yes');
const selection = await vscode.window.showInformationMessage(
vscode.l10n.t('Would you like to publish this repository to continue working on it elsewhere?'),
{ modal: true },
yes
);
if (selection !== yes) {
throw new vscode.CancellationError();
}
await repository.commit('Initial commit', { all: true });
await vscode.commands.executeCommand('git.publish');
} else if (!repository.HEAD?.upstream && repository.HEAD?.type === RefType.Head) {
// If this branch hasn't been published to the remote yet,
// ensure that it is published before Continue On is invoked
const publishBranch = vscode.l10n.t('Publish Branch');
const selection = await vscode.window.showInformationMessage(