Skip to content

Commit 65fa899

Browse files
author
Pascal Fong Kye
committed
refactor: stage all but merge
1 parent d2b5d32 commit 65fa899

1 file changed

Lines changed: 6 additions & 29 deletions

File tree

extensions/git/src/commands.ts

Lines changed: 6 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,37 +1000,14 @@ export class CommandCenter {
10001000

10011001
@command('git.stageAll', { repository: true })
10021002
async stageAll(repository: Repository): Promise<void> {
1003-
const resources = repository.mergeGroup.resourceStates.filter(s => s instanceof Resource) as Resource[];
1004-
const { merge, unresolved, deletionConflicts } = await categorizeResourceByResolution(resources);
1005-
1006-
try {
1007-
for (const deletionConflict of deletionConflicts) {
1008-
await this._stageDeletionConflict(repository, deletionConflict.resourceUri);
1009-
}
1010-
} catch (err) {
1011-
if (/Cancelled/.test(err.message)) {
1012-
return;
1013-
}
1014-
1015-
throw err;
1016-
}
1017-
1018-
if (unresolved.length > 0) {
1019-
const message = unresolved.length > 1
1020-
? localize('confirm stage files with merge conflicts', "Are you sure you want to stage {0} files with merge conflicts?", merge.length)
1021-
: localize('confirm stage file with merge conflicts', "Are you sure you want to stage {0} with merge conflicts?", path.basename(merge[0].resourceUri.fsPath));
1022-
1023-
const yes = localize('yes', "Yes");
1024-
const pick = await window.showWarningMessage(message, { modal: true }, yes);
1003+
const resources = [...repository.workingTreeGroup.resourceStates, ...repository.untrackedGroup.resourceStates];
1004+
const uris = resources.map(r => r.resourceUri);
10251005

1026-
if (pick !== yes) {
1027-
return;
1028-
}
1006+
if (uris.length > 0) {
1007+
const config = workspace.getConfiguration('git', Uri.file(repository.root));
1008+
const untrackedChanges = config.get<'mixed' | 'separate' | 'hidden'>('untrackedChanges');
1009+
await repository.add(uris, untrackedChanges === 'mixed' ? undefined : { update: true });
10291010
}
1030-
1031-
const config = workspace.getConfiguration('git', Uri.file(repository.root));
1032-
const untrackedChanges = config.get<'mixed' | 'separate' | 'hidden'>('untrackedChanges');
1033-
await repository.add([], untrackedChanges === 'mixed' ? undefined : { update: true });
10341011
}
10351012

10361013
private async _stageDeletionConflict(repository: Repository, uri: Uri): Promise<void> {

0 commit comments

Comments
 (0)