@kaynooo/cli-git 0.15.1 → 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 +16 -5
- 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": {
|
|
@@ -1671,6 +1675,14 @@ import { openSync } from "fs";
|
|
|
1671
1675
|
import process19 from "process";
|
|
1672
1676
|
import tty from "tty";
|
|
1673
1677
|
|
|
1678
|
+
// ../kit/src/redraw.ts
|
|
1679
|
+
var SYNC_START = "\x1B[?2026h";
|
|
1680
|
+
var SYNC_END = "\x1B[?2026l";
|
|
1681
|
+
function overwrite(lines, columns) {
|
|
1682
|
+
return lines.map((line) => textWidth(line) % columns === 0 ? `\x1B[2K${line}` : `${line}\x1B[K`).join(`
|
|
1683
|
+
`);
|
|
1684
|
+
}
|
|
1685
|
+
|
|
1674
1686
|
// ../kit/src/picker/preview.ts
|
|
1675
1687
|
import process18 from "process";
|
|
1676
1688
|
|
|
@@ -1942,14 +1954,13 @@ async function select(rows, settings, terminal = openTerminal()) {
|
|
|
1942
1954
|
if (restored)
|
|
1943
1955
|
return;
|
|
1944
1956
|
const layout = layoutFor({ columns: terminal.columns, rows: terminal.rows }, settings.height, settings.preview !== undefined, settings.previewPosition);
|
|
1945
|
-
let frame = HIDE_CURSOR;
|
|
1957
|
+
let frame = SYNC_START + HIDE_CURSOR;
|
|
1946
1958
|
if (reserved !== layout.height || clear) {
|
|
1947
1959
|
frame += CLEAR_BELOW2 + `
|
|
1948
1960
|
`.repeat(layout.height - 1) + up(layout.height - 1);
|
|
1949
1961
|
reserved = layout.height;
|
|
1950
1962
|
}
|
|
1951
|
-
frame += `\r${render(state, layout, theme, preview).
|
|
1952
|
-
`)}${up(layout.height - 1)}\r\x1B[${caretColumn(state, layout)}G${CARET}\r`;
|
|
1963
|
+
frame += `\r${overwrite(render(state, layout, theme, preview), terminal.columns)}${up(layout.height - 1)}\r\x1B[${caretColumn(state, layout)}G${CARET}\r${SYNC_END}`;
|
|
1953
1964
|
terminal.write(frame);
|
|
1954
1965
|
}
|
|
1955
1966
|
function pageSize() {
|
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
|
}
|