@kaynooo/cli-git 0.18.1 → 0.19.0
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/README.md +1 -1
- package/dist/gb.js +17 -30
- package/dist/gc.js +12 -25
- package/dist/gcl.js +87 -54
- package/dist/gd.js +20 -33
- package/dist/gf.js +19 -32
- package/dist/gm.js +28 -41
- package/dist/gp.js +19 -32
- package/dist/gst.js +26 -39
- package/dist/gu.js +12 -25
- package/package.json +3 -3
package/dist/gf.js
CHANGED
|
@@ -1552,7 +1552,7 @@ var init_prompt = __esm(() => {
|
|
|
1552
1552
|
});
|
|
1553
1553
|
|
|
1554
1554
|
// src/gf.ts
|
|
1555
|
-
import
|
|
1555
|
+
import process23 from "process";
|
|
1556
1556
|
|
|
1557
1557
|
// ../kit/src/index.ts
|
|
1558
1558
|
init_args();
|
|
@@ -1982,12 +1982,15 @@ import { join as join6 } from "path";
|
|
|
1982
1982
|
import process16 from "process";
|
|
1983
1983
|
var SOCKET_VARIABLE = "KAYNOOO_ASKPASS_SOCKET";
|
|
1984
1984
|
var ECHOED = /username|yes\/no/i;
|
|
1985
|
+
var NO_PROMPTS = { GIT_TERMINAL_PROMPT: "0", GIT_ASKPASS: "", SSH_ASKPASS: "", SSH_ASKPASS_REQUIRE: "never" };
|
|
1985
1986
|
var quoted = (text) => `'${text.replaceAll("'", `'\\''`)}'`;
|
|
1986
1987
|
function askpass(pause = () => () => {
|
|
1987
1988
|
return;
|
|
1988
1989
|
}) {
|
|
1989
1990
|
if (process16.stdin.isTTY !== true || process16.stderr.isTTY !== true || process16.argv[1] === undefined)
|
|
1990
|
-
return
|
|
1991
|
+
return { env: { ...NO_PROMPTS }, close: () => {
|
|
1992
|
+
return;
|
|
1993
|
+
} };
|
|
1991
1994
|
const dir = mkdtempSync(join6(tmpdir(), "kaynooo-askpass-"));
|
|
1992
1995
|
const socketPath = join6(dir, "socket");
|
|
1993
1996
|
const script = join6(dir, "askpass");
|
|
@@ -2042,7 +2045,7 @@ ${SOCKET_VARIABLE}=${quoted(socketPath)} exec ${quoted(process16.execPath)} --no
|
|
|
2042
2045
|
`);
|
|
2043
2046
|
chmodSync(script, 448);
|
|
2044
2047
|
return {
|
|
2045
|
-
env: { GIT_ASKPASS: script, SSH_ASKPASS: script, SSH_ASKPASS_REQUIRE: "force" },
|
|
2048
|
+
env: { GIT_ASKPASS: script, GIT_TERMINAL_PROMPT: "0", SSH_ASKPASS: script, SSH_ASKPASS_REQUIRE: "force" },
|
|
2046
2049
|
close: () => {
|
|
2047
2050
|
server.stop(true);
|
|
2048
2051
|
rmSync(dir, { recursive: true, force: true });
|
|
@@ -2465,26 +2468,10 @@ async function watching(value, step, stream = process20.stdout, sleep = Bun.slee
|
|
|
2465
2468
|
}
|
|
2466
2469
|
// ../kit/src/workspace-root.ts
|
|
2467
2470
|
init_user_config();
|
|
2468
|
-
import { homedir as homedir5 } from "os";
|
|
2469
|
-
import { dirname as dirname5, join as join9, resolve as resolve4 } from "path";
|
|
2470
|
-
import process21 from "process";
|
|
2471
|
-
function expandHome(path, home) {
|
|
2472
|
-
if (path === "~")
|
|
2473
|
-
return home;
|
|
2474
|
-
return path.startsWith("~/") ? join9(home, path.slice(2)) : path;
|
|
2475
|
-
}
|
|
2476
|
-
function configured(env, home) {
|
|
2477
|
-
const folder = readUserConfig("config", { home, xdg: env.XDG_CONFIG_HOME }).workspace;
|
|
2478
|
-
return typeof folder === "string" && folder !== "" ? folder : undefined;
|
|
2479
|
-
}
|
|
2480
|
-
function workspaceRoot({ given, env = process21.env, home = homedir5() } = {}) {
|
|
2481
|
-
const fromEnv = env.KAYNOOO_WORKSPACE === "" ? undefined : env.KAYNOOO_WORKSPACE;
|
|
2482
|
-
return resolve4(expandHome(given ?? fromEnv ?? configured(env, home) ?? join9(home, "Workspace"), home));
|
|
2483
|
-
}
|
|
2484
2471
|
// src/repos.ts
|
|
2485
2472
|
import { readdir } from "fs/promises";
|
|
2486
|
-
import { join as
|
|
2487
|
-
import
|
|
2473
|
+
import { join as join9, relative, resolve as resolve4 } from "path";
|
|
2474
|
+
import process22 from "process";
|
|
2488
2475
|
|
|
2489
2476
|
// src/git.ts
|
|
2490
2477
|
async function git2(args, env) {
|
|
@@ -2587,9 +2574,9 @@ async function reposUnder(root, depth = DEPTH) {
|
|
|
2587
2574
|
found.push(dir);
|
|
2588
2575
|
if (left === 0)
|
|
2589
2576
|
return;
|
|
2590
|
-
await Promise.all(entries.filter((entry) => entry.isDirectory() && !entry.name.startsWith(".") && !SKIPPED.has(entry.name)).map(async (entry) => walk(
|
|
2577
|
+
await Promise.all(entries.filter((entry) => entry.isDirectory() && !entry.name.startsWith(".") && !SKIPPED.has(entry.name)).map(async (entry) => walk(join9(dir, entry.name), left - 1)));
|
|
2591
2578
|
}
|
|
2592
|
-
await walk(
|
|
2579
|
+
await walk(resolve4(root), depth);
|
|
2593
2580
|
return found.sort();
|
|
2594
2581
|
}
|
|
2595
2582
|
async function toplevelOf(dir) {
|
|
@@ -2597,14 +2584,14 @@ async function toplevelOf(dir) {
|
|
|
2597
2584
|
return read.code === 0 ? read.stdout.trim() : undefined;
|
|
2598
2585
|
}
|
|
2599
2586
|
async function reposOf(roots) {
|
|
2600
|
-
const starts = roots.length > 0 ? roots : [await toplevelOf(".") ??
|
|
2587
|
+
const starts = roots.length > 0 ? roots : [await toplevelOf(".") ?? process22.cwd()];
|
|
2601
2588
|
const found = await Promise.all(starts.map(async (root) => reposUnder(root)));
|
|
2602
2589
|
return [...new Set(found.flat())].sort();
|
|
2603
2590
|
}
|
|
2604
2591
|
async function repoState(dir) {
|
|
2605
2592
|
const [read, log] = await Promise.all([git2(["-C", dir, "status", "--porcelain=v2", "--branch"]), git2(["-C", dir, "log", "-1", "--format=%h%x00%s"])]);
|
|
2606
2593
|
const [sha, title = ""] = log.code === 0 && log.stdout.trim() !== "" ? log.stdout.trim().split("\x00") : [];
|
|
2607
|
-
return { path: relative(
|
|
2594
|
+
return { path: relative(process22.cwd(), dir) || ".", dir, status: read.code === 0 ? parseStatus(read.stdout) : null, head: sha === undefined ? null : { sha, title } };
|
|
2608
2595
|
}
|
|
2609
2596
|
function trackingOf(status) {
|
|
2610
2597
|
if (status.upstream === null)
|
|
@@ -2706,16 +2693,16 @@ var OPTIONS = {
|
|
|
2706
2693
|
json: jsonOption("one {path, branch, upstream, commits, outcome, reason?} per repository, outcome being updated, current, fetched, skipped or refused")
|
|
2707
2694
|
};
|
|
2708
2695
|
function line(result) {
|
|
2709
|
-
const { dim } = paint(
|
|
2696
|
+
const { dim } = paint(process23.stdout);
|
|
2710
2697
|
const count = `${result.commits} ${result.commits === 1 ? "commit" : "commits"}`;
|
|
2711
2698
|
const said = {
|
|
2712
|
-
updated: () => marked("ok", `${result.branch} <- ${result.upstream}, ${count}`,
|
|
2699
|
+
updated: () => marked("ok", `${result.branch} <- ${result.upstream}, ${count}`, process23.stdout),
|
|
2713
2700
|
current: () => dim(`${result.branch} up to date`),
|
|
2714
2701
|
fetched: () => `${result.branch} is ${result.commits} behind ${result.upstream}`,
|
|
2715
2702
|
skipped: () => dim(`${result.branch ?? ""} ${result.reason ?? "skipped"}`.trim()),
|
|
2716
|
-
refused: () => marked("problem", `${result.branch === null ? "" : `${result.branch}: `}${result.reason ?? "refused"}`,
|
|
2703
|
+
refused: () => marked("problem", `${result.branch === null ? "" : `${result.branch}: `}${result.reason ?? "refused"}`, process23.stdout)
|
|
2717
2704
|
}[result.outcome];
|
|
2718
|
-
return [role("path",
|
|
2705
|
+
return [role("path", process23.stdout)(result.path), said()];
|
|
2719
2706
|
}
|
|
2720
2707
|
async function main(argv) {
|
|
2721
2708
|
const { values, positionals } = parse(argv, USAGE, OPTIONS, { positionals: ["[dir]..."], exits: EXITS, replaces: "git fetch --prune, git pull --ff-only and a git -C <repo> pull per nested repository", examples: ["gf", ["gf --repos", "every repository nested in this one"], ["gf --no-pull", "fetch and say how far behind the branch is"]] });
|
|
@@ -2723,14 +2710,14 @@ async function main(argv) {
|
|
|
2723
2710
|
const results = [];
|
|
2724
2711
|
const progress = progressLine();
|
|
2725
2712
|
const prompts = askpass(progress.pause);
|
|
2726
|
-
const env =
|
|
2713
|
+
const env = { ...process23.env, ...prompts.env };
|
|
2727
2714
|
try {
|
|
2728
2715
|
for (const [at, repo] of repos.entries()) {
|
|
2729
2716
|
progress.update(repos.length > 1 ? { step: `fetching ${repo.path}`, done: at, total: repos.length, unit: "repositories" } : { step: `fetching ${repo.path}` });
|
|
2730
2717
|
results.push(await sync(repo, { pull: values["no-pull"] !== true, env }));
|
|
2731
2718
|
}
|
|
2732
2719
|
} finally {
|
|
2733
|
-
prompts
|
|
2720
|
+
prompts.close();
|
|
2734
2721
|
progress.stop();
|
|
2735
2722
|
}
|
|
2736
2723
|
if (values.json === true)
|
|
@@ -2739,4 +2726,4 @@ async function main(argv) {
|
|
|
2739
2726
|
console.log(table(results.map(line)));
|
|
2740
2727
|
return results.some((result) => result.outcome === "refused") ? 1 : 0;
|
|
2741
2728
|
}
|
|
2742
|
-
|
|
2729
|
+
process23.exitCode = await runMain({ name: "gf", run: main });
|
package/dist/gm.js
CHANGED
|
@@ -1553,8 +1553,8 @@ var init_prompt = __esm(() => {
|
|
|
1553
1553
|
|
|
1554
1554
|
// src/gm.ts
|
|
1555
1555
|
import { readFileSync as readFileSync7 } from "fs";
|
|
1556
|
-
import { join as
|
|
1557
|
-
import
|
|
1556
|
+
import { join as join9, relative } from "path";
|
|
1557
|
+
import process25 from "process";
|
|
1558
1558
|
|
|
1559
1559
|
// ../kit/src/index.ts
|
|
1560
1560
|
init_args();
|
|
@@ -1984,12 +1984,15 @@ import { join as join6 } from "path";
|
|
|
1984
1984
|
import process16 from "process";
|
|
1985
1985
|
var SOCKET_VARIABLE = "KAYNOOO_ASKPASS_SOCKET";
|
|
1986
1986
|
var ECHOED = /username|yes\/no/i;
|
|
1987
|
+
var NO_PROMPTS = { GIT_TERMINAL_PROMPT: "0", GIT_ASKPASS: "", SSH_ASKPASS: "", SSH_ASKPASS_REQUIRE: "never" };
|
|
1987
1988
|
var quoted = (text) => `'${text.replaceAll("'", `'\\''`)}'`;
|
|
1988
1989
|
function askpass(pause = () => () => {
|
|
1989
1990
|
return;
|
|
1990
1991
|
}) {
|
|
1991
1992
|
if (process16.stdin.isTTY !== true || process16.stderr.isTTY !== true || process16.argv[1] === undefined)
|
|
1992
|
-
return
|
|
1993
|
+
return { env: { ...NO_PROMPTS }, close: () => {
|
|
1994
|
+
return;
|
|
1995
|
+
} };
|
|
1993
1996
|
const dir = mkdtempSync(join6(tmpdir(), "kaynooo-askpass-"));
|
|
1994
1997
|
const socketPath = join6(dir, "socket");
|
|
1995
1998
|
const script = join6(dir, "askpass");
|
|
@@ -2044,7 +2047,7 @@ ${SOCKET_VARIABLE}=${quoted(socketPath)} exec ${quoted(process16.execPath)} --no
|
|
|
2044
2047
|
`);
|
|
2045
2048
|
chmodSync(script, 448);
|
|
2046
2049
|
return {
|
|
2047
|
-
env: { GIT_ASKPASS: script, SSH_ASKPASS: script, SSH_ASKPASS_REQUIRE: "force" },
|
|
2050
|
+
env: { GIT_ASKPASS: script, GIT_TERMINAL_PROMPT: "0", SSH_ASKPASS: script, SSH_ASKPASS_REQUIRE: "force" },
|
|
2048
2051
|
close: () => {
|
|
2049
2052
|
server.stop(true);
|
|
2050
2053
|
rmSync(dir, { recursive: true, force: true });
|
|
@@ -2467,22 +2470,6 @@ async function watching(value, step, stream = process20.stdout, sleep = Bun.slee
|
|
|
2467
2470
|
}
|
|
2468
2471
|
// ../kit/src/workspace-root.ts
|
|
2469
2472
|
init_user_config();
|
|
2470
|
-
import { homedir as homedir5 } from "os";
|
|
2471
|
-
import { dirname as dirname5, join as join9, resolve as resolve4 } from "path";
|
|
2472
|
-
import process21 from "process";
|
|
2473
|
-
function expandHome(path, home) {
|
|
2474
|
-
if (path === "~")
|
|
2475
|
-
return home;
|
|
2476
|
-
return path.startsWith("~/") ? join9(home, path.slice(2)) : path;
|
|
2477
|
-
}
|
|
2478
|
-
function configured(env, home) {
|
|
2479
|
-
const folder = readUserConfig("config", { home, xdg: env.XDG_CONFIG_HOME }).workspace;
|
|
2480
|
-
return typeof folder === "string" && folder !== "" ? folder : undefined;
|
|
2481
|
-
}
|
|
2482
|
-
function workspaceRoot({ given, env = process21.env, home = homedir5() } = {}) {
|
|
2483
|
-
const fromEnv = env.KAYNOOO_WORKSPACE === "" ? undefined : env.KAYNOOO_WORKSPACE;
|
|
2484
|
-
return resolve4(expandHome(given ?? fromEnv ?? configured(env, home) ?? join9(home, "Workspace"), home));
|
|
2485
|
-
}
|
|
2486
2473
|
// ../kit/src/picker.ts
|
|
2487
2474
|
init_folders();
|
|
2488
2475
|
init_state();
|
|
@@ -2493,11 +2480,11 @@ init_job();
|
|
|
2493
2480
|
init_redraw();
|
|
2494
2481
|
init_style();
|
|
2495
2482
|
import { openSync } from "fs";
|
|
2496
|
-
import
|
|
2483
|
+
import process23 from "process";
|
|
2497
2484
|
import tty from "tty";
|
|
2498
2485
|
|
|
2499
2486
|
// ../kit/src/picker/preview.ts
|
|
2500
|
-
import
|
|
2487
|
+
import process22 from "process";
|
|
2501
2488
|
|
|
2502
2489
|
// ../kit/src/shell.ts
|
|
2503
2490
|
var SEPARATORS = new Set([`
|
|
@@ -2584,7 +2571,7 @@ async function runPreview(template, line, signal, hidden = []) {
|
|
|
2584
2571
|
${previewCommand(template, line, hidden)}`], { stdin: "ignore", stdout: "pipe", stderr: "ignore", detached: true });
|
|
2585
2572
|
const stop = () => {
|
|
2586
2573
|
try {
|
|
2587
|
-
|
|
2574
|
+
process22.kill(-proc.pid, "SIGKILL");
|
|
2588
2575
|
} catch {
|
|
2589
2576
|
proc.kill();
|
|
2590
2577
|
}
|
|
@@ -2747,7 +2734,7 @@ function openTerminal() {
|
|
|
2747
2734
|
return fail("no terminal to read keys from (/dev/tty)");
|
|
2748
2735
|
}
|
|
2749
2736
|
const keys = Bun.file("/dev/tty").stream().getReader();
|
|
2750
|
-
const out =
|
|
2737
|
+
const out = process23.stderr;
|
|
2751
2738
|
let resize;
|
|
2752
2739
|
async function read(onChunk) {
|
|
2753
2740
|
const decoder = new TextDecoder;
|
|
@@ -2936,9 +2923,9 @@ async function select(rows, settings, terminal = openTerminal()) {
|
|
|
2936
2923
|
const ended = new Promise((resolve) => {
|
|
2937
2924
|
finish = resolve;
|
|
2938
2925
|
});
|
|
2939
|
-
|
|
2926
|
+
process23.once("exit", restore);
|
|
2940
2927
|
for (const signal of SIGNALS2)
|
|
2941
|
-
|
|
2928
|
+
process23.once(signal, stop);
|
|
2942
2929
|
try {
|
|
2943
2930
|
terminal.write(`${PASTE_ON}${MOUSE_ON}`);
|
|
2944
2931
|
terminal.listen(onChunk, () => draw(true));
|
|
@@ -2951,8 +2938,8 @@ async function select(rows, settings, terminal = openTerminal()) {
|
|
|
2951
2938
|
await ended;
|
|
2952
2939
|
} finally {
|
|
2953
2940
|
for (const signal of SIGNALS2)
|
|
2954
|
-
|
|
2955
|
-
|
|
2941
|
+
process23.off(signal, stop);
|
|
2942
|
+
process23.off("exit", restore);
|
|
2956
2943
|
restore();
|
|
2957
2944
|
}
|
|
2958
2945
|
return state.done === "accept" ? { rows: chosen(state), key: state.key, query: state.query } : undefined;
|
|
@@ -3002,7 +2989,7 @@ function list(rows) {
|
|
|
3002
2989
|
|
|
3003
2990
|
// src/branch.ts
|
|
3004
2991
|
import { basename } from "path";
|
|
3005
|
-
import
|
|
2992
|
+
import process24 from "process";
|
|
3006
2993
|
var usage2 = `gb [branch]: picks a git branch and switches to it
|
|
3007
2994
|
gb -
|
|
3008
2995
|
gb -c <name>
|
|
@@ -3227,7 +3214,7 @@ async function gb(args) {
|
|
|
3227
3214
|
if (parsed.values.json === true)
|
|
3228
3215
|
printJson(all);
|
|
3229
3216
|
else
|
|
3230
|
-
console.log(table2(all.map(row)).map((line) => takesControlCodes(
|
|
3217
|
+
console.log(table2(all.map(row)).map((line) => takesControlCodes(process24.stdout) ? line : Bun.stripANSI(line)).join(`
|
|
3231
3218
|
`));
|
|
3232
3219
|
return 0;
|
|
3233
3220
|
}
|
|
@@ -3331,7 +3318,7 @@ var OPTIONS = {
|
|
|
3331
3318
|
};
|
|
3332
3319
|
var NOT_A_REPOSITORY = /not a git repository/i;
|
|
3333
3320
|
var RENAME = /^[RC]\d*$/;
|
|
3334
|
-
var EDITOR_OFF = { ...
|
|
3321
|
+
var EDITOR_OFF = { ...process25.env, GIT_EDITOR: "true", GIT_MERGE_AUTOEDIT: "no" };
|
|
3335
3322
|
var BINARY_PROBE = 8000;
|
|
3336
3323
|
var SYMLINK_MODE = "120000";
|
|
3337
3324
|
async function ran(args, env) {
|
|
@@ -3372,7 +3359,7 @@ async function isMarkable(path, bytes, stages) {
|
|
|
3372
3359
|
async function conflicted() {
|
|
3373
3360
|
const top = (await ran(["rev-parse", "--show-toplevel"])).trim();
|
|
3374
3361
|
return Promise.all([...await unmergedStages()].map(async ([fromTop, stages]) => {
|
|
3375
|
-
const path = relative(
|
|
3362
|
+
const path = relative(process25.cwd(), join9(top, fromTop));
|
|
3376
3363
|
let bytes;
|
|
3377
3364
|
try {
|
|
3378
3365
|
bytes = readFileSync7(path);
|
|
@@ -3384,7 +3371,7 @@ async function conflicted() {
|
|
|
3384
3371
|
}));
|
|
3385
3372
|
}
|
|
3386
3373
|
function conflictLines(conflicts) {
|
|
3387
|
-
return conflicts.flatMap(({ path, hunks }) => hunks.length === 0 ? [`${role("path",
|
|
3374
|
+
return conflicts.flatMap(({ path, hunks }) => hunks.length === 0 ? [`${role("path", process25.stdout)(path)}: conflicted, no markers to show (deleted on a side, binary or a mode change)`] : hunks.flatMap((hunk) => [role("path", process25.stdout)(`${path}:${hunk.from}-${hunk.to}`), ...hunk.lines.map(({ line, text }) => `${line} ${text}`), ""]));
|
|
3388
3375
|
}
|
|
3389
3376
|
function fileLine(line) {
|
|
3390
3377
|
const [letter = "", from = "", to] = line.split("\t");
|
|
@@ -3402,7 +3389,7 @@ function conflictReport(branch, into, conflicts, json, squash = false) {
|
|
|
3402
3389
|
printJson({ outcome: "conflict", branch, into, conflicts: conflicts.map(({ path, hunks }) => ({ path, hunks })) });
|
|
3403
3390
|
return 1;
|
|
3404
3391
|
}
|
|
3405
|
-
console.log([marked("problem", `merging ${branch} into ${into} left ${conflicts.length} conflicted ${conflicts.length === 1 ? "file" : "files"}`,
|
|
3392
|
+
console.log([marked("problem", `merging ${branch} into ${into} left ${conflicts.length} conflicted ${conflicts.length === 1 ? "file" : "files"}`, process25.stdout), ...conflictLines(conflicts)].join(`
|
|
3406
3393
|
`).trimEnd());
|
|
3407
3394
|
console.log(squash ? `
|
|
3408
3395
|
resolve the files and commit them with gc, or git reset --merge to give up` : `
|
|
@@ -3423,7 +3410,7 @@ async function mergedReport(before, branch, into, json) {
|
|
|
3423
3410
|
const how = outcome === "merge" ? `merge commit ${sha.slice(0, 7)}` : "fast-forward";
|
|
3424
3411
|
const list = changed.split(`
|
|
3425
3412
|
`).filter(Boolean);
|
|
3426
|
-
console.log([marked("ok", `${into} <- ${branch}, ${how}, ${count}, ${list.length} ${list.length === 1 ? "file" : "files"} changed`,
|
|
3413
|
+
console.log([marked("ok", `${into} <- ${branch}, ${how}, ${count}, ${list.length} ${list.length === 1 ? "file" : "files"} changed`, process25.stdout), ...list.map(fileLine)].join(`
|
|
3427
3414
|
`));
|
|
3428
3415
|
return 0;
|
|
3429
3416
|
}
|
|
@@ -3438,7 +3425,7 @@ ${(stderr || stdout).trim()}`);
|
|
|
3438
3425
|
`);
|
|
3439
3426
|
return { outcome: code === 0 ? "clean" : "conflict", conflicts: [...new Set(rest.slice(0, Math.max(0, rest.indexOf(""))))] };
|
|
3440
3427
|
}
|
|
3441
|
-
function verdictText(verdict, tint = paint(
|
|
3428
|
+
function verdictText(verdict, tint = paint(process25.stdout)) {
|
|
3442
3429
|
if (verdict.outcome === "up-to-date")
|
|
3443
3430
|
return tint.dim("merged already");
|
|
3444
3431
|
return verdict.outcome === "clean" ? tint.green("clean") : tint.red(`conflicts: ${verdict.conflicts.join(", ")}`);
|
|
@@ -3452,7 +3439,7 @@ async function squashedReport(before, branch, into, json) {
|
|
|
3452
3439
|
}
|
|
3453
3440
|
const list = changed.split(`
|
|
3454
3441
|
`).filter(Boolean);
|
|
3455
|
-
console.log([marked("ok", `${branch} squashed into the index of ${into}: ${commits} ${commits === 1 ? "commit" : "commits"}, ${list.length} ${list.length === 1 ? "file" : "files"}, commit them with gc`,
|
|
3442
|
+
console.log([marked("ok", `${branch} squashed into the index of ${into}: ${commits} ${commits === 1 ? "commit" : "commits"}, ${list.length} ${list.length === 1 ? "file" : "files"}, commit them with gc`, process25.stdout), ...list.map(fileLine)].join(`
|
|
3456
3443
|
`));
|
|
3457
3444
|
return 0;
|
|
3458
3445
|
}
|
|
@@ -3466,9 +3453,9 @@ async function dryRun(branch, into, json) {
|
|
|
3466
3453
|
if (verdict.outcome === "up-to-date")
|
|
3467
3454
|
console.log(`${branch} is already merged into ${into}`);
|
|
3468
3455
|
else if (verdict.outcome === "clean")
|
|
3469
|
-
console.log(marked("ok", `merging ${branch} into ${into} would not conflict`,
|
|
3456
|
+
console.log(marked("ok", `merging ${branch} into ${into} would not conflict`, process25.stdout));
|
|
3470
3457
|
else
|
|
3471
|
-
console.log([marked("problem", `merging ${branch} into ${into} would conflict in ${verdict.conflicts.length} ${verdict.conflicts.length === 1 ? "file" : "files"}`,
|
|
3458
|
+
console.log([marked("problem", `merging ${branch} into ${into} would conflict in ${verdict.conflicts.length} ${verdict.conflicts.length === 1 ? "file" : "files"}`, process25.stdout), ...verdict.conflicts.map((path) => ` ${path}`)].join(`
|
|
3472
3459
|
`));
|
|
3473
3460
|
return code;
|
|
3474
3461
|
}
|
|
@@ -3543,7 +3530,7 @@ async function main(argv) {
|
|
|
3543
3530
|
if (json)
|
|
3544
3531
|
printJson({ outcome: "refused", into, conflicts: [...left, ...unpicked].map(({ path, hunks }) => ({ path, hunks })) });
|
|
3545
3532
|
else
|
|
3546
|
-
console.log([...problems.map((problem) => marked("problem", problem,
|
|
3533
|
+
console.log([...problems.map((problem) => marked("problem", problem, process25.stdout)), ...conflictLines([...left, ...unpicked])].join(`
|
|
3547
3534
|
`).trimEnd());
|
|
3548
3535
|
return 1;
|
|
3549
3536
|
}
|
|
@@ -3599,4 +3586,4 @@ ${USAGE}`);
|
|
|
3599
3586
|
return fail(`git merge failed:
|
|
3600
3587
|
${(merged.stderr || merged.stdout).trim()}`, NOT_A_REPOSITORY.test(merged.stderr) ? 2 : 1);
|
|
3601
3588
|
}
|
|
3602
|
-
|
|
3589
|
+
process25.exitCode = await runMain({ name: "gm", run: main });
|
package/dist/gp.js
CHANGED
|
@@ -1552,7 +1552,7 @@ var init_prompt = __esm(() => {
|
|
|
1552
1552
|
});
|
|
1553
1553
|
|
|
1554
1554
|
// src/gp.ts
|
|
1555
|
-
import
|
|
1555
|
+
import process23 from "process";
|
|
1556
1556
|
|
|
1557
1557
|
// ../kit/src/index.ts
|
|
1558
1558
|
init_args();
|
|
@@ -1982,12 +1982,15 @@ import { join as join6 } from "path";
|
|
|
1982
1982
|
import process16 from "process";
|
|
1983
1983
|
var SOCKET_VARIABLE = "KAYNOOO_ASKPASS_SOCKET";
|
|
1984
1984
|
var ECHOED = /username|yes\/no/i;
|
|
1985
|
+
var NO_PROMPTS = { GIT_TERMINAL_PROMPT: "0", GIT_ASKPASS: "", SSH_ASKPASS: "", SSH_ASKPASS_REQUIRE: "never" };
|
|
1985
1986
|
var quoted = (text) => `'${text.replaceAll("'", `'\\''`)}'`;
|
|
1986
1987
|
function askpass(pause = () => () => {
|
|
1987
1988
|
return;
|
|
1988
1989
|
}) {
|
|
1989
1990
|
if (process16.stdin.isTTY !== true || process16.stderr.isTTY !== true || process16.argv[1] === undefined)
|
|
1990
|
-
return
|
|
1991
|
+
return { env: { ...NO_PROMPTS }, close: () => {
|
|
1992
|
+
return;
|
|
1993
|
+
} };
|
|
1991
1994
|
const dir = mkdtempSync(join6(tmpdir(), "kaynooo-askpass-"));
|
|
1992
1995
|
const socketPath = join6(dir, "socket");
|
|
1993
1996
|
const script = join6(dir, "askpass");
|
|
@@ -2042,7 +2045,7 @@ ${SOCKET_VARIABLE}=${quoted(socketPath)} exec ${quoted(process16.execPath)} --no
|
|
|
2042
2045
|
`);
|
|
2043
2046
|
chmodSync(script, 448);
|
|
2044
2047
|
return {
|
|
2045
|
-
env: { GIT_ASKPASS: script, SSH_ASKPASS: script, SSH_ASKPASS_REQUIRE: "force" },
|
|
2048
|
+
env: { GIT_ASKPASS: script, GIT_TERMINAL_PROMPT: "0", SSH_ASKPASS: script, SSH_ASKPASS_REQUIRE: "force" },
|
|
2046
2049
|
close: () => {
|
|
2047
2050
|
server.stop(true);
|
|
2048
2051
|
rmSync(dir, { recursive: true, force: true });
|
|
@@ -2465,22 +2468,6 @@ async function watching(value, step, stream = process20.stdout, sleep = Bun.slee
|
|
|
2465
2468
|
}
|
|
2466
2469
|
// ../kit/src/workspace-root.ts
|
|
2467
2470
|
init_user_config();
|
|
2468
|
-
import { homedir as homedir5 } from "os";
|
|
2469
|
-
import { dirname as dirname5, join as join9, resolve as resolve4 } from "path";
|
|
2470
|
-
import process21 from "process";
|
|
2471
|
-
function expandHome(path, home) {
|
|
2472
|
-
if (path === "~")
|
|
2473
|
-
return home;
|
|
2474
|
-
return path.startsWith("~/") ? join9(home, path.slice(2)) : path;
|
|
2475
|
-
}
|
|
2476
|
-
function configured(env, home) {
|
|
2477
|
-
const folder = readUserConfig("config", { home, xdg: env.XDG_CONFIG_HOME }).workspace;
|
|
2478
|
-
return typeof folder === "string" && folder !== "" ? folder : undefined;
|
|
2479
|
-
}
|
|
2480
|
-
function workspaceRoot({ given, env = process21.env, home = homedir5() } = {}) {
|
|
2481
|
-
const fromEnv = env.KAYNOOO_WORKSPACE === "" ? undefined : env.KAYNOOO_WORKSPACE;
|
|
2482
|
-
return resolve4(expandHome(given ?? fromEnv ?? configured(env, home) ?? join9(home, "Workspace"), home));
|
|
2483
|
-
}
|
|
2484
2471
|
// src/git.ts
|
|
2485
2472
|
async function git2(args, env) {
|
|
2486
2473
|
const ran = await runCommand(["git", "--no-optional-locks", "-c", "core.quotePath=false", ...args], env === undefined ? {} : { env });
|
|
@@ -2490,8 +2477,8 @@ async function git2(args, env) {
|
|
|
2490
2477
|
|
|
2491
2478
|
// src/repos.ts
|
|
2492
2479
|
import { readdir } from "fs/promises";
|
|
2493
|
-
import { join as
|
|
2494
|
-
import
|
|
2480
|
+
import { join as join9, relative, resolve as resolve4 } from "path";
|
|
2481
|
+
import process22 from "process";
|
|
2495
2482
|
|
|
2496
2483
|
// src/status.ts
|
|
2497
2484
|
var AHEAD_BEHIND = /\+(\d+) -(\d+)/;
|
|
@@ -2587,9 +2574,9 @@ async function reposUnder(root, depth = DEPTH) {
|
|
|
2587
2574
|
found.push(dir);
|
|
2588
2575
|
if (left === 0)
|
|
2589
2576
|
return;
|
|
2590
|
-
await Promise.all(entries.filter((entry) => entry.isDirectory() && !entry.name.startsWith(".") && !SKIPPED.has(entry.name)).map(async (entry) => walk(
|
|
2577
|
+
await Promise.all(entries.filter((entry) => entry.isDirectory() && !entry.name.startsWith(".") && !SKIPPED.has(entry.name)).map(async (entry) => walk(join9(dir, entry.name), left - 1)));
|
|
2591
2578
|
}
|
|
2592
|
-
await walk(
|
|
2579
|
+
await walk(resolve4(root), depth);
|
|
2593
2580
|
return found.sort();
|
|
2594
2581
|
}
|
|
2595
2582
|
async function toplevelOf(dir) {
|
|
@@ -2597,14 +2584,14 @@ async function toplevelOf(dir) {
|
|
|
2597
2584
|
return read.code === 0 ? read.stdout.trim() : undefined;
|
|
2598
2585
|
}
|
|
2599
2586
|
async function reposOf(roots) {
|
|
2600
|
-
const starts = roots.length > 0 ? roots : [await toplevelOf(".") ??
|
|
2587
|
+
const starts = roots.length > 0 ? roots : [await toplevelOf(".") ?? process22.cwd()];
|
|
2601
2588
|
const found = await Promise.all(starts.map(async (root) => reposUnder(root)));
|
|
2602
2589
|
return [...new Set(found.flat())].sort();
|
|
2603
2590
|
}
|
|
2604
2591
|
async function repoState(dir) {
|
|
2605
2592
|
const [read, log] = await Promise.all([git2(["-C", dir, "status", "--porcelain=v2", "--branch"]), git2(["-C", dir, "log", "-1", "--format=%h%x00%s"])]);
|
|
2606
2593
|
const [sha, title = ""] = log.code === 0 && log.stdout.trim() !== "" ? log.stdout.trim().split("\x00") : [];
|
|
2607
|
-
return { path: relative(
|
|
2594
|
+
return { path: relative(process22.cwd(), dir) || ".", dir, status: read.code === 0 ? parseStatus(read.stdout) : null, head: sha === undefined ? null : { sha, title } };
|
|
2608
2595
|
}
|
|
2609
2596
|
function trackingOf(status) {
|
|
2610
2597
|
if (status.upstream === null)
|
|
@@ -2721,16 +2708,16 @@ async function push(repo, asked, { dryRun, extra, env }) {
|
|
|
2721
2708
|
return pushed.code === 0 ? { path, branch, remote, commits, outcome: "pushed" } : { path, branch, remote, commits, outcome: "refused", reason: whyRefused(pushed.stderr) };
|
|
2722
2709
|
}
|
|
2723
2710
|
function line(result) {
|
|
2724
|
-
const { dim } = paint(
|
|
2711
|
+
const { dim } = paint(process23.stdout);
|
|
2725
2712
|
const sent = result.commits === null ? "" : `, ${result.commits} ${result.commits === 1 ? "commit" : "commits"}`;
|
|
2726
2713
|
const what = `${result.branch} -> ${result.remote}${sent}`;
|
|
2727
2714
|
const said = {
|
|
2728
|
-
pushed: () => marked("ok", `pushed ${what}`,
|
|
2715
|
+
pushed: () => marked("ok", `pushed ${what}`, process23.stdout),
|
|
2729
2716
|
"would-push": () => `would push ${what}`,
|
|
2730
2717
|
skipped: () => dim(result.reason ?? "skipped"),
|
|
2731
|
-
refused: () => marked("problem", `${result.branch === null ? "" : `${result.branch}: `}${result.reason ?? "refused"}`,
|
|
2718
|
+
refused: () => marked("problem", `${result.branch === null ? "" : `${result.branch}: `}${result.reason ?? "refused"}`, process23.stdout)
|
|
2732
2719
|
}[result.outcome];
|
|
2733
|
-
return [role("path",
|
|
2720
|
+
return [role("path", process23.stdout)(result.path), said()];
|
|
2734
2721
|
}
|
|
2735
2722
|
async function main(argv) {
|
|
2736
2723
|
const { values, positionals, rest = [] } = parse(argv, USAGE, OPTIONS, { positionals: ["[dir]..."], rest: true, exits: EXITS, replaces: "git push, git push -u origin <branch> and a git -C <repo> push per nested repository", examples: ["gp", ["gp --repos", "every repository nested in this one"], ["gp --repos --dry-run", "what would go out"], ["gp . ../other", "this repository and a sibling"], ["gp -b feature", "a branch other than the current one"], ["gp -- --force-with-lease", "flags for git push"]] });
|
|
@@ -2741,14 +2728,14 @@ async function main(argv) {
|
|
|
2741
2728
|
const results = [];
|
|
2742
2729
|
const progress = progressLine();
|
|
2743
2730
|
const prompts = askpass(progress.pause);
|
|
2744
|
-
const env =
|
|
2731
|
+
const env = { ...process23.env, ...prompts.env };
|
|
2745
2732
|
try {
|
|
2746
2733
|
for (const [at, { repo, branch }] of pushes.entries()) {
|
|
2747
2734
|
progress.update(pushes.length > 1 ? { step: `pushing ${repo.path}`, done: at, total: pushes.length, unit: "pushes" } : { step: `pushing ${repo.path}` });
|
|
2748
2735
|
results.push(await push(repo, branch, { dryRun: values["dry-run"] === true, extra: rest, env }));
|
|
2749
2736
|
}
|
|
2750
2737
|
} finally {
|
|
2751
|
-
prompts
|
|
2738
|
+
prompts.close();
|
|
2752
2739
|
progress.stop();
|
|
2753
2740
|
}
|
|
2754
2741
|
if (values.json === true)
|
|
@@ -2757,4 +2744,4 @@ async function main(argv) {
|
|
|
2757
2744
|
console.log(table(results.map(line)));
|
|
2758
2745
|
return results.some((result) => result.outcome === "refused") ? 1 : 0;
|
|
2759
2746
|
}
|
|
2760
|
-
|
|
2747
|
+
process23.exitCode = await runMain({ name: "gp", run: main });
|