Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maintenance nov 2024 #190

Merged
merged 5 commits into from
Nov 4, 2024
Merged
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
2 changes: 1 addition & 1 deletion src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1089,7 +1089,7 @@ export class CommandCenter {
const items = await repository.stashList();
const stashId = await interaction.pickStashItem(items, operation);
if (stashId) {
repository.stashApplyOrDrop(operation, stashId);
return repository.stashApplyOrDrop(operation, stashId);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/openedRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ export class OpenedRepository {
* paths[] will cause damage
*/
async cleanAll(): Promise<void> {
this.exec(['clean']);
await this.exec(['clean']);
}

async ignore(paths: RelativePath[]): Promise<void> {
Expand Down
16 changes: 10 additions & 6 deletions src/repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -693,12 +693,13 @@ export class Repository implements IDisposable, InteractionAPI {
return this.stagingGroup.resourceStates.map(r =>
this.mapResourceToRepoRelativePath(r)
);
} else if (scope === CommitScope.WORKING_GROUP) {
}
if (scope === CommitScope.WORKING_GROUP) {
return this.workingGroup.resourceStates.map(r =>
this.mapResourceToRepoRelativePath(r)
);
}
return [];
return []; // scope === CommitScope.ALL
}

@throttle
Expand Down Expand Up @@ -897,10 +898,13 @@ export class Repository implements IDisposable, InteractionAPI {
scope: Exclude<CommitScope, CommitScope.UNKNOWN>,
operation: 'save' | 'snapshot'
): Promise<void> {
return this.runWithProgress(Operation.Commit, async () => {
const fileList = this.scopeToFileList(scope);
this.repository.stash(message, operation, fileList);
});
return this.runWithProgress(Operation.Commit, async () =>
this.repository.stash(
message,
operation,
this.scopeToFileList(scope)
)
);
}

async stashList(): Promise<StashItem[]> {
Expand Down
2 changes: 1 addition & 1 deletion src/test/suite/Infrastructure.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ suite('Infrastructure', () => {
});
sinon.assert.calledOnceWithExactly(
showErrorMessage,
'Fossil: fossil: unknown command: fizzbuzz',
`Fossil: ${fossilPath}: unknown command: fizzbuzz`,
'Open Fossil Log'
);
});
Expand Down
107 changes: 68 additions & 39 deletions src/test/suite/commandSuites.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
import * as assert from 'assert/strict';
import * as fs from 'fs/promises';
import { OpenedRepository, ResourceStatus } from '../../openedRepository';
import { Suite, Func, Test } from 'mocha';
import { Suite, before, Func, Test } from 'mocha';
import { toFossilUri } from '../../uri';

declare module 'mocha' {
Expand Down Expand Up @@ -46,11 +46,9 @@ export function StatusSuite(this: Suite): void {
await fs.unlink(path.fsPath);
const repository = getRepository();
await repository.updateModelState();
assertGroups(
repository,
new Map([[path.fsPath, ResourceStatus.MISSING]]),
new Map()
);
assertGroups(repository, {
working: [[path.fsPath, ResourceStatus.MISSING]],
});
}).timeout(5000);

test('Rename is visible in Source Control panel', async () => {
Expand All @@ -60,19 +58,17 @@ export function StatusSuite(this: Suite): void {
const newFilename = 'sriciscp-renamed.txt';
const oldUri = await add(oldFilename, 'test\n', `add ${oldFilename}`);
await repository.updateModelState();
assertGroups(repository, new Map(), new Map());
assertGroups(repository, {});

const openedRepository: OpenedRepository = (repository as any)
.repository;

await openedRepository.exec(['mv', oldFilename, newFilename, '--hard']);
await repository.updateModelState();
const barPath = Uri.joinPath(oldUri, '..', newFilename).fsPath;
assertGroups(
repository,
new Map([[barPath, ResourceStatus.RENAMED]]),
new Map()
);
assertGroups(repository, {
working: [[barPath, ResourceStatus.RENAMED]],
});
}).timeout(15000);

test('Merge is visible in Source Control panel', async () => {
Expand Down Expand Up @@ -100,14 +96,12 @@ export function StatusSuite(this: Suite): void {
await openedRepository.exec(['update', 'trunk']);
await openedRepository.exec(['merge', 'test_brunch']);
await repository.updateModelState();
assertGroups(
repository,
new Map([
assertGroups(repository, {
working: [
[barPath, ResourceStatus.ADDED],
[fooPath, ResourceStatus.MODIFIED],
]),
new Map()
);
],
});
}).timeout(10000);

test.if(process.platform != 'win32', 'Meta', async () => {
Expand Down Expand Up @@ -186,51 +180,69 @@ export function StatusSuite(this: Suite): void {
await fs.mkdir(not_file_path);

await repository.updateModelState();
assertGroups(
repository,
new Map([
assertGroups(repository, {
working: [
[executable_path, ResourceStatus.MODIFIED],
[unexec_path, ResourceStatus.MODIFIED],
[symlink_path, ResourceStatus.MODIFIED],
[unlink_path, ResourceStatus.MODIFIED],
[not_file_path, ResourceStatus.MISSING],
]),
new Map()
);
],
});
new Map();
await fs.rmdir(not_file_path);
}).timeout(20000);

const testRename = async (
status: string,
before: string,
after: string
status: `${'RENAMED' | 'EDITED'} ${'a' | 'a.txt -> b'}.txt`,
before: 'a.txt',
after: 'a.txt' | 'b.txt',
resourceStatus: ResourceStatus
) => {
const repository = getRepository();
const execStub = getExecStub(this.ctx.sandbox);
await fakeFossilStatus(execStub, status);
await repository.updateModelState();
const folder = vscode.workspace.workspaceFolders![0].uri;
const uriBefore = Uri.joinPath(folder, before).toString();
const uriAfter = Uri.joinPath(folder, after).toString();
assert.equal(repository.workingGroup.resourceStates.length, 1);
const root = vscode.workspace.workspaceFolders![0].uri;
const uriBefore = Uri.joinPath(root, before);
const uriAfter = Uri.joinPath(root, after);
assertGroups(repository, {
working: [[uriAfter.fsPath, resourceStatus]],
});
const resource = repository.workingGroup.resourceStates[0];
assert.equal(resource.resourceUri.toString(), uriAfter);
assert.equal(resource.original.toString(), uriBefore);
assert.equal(resource.original.toString(), uriBefore.toString());
assert.ok(resource.renameResourceUri);
assert.equal(resource.renameResourceUri.toString(), uriAfter);
assert.equal(
resource.renameResourceUri.toString(),
uriAfter.toString()
);
};

test('Renamed (pre 2.19)', async () => {
await testRename('RENAMED a.txt', 'a.txt', 'a.txt');
await testRename(
'RENAMED a.txt',
'a.txt',
'a.txt',
ResourceStatus.RENAMED
);
});

test('Renamed (since 2.19)', async () => {
await testRename('RENAMED a.txt -> b.txt', 'a.txt', 'b.txt');
await testRename(
'RENAMED a.txt -> b.txt',
'a.txt',
'b.txt',
ResourceStatus.RENAMED
);
});

test('Renamed (since 2.23)', async () => {
await testRename('EDITED a.txt -> b.txt', 'a.txt', 'b.txt');
await testRename(
'EDITED a.txt -> b.txt',
'a.txt',
'b.txt',
ResourceStatus.MODIFIED
);
});
}

Expand Down Expand Up @@ -279,6 +291,12 @@ export function TagSuite(this: Suite): void {
}

export function CleanSuite(this: Suite): void {
let rootUri: Uri;

before(() => {
rootUri = workspace.workspaceFolders![0].uri;
});

test('Clean', async () => {
const swm: sinon.SinonStub = this.ctx.sandbox.stub(
window,
Expand Down Expand Up @@ -306,7 +324,12 @@ export function CleanSuite(this: Suite): void {
.resolves();
await fakeFossilStatus(execStub, 'EXTRA a.txt\nEXTRA b.txt');
await repository.updateModelState();
assert.equal(repository.untrackedGroup.resourceStates.length, 2);
assertGroups(repository, {
untracked: [
[Uri.joinPath(rootUri, 'a.txt').fsPath, ResourceStatus.EXTRA],
[Uri.joinPath(rootUri, 'b.txt').fsPath, ResourceStatus.EXTRA],
],
});
const swm: sinon.SinonStub = this.ctx.sandbox.stub(
window,
'showWarningMessage'
Expand Down Expand Up @@ -342,7 +365,13 @@ export function CleanSuite(this: Suite): void {
'EXTRA a.txt\nEXTRA b.txt\nEXTRA c.txt'
);
await repository.updateModelState();
assert.equal(repository.untrackedGroup.resourceStates.length, 3);
assertGroups(repository, {
untracked: [
[Uri.joinPath(rootUri, 'a.txt').fsPath, ResourceStatus.EXTRA],
[Uri.joinPath(rootUri, 'b.txt').fsPath, ResourceStatus.EXTRA],
[Uri.joinPath(rootUri, 'c.txt').fsPath, ResourceStatus.EXTRA],
],
});
const showWarningMessage: sinon.SinonStub = this.ctx.sandbox.stub(
window,
'showWarningMessage'
Expand Down
Loading