@kaynooo/cli-git 0.15.2 → 0.15.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/gb.js +7 -3
- package/dist/gu.js +7 -1
- package/package.json +2 -2
package/dist/gb.js
CHANGED
|
@@ -1515,7 +1515,8 @@ var KEYS = {
|
|
|
1515
1515
|
"\x03": "cancel",
|
|
1516
1516
|
"\x1B": "cancel",
|
|
1517
1517
|
"\x7F": "erase",
|
|
1518
|
-
"\b": "
|
|
1518
|
+
"\b": "word",
|
|
1519
|
+
"\x1B\x7F": "word",
|
|
1519
1520
|
"\x15": "clear",
|
|
1520
1521
|
"\x17": "word",
|
|
1521
1522
|
"\t": "tab",
|
|
@@ -1523,6 +1524,9 @@ var KEYS = {
|
|
|
1523
1524
|
"\x1BOP": "help",
|
|
1524
1525
|
"\x1B[11~": "help"
|
|
1525
1526
|
};
|
|
1527
|
+
function eraseWord(text) {
|
|
1528
|
+
return text.replace(LAST_WORD, "");
|
|
1529
|
+
}
|
|
1526
1530
|
var CTRL_KEY = /^ctrl-[abd-gkln-z]$/;
|
|
1527
1531
|
function repeat(value, count) {
|
|
1528
1532
|
return Array.from({ length: count }).fill(value);
|
|
@@ -1645,7 +1649,7 @@ function press(state, key) {
|
|
|
1645
1649
|
case "clear":
|
|
1646
1650
|
return withQuery(state, "");
|
|
1647
1651
|
case "word":
|
|
1648
|
-
return withQuery(state, state.query
|
|
1652
|
+
return withQuery(state, eraseWord(state.query));
|
|
1649
1653
|
case "enter":
|
|
1650
1654
|
return state.matches.length === 0 && state.marked.size === 0 ? state : { ...state, done: "accept" };
|
|
1651
1655
|
case "tab": {
|
|
@@ -1675,7 +1679,7 @@ import tty from "tty";
|
|
|
1675
1679
|
var SYNC_START = "\x1B[?2026h";
|
|
1676
1680
|
var SYNC_END = "\x1B[?2026l";
|
|
1677
1681
|
function overwrite(lines, columns) {
|
|
1678
|
-
return lines.map((line) => textWidth(line)
|
|
1682
|
+
return lines.map((line) => textWidth(line) % columns === 0 ? `\x1B[2K${line}` : `${line}\x1B[K`).join(`
|
|
1679
1683
|
`);
|
|
1680
1684
|
}
|
|
1681
1685
|
|
package/dist/gu.js
CHANGED
|
@@ -1416,6 +1416,7 @@ var OPTIONS = {
|
|
|
1416
1416
|
json: jsonOption("{action, paths?, saved?, commit?} of what was undone, saved being the patch of a discard")
|
|
1417
1417
|
};
|
|
1418
1418
|
var LITERAL = { ...process18.env, GIT_LITERAL_PATHSPECS: "1" };
|
|
1419
|
+
var PLAIN_PATCH = ["--binary", "--no-ext-diff", "--no-textconv", "--no-color", "--no-relative", "--submodule=short", "--src-prefix=a/", "--dst-prefix=b/"];
|
|
1419
1420
|
var NOT_A_REPOSITORY = /not a git repository/i;
|
|
1420
1421
|
async function checked(args) {
|
|
1421
1422
|
const { code, stdout, stderr } = await git2(args, LITERAL);
|
|
@@ -1469,11 +1470,16 @@ async function main(argv) {
|
|
|
1469
1470
|
console.log(`unstaged ${paths.join(", ")}`);
|
|
1470
1471
|
return 0;
|
|
1471
1472
|
}
|
|
1472
|
-
const patch = await checked(["diff",
|
|
1473
|
+
const patch = await checked(["diff", ...PLAIN_PATCH, "--", ...positionals]);
|
|
1473
1474
|
const folder = join7(resolve5((await checked(["rev-parse", "--git-dir"])).trim()), "gu");
|
|
1474
1475
|
const saved = join7(folder, `${new Date().toISOString().replaceAll(":", "-")}.patch`);
|
|
1476
|
+
const top = (await checked(["rev-parse", "--show-toplevel"])).trim();
|
|
1475
1477
|
mkdirSync2(folder, { recursive: true });
|
|
1476
1478
|
writeFileSync(saved, patch);
|
|
1479
|
+
const reverts = await git2(["-C", top, "apply", "--check", "--reverse", "--whitespace=nowarn", saved]);
|
|
1480
|
+
if (reverts.code !== 0)
|
|
1481
|
+
fail(`the patch saved to ${saved} would not put the change back, nothing discarded:
|
|
1482
|
+
${reverts.stderr.trim()}`, 1);
|
|
1477
1483
|
await checked(["restore", "--", ...positionals]);
|
|
1478
1484
|
if (values.json === true)
|
|
1479
1485
|
printJson({ action: "discard", paths, saved });
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kaynooo/cli-git",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.15.
|
|
4
|
+
"version": "0.15.3",
|
|
5
5
|
"description": "gst, gc, gb, gp, gf, gcl, gd and gu: a repository's state in one call, a commit of exactly the paths given, its message checked before anything is staged, a branch picked, nested repositories pushed or fetched, a clone into the workspace, the changes per file and an undo that keeps what it takes away.",
|
|
6
6
|
"author": "Kaynooo <contact@kaynooo.fr>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -54,6 +54,6 @@
|
|
|
54
54
|
"gu": "$npm_execpath src/gu.ts"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@kaynooo/cli-kit": "0.38.
|
|
57
|
+
"@kaynooo/cli-kit": "0.38.6"
|
|
58
58
|
}
|
|
59
59
|
}
|