Update to 0.4.5
This commit is contained in:
@@ -87,6 +87,40 @@ test('stages and pushes deleted and renamed files selected from the working tree
|
||||
assert.deepEqual(names, ['new-name.txt']);
|
||||
});
|
||||
|
||||
|
||||
test('commits a deletion that was already staged manually without restaging its missing path', async (t) => {
|
||||
const root = await fs.mkdtemp(path.join(os.tmpdir(), 'forgeflow-git-staged-delete-'));
|
||||
t.after(() => fs.rm(root, { recursive: true, force: true }));
|
||||
|
||||
const remote = path.join(root, 'remote.git');
|
||||
const working = path.join(root, 'working');
|
||||
await git(['init', '--bare', remote], root);
|
||||
await git(['clone', remote, working], root);
|
||||
await git(['config', 'user.name', 'ForgeFlow Test'], working);
|
||||
await git(['config', 'user.email', 'forgeflow@example.invalid'], working);
|
||||
await fs.writeFile(path.join(working, 'silent-zebra-glow.zip'), 'obsolete archive\n');
|
||||
await git(['add', '.'], working);
|
||||
await git(['commit', '-m', 'Initial archive'], working);
|
||||
await git(['branch', '-M', 'main'], working);
|
||||
await git(['push', '-u', 'origin', 'main'], working);
|
||||
|
||||
await fs.rm(path.join(working, 'silent-zebra-glow.zip'));
|
||||
const service = new GitService();
|
||||
const staged = await service.stage(working, ['silent-zebra-glow.zip']);
|
||||
assert.equal(staged.files[0].path, 'silent-zebra-glow.zip');
|
||||
assert.equal(staged.files[0].staged, true);
|
||||
assert.equal(staged.files[0].unstaged, false);
|
||||
|
||||
// This used to call git add -A for the same already-staged deletion again,
|
||||
// which fails with a pathspec error because the file no longer exists.
|
||||
const result = await service.commitAndPush(working, 'Remove obsolete archive', ['silent-zebra-glow.zip']);
|
||||
assert.equal(result.status.clean, true);
|
||||
assert.equal(result.status.branch.ahead, 0);
|
||||
|
||||
const tree = await git(['--git-dir', remote, 'ls-tree', '-r', '--name-only', 'refs/heads/main'], root);
|
||||
assert.equal(tree.stdout.trim(), '');
|
||||
});
|
||||
|
||||
test('keeps a successful local commit visible as ahead when the following push fails', async (t) => {
|
||||
const root = await fs.mkdtemp(path.join(os.tmpdir(), 'forgeflow-git-push-failure-'));
|
||||
t.after(() => fs.rm(root, { recursive: true, force: true }));
|
||||
|
||||
Reference in New Issue
Block a user