directly call simplified merge editor for worktree merges (#265024)

directly call own simplified merge editor for worktree merges
This commit is contained in:
Christy 😺
2025-09-03 14:45:41 -07:00
committed by GitHub
parent a5afc1f17f
commit 901aa3b820
2 changed files with 29 additions and 1 deletions

View File

@@ -3536,6 +3536,8 @@ export class CommandCenter {
await worktreeRepository.popStash();
throw err;
}
repository.isWorktreeMigrating = true;
const message = l10n.t('There are merge conflicts from migrating changes. Please resolve them before committing.');
const show = l10n.t('Show Changes');
const choice = await window.showWarningMessage(message, show);
@@ -3546,6 +3548,22 @@ export class CommandCenter {
}
}
@command('git.openWorktreeMergeEditor')
async openWorktreeMergeEditor(uri: Uri): Promise<void> {
type InputData = { uri: Uri; title: string };
const mergeUris = toMergeUris(uri);
const current: InputData = { uri: mergeUris.ours, title: l10n.t('Workspace') };
const incoming: InputData = { uri: mergeUris.theirs, title: l10n.t('Worktree') };
await commands.executeCommand('_open.mergeEditor', {
base: mergeUris.base,
input1: current,
input2: incoming,
output: uri
});
}
@command('git.createWorktree')
async createWorktree(repository: any): Promise<void> {
repository = this.model.getRepository(repository);

View File

@@ -514,8 +514,9 @@ class ResourceCommandResolver {
if (!resource.leftUri) {
const bothModified = resource.type === Status.BOTH_MODIFIED;
if (resource.rightUri && workspace.getConfiguration('git').get<boolean>('mergeEditor', false) && (bothModified || resource.type === Status.BOTH_ADDED)) {
const command = this.repository.isWorktreeMigrating ? 'git.openWorktreeMergeEditor' : 'git.openMergeEditor';
return {
command: 'git.openMergeEditor',
command,
title: l10n.t('Open Merge'),
arguments: [resource.rightUri]
};
@@ -809,6 +810,10 @@ export class Repository implements Disposable {
return this._cherryPickInProgress;
}
private _isWorktreeMigrating: boolean = false;
get isWorktreeMigrating(): boolean { return this._isWorktreeMigrating; }
set isWorktreeMigrating(value: boolean) { this._isWorktreeMigrating = value; }
private readonly _operations: OperationManager;
get operations(): OperationManager { return this._operations; }
@@ -2406,6 +2411,11 @@ export class Repository implements Disposable {
if (resourcesGroups.untrackedGroup) { this.untrackedGroup.resourceStates = resourcesGroups.untrackedGroup; }
if (resourcesGroups.workingTreeGroup) { this.workingTreeGroup.resourceStates = resourcesGroups.workingTreeGroup; }
// clear worktree migrating flag once all conflicts are resolved
if (this._isWorktreeMigrating && resourcesGroups.mergeGroup && resourcesGroups.mergeGroup.length === 0) {
this._isWorktreeMigrating = false;
}
// set count badge
this.setCountBadge();
}