|
|
… |
44 unchanged lines |
| 45 |
45 |
|
assert.deepEqual(bookmarks.map((b) => [b.name, b.current]), [["main", true]]); |
| 46 |
46 |
|
await assert.rejects(oxy.cat(root, "missing.txt"), /not in that state/); |
| 47 |
47 |
|
|
| 48 |
|
- |
// Write operations: hunks, commit by hunk, discard, amend, undo, op log. |
|
48 |
+ |
// Amend folds the edit into the single head. |
|
49 |
+ |
await oxy.amend(root, "first, amended"); |
|
50 |
+ |
assert.equal((await oxy.status(root)).clean, true); |
|
51 |
+ |
assert.ok((await oxy.log(root, 10)).changes.some((c) => c.message === "first, amended")); |
|
52 |
+ |
|
|
53 |
+ |
// Hunks: commit only b.txt's, leave a.txt's edit, then discard it. |
|
54 |
+ |
writeFileSync(join(root, "a.txt"), "one\ntwo\nthree\n"); |
| 49 |
55 |
|
writeFileSync(join(root, "b.txt"), "b\n"); |
| 50 |
56 |
|
const hunks = await oxy.hunks(root); |
| 51 |
57 |
|
assert.ok(hunks.length >= 2, JSON.stringify(hunks)); |
|
|
… |
1 unchanged lines |
| 53 |
59 |
|
await oxy.commitHunks(root, "b only", [bHunk.index]); |
| 54 |
60 |
|
status = await oxy.status(root); |
| 55 |
61 |
|
assert.deepEqual(status.paths.map((p) => p.path), ["a.txt"], "a.txt stays uncommitted"); |
|
62 |
+ |
assert.equal((await oxy.cat(root, "b.txt")).toString(), "b\n", "committed with its content"); |
| 56 |
63 |
|
await oxy.discard(root, ["a.txt"]); |
| 57 |
64 |
|
assert.equal((await oxy.status(root)).clean, true); |
| 58 |
|
- |
writeFileSync(join(root, "b.txt"), "b\nmore\n"); |
| 59 |
|
- |
await oxy.amend(root, "b, amended"); |
| 60 |
|
- |
assert.equal((await oxy.status(root)).clean, true); |
| 61 |
|
- |
const log2 = await oxy.log(root, 10); |
| 62 |
|
- |
assert.ok(log2.changes.some((c) => c.message === "b, amended")); |
|
65 |
+ |
|
|
66 |
+ |
// The operation log, and undo of the last operation (the commit). |
| 63 |
67 |
|
const ops = await oxy.opLog(root); |
| 64 |
68 |
|
assert.ok(ops[0].current && ops.length > 3); |
| 65 |
69 |
|
assert.match(await oxy.undo(root), /Undone/); |
| 66 |
|
- |
assert.equal((await oxy.status(root)).clean, false, "the amend is undone; its edit is back on disk as uncommitted work"); |
|
70 |
+ |
status = await oxy.status(root); |
|
71 |
+ |
assert.ok(status.paths.some((p) => p.path === "b.txt"), "the commit is undone; b.txt is uncommitted work again"); |
| 67 |
72 |
|
}); |