@kaynooo/cli-git 0.18.0 → 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/dist/gp.js CHANGED
@@ -652,21 +652,32 @@ function wholeNumber(value, name, fallback, min = 1) {
652
652
  badUsage(`${name.startsWith("<") ? name : `--${name}`} takes a whole number from ${min}, not ${value}`);
653
653
  return number;
654
654
  }
655
+ function durationMs(text, unit) {
656
+ if (BARE_DURATION.test(text))
657
+ return Number(text) * UNIT_MS[unit];
658
+ if (!DURATION.test(text))
659
+ return 0;
660
+ let ms = 0;
661
+ for (const [, amount, part] of text.matchAll(DURATION_PART))
662
+ ms += Number(amount) * UNIT_MS[part];
663
+ return ms;
664
+ }
655
665
  function duration(value, name, fallback, unit = "s") {
656
666
  if (value === undefined)
657
667
  return fallback;
658
- const match = DURATION.exec(value.trim());
659
- const ms = match === null ? 0 : Number(match[1]) * UNIT_MS[match[2] ?? unit];
668
+ const ms = durationMs(value.trim(), unit);
660
669
  if (ms < 1)
661
670
  badUsage(`--${name} takes a duration such as 30s, 5m, 1h or 7d, not ${value}`);
662
671
  return ms;
663
672
  }
664
- var WHOLE, DURATION, UNIT_MS;
673
+ var WHOLE, BARE_DURATION, DURATION, DURATION_PART, UNIT_MS;
665
674
  var init_input = __esm(() => {
666
675
  init_args();
667
676
  WHOLE = /^\d+$/;
668
- DURATION = /^(\d+(?:\.\d+)?)(ms|[smhd])?$/;
669
- UNIT_MS = { ms: 1, s: 1000, m: 60000, h: 3600000, d: 86400000 };
677
+ BARE_DURATION = /^\d+(?:\.\d+)?$/;
678
+ DURATION = /^(?:\d+(?:\.\d+)?(?:ms|min|[smhd]))+$/;
679
+ DURATION_PART = /(\d+(?:\.\d+)?)(ms|min|[smhd])/g;
680
+ UNIT_MS = { ms: 1, s: 1000, m: 60000, min: 60000, h: 3600000, d: 86400000 };
670
681
  });
671
682
 
672
683
  // ../kit/src/args.ts
@@ -1541,7 +1552,7 @@ var init_prompt = __esm(() => {
1541
1552
  });
1542
1553
 
1543
1554
  // src/gp.ts
1544
- import process24 from "process";
1555
+ import process23 from "process";
1545
1556
 
1546
1557
  // ../kit/src/index.ts
1547
1558
  init_args();
@@ -1971,12 +1982,15 @@ import { join as join6 } from "path";
1971
1982
  import process16 from "process";
1972
1983
  var SOCKET_VARIABLE = "KAYNOOO_ASKPASS_SOCKET";
1973
1984
  var ECHOED = /username|yes\/no/i;
1985
+ var NO_PROMPTS = { GIT_TERMINAL_PROMPT: "0", GIT_ASKPASS: "", SSH_ASKPASS: "", SSH_ASKPASS_REQUIRE: "never" };
1974
1986
  var quoted = (text) => `'${text.replaceAll("'", `'\\''`)}'`;
1975
1987
  function askpass(pause = () => () => {
1976
1988
  return;
1977
1989
  }) {
1978
1990
  if (process16.stdin.isTTY !== true || process16.stderr.isTTY !== true || process16.argv[1] === undefined)
1979
- return;
1991
+ return { env: { ...NO_PROMPTS }, close: () => {
1992
+ return;
1993
+ } };
1980
1994
  const dir = mkdtempSync(join6(tmpdir(), "kaynooo-askpass-"));
1981
1995
  const socketPath = join6(dir, "socket");
1982
1996
  const script = join6(dir, "askpass");
@@ -2031,7 +2045,7 @@ ${SOCKET_VARIABLE}=${quoted(socketPath)} exec ${quoted(process16.execPath)} --no
2031
2045
  `);
2032
2046
  chmodSync(script, 448);
2033
2047
  return {
2034
- 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" },
2035
2049
  close: () => {
2036
2050
  server.stop(true);
2037
2051
  rmSync(dir, { recursive: true, force: true });
@@ -2454,22 +2468,6 @@ async function watching(value, step, stream = process20.stdout, sleep = Bun.slee
2454
2468
  }
2455
2469
  // ../kit/src/workspace-root.ts
2456
2470
  init_user_config();
2457
- import { homedir as homedir5 } from "os";
2458
- import { dirname as dirname5, join as join9, resolve as resolve4 } from "path";
2459
- import process21 from "process";
2460
- function expandHome(path, home) {
2461
- if (path === "~")
2462
- return home;
2463
- return path.startsWith("~/") ? join9(home, path.slice(2)) : path;
2464
- }
2465
- function configured(env, home) {
2466
- const folder = readUserConfig("config", { home, xdg: env.XDG_CONFIG_HOME }).workspace;
2467
- return typeof folder === "string" && folder !== "" ? folder : undefined;
2468
- }
2469
- function workspaceRoot({ given, env = process21.env, home = homedir5() } = {}) {
2470
- const fromEnv = env.KAYNOOO_WORKSPACE === "" ? undefined : env.KAYNOOO_WORKSPACE;
2471
- return resolve4(expandHome(given ?? fromEnv ?? configured(env, home) ?? join9(home, "Workspace"), home));
2472
- }
2473
2471
  // src/git.ts
2474
2472
  async function git2(args, env) {
2475
2473
  const ran = await runCommand(["git", "--no-optional-locks", "-c", "core.quotePath=false", ...args], env === undefined ? {} : { env });
@@ -2479,8 +2477,8 @@ async function git2(args, env) {
2479
2477
 
2480
2478
  // src/repos.ts
2481
2479
  import { readdir } from "fs/promises";
2482
- import { join as join10, relative, resolve as resolve5 } from "path";
2483
- import process23 from "process";
2480
+ import { join as join9, relative, resolve as resolve4 } from "path";
2481
+ import process22 from "process";
2484
2482
 
2485
2483
  // src/status.ts
2486
2484
  var AHEAD_BEHIND = /\+(\d+) -(\d+)/;
@@ -2576,9 +2574,9 @@ async function reposUnder(root, depth = DEPTH) {
2576
2574
  found.push(dir);
2577
2575
  if (left === 0)
2578
2576
  return;
2579
- await Promise.all(entries.filter((entry) => entry.isDirectory() && !entry.name.startsWith(".") && !SKIPPED.has(entry.name)).map(async (entry) => walk(join10(dir, entry.name), left - 1)));
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)));
2580
2578
  }
2581
- await walk(resolve5(root), depth);
2579
+ await walk(resolve4(root), depth);
2582
2580
  return found.sort();
2583
2581
  }
2584
2582
  async function toplevelOf(dir) {
@@ -2586,14 +2584,14 @@ async function toplevelOf(dir) {
2586
2584
  return read.code === 0 ? read.stdout.trim() : undefined;
2587
2585
  }
2588
2586
  async function reposOf(roots) {
2589
- const starts = roots.length > 0 ? roots : [await toplevelOf(".") ?? process23.cwd()];
2587
+ const starts = roots.length > 0 ? roots : [await toplevelOf(".") ?? process22.cwd()];
2590
2588
  const found = await Promise.all(starts.map(async (root) => reposUnder(root)));
2591
2589
  return [...new Set(found.flat())].sort();
2592
2590
  }
2593
2591
  async function repoState(dir) {
2594
2592
  const [read, log] = await Promise.all([git2(["-C", dir, "status", "--porcelain=v2", "--branch"]), git2(["-C", dir, "log", "-1", "--format=%h%x00%s"])]);
2595
2593
  const [sha, title = ""] = log.code === 0 && log.stdout.trim() !== "" ? log.stdout.trim().split("\x00") : [];
2596
- return { path: relative(process23.cwd(), dir) || ".", dir, status: read.code === 0 ? parseStatus(read.stdout) : null, head: sha === undefined ? null : { sha, title } };
2594
+ return { path: relative(process22.cwd(), dir) || ".", dir, status: read.code === 0 ? parseStatus(read.stdout) : null, head: sha === undefined ? null : { sha, title } };
2597
2595
  }
2598
2596
  function trackingOf(status) {
2599
2597
  if (status.upstream === null)
@@ -2710,16 +2708,16 @@ async function push(repo, asked, { dryRun, extra, env }) {
2710
2708
  return pushed.code === 0 ? { path, branch, remote, commits, outcome: "pushed" } : { path, branch, remote, commits, outcome: "refused", reason: whyRefused(pushed.stderr) };
2711
2709
  }
2712
2710
  function line(result) {
2713
- const { dim } = paint(process24.stdout);
2711
+ const { dim } = paint(process23.stdout);
2714
2712
  const sent = result.commits === null ? "" : `, ${result.commits} ${result.commits === 1 ? "commit" : "commits"}`;
2715
2713
  const what = `${result.branch} -> ${result.remote}${sent}`;
2716
2714
  const said = {
2717
- pushed: () => marked("ok", `pushed ${what}`, process24.stdout),
2715
+ pushed: () => marked("ok", `pushed ${what}`, process23.stdout),
2718
2716
  "would-push": () => `would push ${what}`,
2719
2717
  skipped: () => dim(result.reason ?? "skipped"),
2720
- refused: () => marked("problem", `${result.branch === null ? "" : `${result.branch}: `}${result.reason ?? "refused"}`, process24.stdout)
2718
+ refused: () => marked("problem", `${result.branch === null ? "" : `${result.branch}: `}${result.reason ?? "refused"}`, process23.stdout)
2721
2719
  }[result.outcome];
2722
- return [role("path", process24.stdout)(result.path), said()];
2720
+ return [role("path", process23.stdout)(result.path), said()];
2723
2721
  }
2724
2722
  async function main(argv) {
2725
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"]] });
@@ -2730,14 +2728,14 @@ async function main(argv) {
2730
2728
  const results = [];
2731
2729
  const progress = progressLine();
2732
2730
  const prompts = askpass(progress.pause);
2733
- const env = prompts === undefined ? undefined : { ...process24.env, ...prompts.env };
2731
+ const env = { ...process23.env, ...prompts.env };
2734
2732
  try {
2735
2733
  for (const [at, { repo, branch }] of pushes.entries()) {
2736
2734
  progress.update(pushes.length > 1 ? { step: `pushing ${repo.path}`, done: at, total: pushes.length, unit: "pushes" } : { step: `pushing ${repo.path}` });
2737
2735
  results.push(await push(repo, branch, { dryRun: values["dry-run"] === true, extra: rest, env }));
2738
2736
  }
2739
2737
  } finally {
2740
- prompts?.close();
2738
+ prompts.close();
2741
2739
  progress.stop();
2742
2740
  }
2743
2741
  if (values.json === true)
@@ -2746,4 +2744,4 @@ async function main(argv) {
2746
2744
  console.log(table(results.map(line)));
2747
2745
  return results.some((result) => result.outcome === "refused") ? 1 : 0;
2748
2746
  }
2749
- process24.exitCode = await runMain({ name: "gp", run: main });
2747
+ process23.exitCode = await runMain({ name: "gp", run: main });
package/dist/gst.js CHANGED
@@ -652,21 +652,32 @@ function wholeNumber(value, name, fallback, min = 1) {
652
652
  badUsage(`${name.startsWith("<") ? name : `--${name}`} takes a whole number from ${min}, not ${value}`);
653
653
  return number;
654
654
  }
655
+ function durationMs(text, unit) {
656
+ if (BARE_DURATION.test(text))
657
+ return Number(text) * UNIT_MS[unit];
658
+ if (!DURATION.test(text))
659
+ return 0;
660
+ let ms = 0;
661
+ for (const [, amount, part] of text.matchAll(DURATION_PART))
662
+ ms += Number(amount) * UNIT_MS[part];
663
+ return ms;
664
+ }
655
665
  function duration(value, name, fallback, unit = "s") {
656
666
  if (value === undefined)
657
667
  return fallback;
658
- const match = DURATION.exec(value.trim());
659
- const ms = match === null ? 0 : Number(match[1]) * UNIT_MS[match[2] ?? unit];
668
+ const ms = durationMs(value.trim(), unit);
660
669
  if (ms < 1)
661
670
  badUsage(`--${name} takes a duration such as 30s, 5m, 1h or 7d, not ${value}`);
662
671
  return ms;
663
672
  }
664
- var WHOLE, DURATION, UNIT_MS;
673
+ var WHOLE, BARE_DURATION, DURATION, DURATION_PART, UNIT_MS;
665
674
  var init_input = __esm(() => {
666
675
  init_args();
667
676
  WHOLE = /^\d+$/;
668
- DURATION = /^(\d+(?:\.\d+)?)(ms|[smhd])?$/;
669
- UNIT_MS = { ms: 1, s: 1000, m: 60000, h: 3600000, d: 86400000 };
677
+ BARE_DURATION = /^\d+(?:\.\d+)?$/;
678
+ DURATION = /^(?:\d+(?:\.\d+)?(?:ms|min|[smhd]))+$/;
679
+ DURATION_PART = /(\d+(?:\.\d+)?)(ms|min|[smhd])/g;
680
+ UNIT_MS = { ms: 1, s: 1000, m: 60000, min: 60000, h: 3600000, d: 86400000 };
670
681
  });
671
682
 
672
683
  // ../kit/src/args.ts
@@ -1541,7 +1552,7 @@ var init_prompt = __esm(() => {
1541
1552
  });
1542
1553
 
1543
1554
  // src/gst.ts
1544
- import process25 from "process";
1555
+ import process24 from "process";
1545
1556
 
1546
1557
  // ../kit/src/index.ts
1547
1558
  init_args();
@@ -1971,12 +1982,15 @@ import { join as join6 } from "path";
1971
1982
  import process16 from "process";
1972
1983
  var SOCKET_VARIABLE = "KAYNOOO_ASKPASS_SOCKET";
1973
1984
  var ECHOED = /username|yes\/no/i;
1985
+ var NO_PROMPTS = { GIT_TERMINAL_PROMPT: "0", GIT_ASKPASS: "", SSH_ASKPASS: "", SSH_ASKPASS_REQUIRE: "never" };
1974
1986
  var quoted = (text) => `'${text.replaceAll("'", `'\\''`)}'`;
1975
1987
  function askpass(pause = () => () => {
1976
1988
  return;
1977
1989
  }) {
1978
1990
  if (process16.stdin.isTTY !== true || process16.stderr.isTTY !== true || process16.argv[1] === undefined)
1979
- return;
1991
+ return { env: { ...NO_PROMPTS }, close: () => {
1992
+ return;
1993
+ } };
1980
1994
  const dir = mkdtempSync(join6(tmpdir(), "kaynooo-askpass-"));
1981
1995
  const socketPath = join6(dir, "socket");
1982
1996
  const script = join6(dir, "askpass");
@@ -2031,7 +2045,7 @@ ${SOCKET_VARIABLE}=${quoted(socketPath)} exec ${quoted(process16.execPath)} --no
2031
2045
  `);
2032
2046
  chmodSync(script, 448);
2033
2047
  return {
2034
- 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" },
2035
2049
  close: () => {
2036
2050
  server.stop(true);
2037
2051
  rmSync(dir, { recursive: true, force: true });
@@ -2454,25 +2468,9 @@ async function watching(value, step, stream = process20.stdout, sleep = Bun.slee
2454
2468
  }
2455
2469
  // ../kit/src/workspace-root.ts
2456
2470
  init_user_config();
2457
- import { homedir as homedir5 } from "os";
2458
- import { dirname as dirname5, join as join9, resolve as resolve4 } from "path";
2459
- import process21 from "process";
2460
- function expandHome(path, home) {
2461
- if (path === "~")
2462
- return home;
2463
- return path.startsWith("~/") ? join9(home, path.slice(2)) : path;
2464
- }
2465
- function configured(env, home) {
2466
- const folder = readUserConfig("config", { home, xdg: env.XDG_CONFIG_HOME }).workspace;
2467
- return typeof folder === "string" && folder !== "" ? folder : undefined;
2468
- }
2469
- function workspaceRoot({ given, env = process21.env, home = homedir5() } = {}) {
2470
- const fromEnv = env.KAYNOOO_WORKSPACE === "" ? undefined : env.KAYNOOO_WORKSPACE;
2471
- return resolve4(expandHome(given ?? fromEnv ?? configured(env, home) ?? join9(home, "Workspace"), home));
2472
- }
2473
2471
  // src/colour.ts
2474
- import process23 from "process";
2475
- function letter(status, stream = process23.stdout) {
2472
+ import process22 from "process";
2473
+ function letter(status, stream = process22.stdout) {
2476
2474
  const colors = paint(stream);
2477
2475
  const tint = { A: colors.green, M: colors.yellow, D: colors.red, U: colors.red, R: colors.cyan, C: colors.cyan }[status] ?? colors.dim;
2478
2476
  return tint(status);
@@ -2487,7 +2485,7 @@ async function git2(args, env) {
2487
2485
 
2488
2486
  // src/operation.ts
2489
2487
  import { existsSync as existsSync4, readFileSync as readFileSync7 } from "fs";
2490
- import { join as join10 } from "path";
2488
+ import { join as join9 } from "path";
2491
2489
  function numberIn(path) {
2492
2490
  try {
2493
2491
  const value = Number.parseInt(readFileSync7(path, "utf8"), 10);
@@ -2497,11 +2495,11 @@ function numberIn(path) {
2497
2495
  }
2498
2496
  }
2499
2497
  function operationOf(gitDir) {
2500
- const has = (name) => existsSync4(join10(gitDir, name));
2498
+ const has = (name) => existsSync4(join9(gitDir, name));
2501
2499
  if (has("rebase-merge"))
2502
- return { kind: "rebase", step: numberIn(join10(gitDir, "rebase-merge/msgnum")), total: numberIn(join10(gitDir, "rebase-merge/end")) };
2500
+ return { kind: "rebase", step: numberIn(join9(gitDir, "rebase-merge/msgnum")), total: numberIn(join9(gitDir, "rebase-merge/end")) };
2503
2501
  if (has("rebase-apply"))
2504
- return { kind: "rebase", step: numberIn(join10(gitDir, "rebase-apply/next")), total: numberIn(join10(gitDir, "rebase-apply/last")) };
2502
+ return { kind: "rebase", step: numberIn(join9(gitDir, "rebase-apply/next")), total: numberIn(join9(gitDir, "rebase-apply/last")) };
2505
2503
  for (const [file, kind] of [["MERGE_HEAD", "merge"], ["CHERRY_PICK_HEAD", "cherry-pick"], ["REVERT_HEAD", "revert"], ["BISECT_LOG", "bisect"]]) {
2506
2504
  if (has(file))
2507
2505
  return { kind };
@@ -2511,8 +2509,8 @@ function operationOf(gitDir) {
2511
2509
 
2512
2510
  // src/repos.ts
2513
2511
  import { readdir } from "fs/promises";
2514
- import { join as join11, relative, resolve as resolve5 } from "path";
2515
- import process24 from "process";
2512
+ import { join as join10, relative, resolve as resolve4 } from "path";
2513
+ import process23 from "process";
2516
2514
 
2517
2515
  // src/status.ts
2518
2516
  var AHEAD_BEHIND = /\+(\d+) -(\d+)/;
@@ -2608,9 +2606,9 @@ async function reposUnder(root, depth = DEPTH) {
2608
2606
  found.push(dir);
2609
2607
  if (left === 0)
2610
2608
  return;
2611
- await Promise.all(entries.filter((entry) => entry.isDirectory() && !entry.name.startsWith(".") && !SKIPPED.has(entry.name)).map(async (entry) => walk(join11(dir, entry.name), left - 1)));
2609
+ await Promise.all(entries.filter((entry) => entry.isDirectory() && !entry.name.startsWith(".") && !SKIPPED.has(entry.name)).map(async (entry) => walk(join10(dir, entry.name), left - 1)));
2612
2610
  }
2613
- await walk(resolve5(root), depth);
2611
+ await walk(resolve4(root), depth);
2614
2612
  return found.sort();
2615
2613
  }
2616
2614
  async function toplevelOf(dir) {
@@ -2618,14 +2616,14 @@ async function toplevelOf(dir) {
2618
2616
  return read.code === 0 ? read.stdout.trim() : undefined;
2619
2617
  }
2620
2618
  async function reposOf(roots) {
2621
- const starts = roots.length > 0 ? roots : [await toplevelOf(".") ?? process24.cwd()];
2619
+ const starts = roots.length > 0 ? roots : [await toplevelOf(".") ?? process23.cwd()];
2622
2620
  const found = await Promise.all(starts.map(async (root) => reposUnder(root)));
2623
2621
  return [...new Set(found.flat())].sort();
2624
2622
  }
2625
2623
  async function repoState(dir) {
2626
2624
  const [read, log] = await Promise.all([git2(["-C", dir, "status", "--porcelain=v2", "--branch"]), git2(["-C", dir, "log", "-1", "--format=%h%x00%s"])]);
2627
2625
  const [sha, title = ""] = log.code === 0 && log.stdout.trim() !== "" ? log.stdout.trim().split("\x00") : [];
2628
- return { path: relative(process24.cwd(), dir) || ".", dir, status: read.code === 0 ? parseStatus(read.stdout) : null, head: sha === undefined ? null : { sha, title } };
2626
+ return { path: relative(process23.cwd(), dir) || ".", dir, status: read.code === 0 ? parseStatus(read.stdout) : null, head: sha === undefined ? null : { sha, title } };
2629
2627
  }
2630
2628
  function trackingOf(status) {
2631
2629
  if (status.upstream === null)
@@ -2697,18 +2695,18 @@ async function listRepos(roots, json) {
2697
2695
  printJson(repos.map(({ path, status, head }) => status === null ? { path, error: "git could not read it" } : { path, ...jsonOf(status, head) }));
2698
2696
  return 0;
2699
2697
  }
2700
- const dim = paint(process25.stdout).dim;
2698
+ const dim = paint(process24.stdout).dim;
2701
2699
  const cells = (repo) => {
2702
2700
  if (repo.status === null)
2703
- return [role("path", process25.stdout)(repo.path), "", "", "git could not read it"];
2701
+ return [role("path", process24.stdout)(repo.path), "", "", "git could not read it"];
2704
2702
  const changes = changesOf(repo.status);
2705
- return [role("path", process25.stdout)(repo.path), branchOf(repo.status), trackingOf(repo.status), changes === "clean" ? dim(changes) : changes];
2703
+ return [role("path", process24.stdout)(repo.path), branchOf(repo.status), trackingOf(repo.status), changes === "clean" ? dim(changes) : changes];
2706
2704
  };
2707
2705
  console.log(table(repos.map(cells)));
2708
2706
  return 0;
2709
2707
  }
2710
2708
  function group(title, lines) {
2711
- return lines.length === 0 ? [] : [paint(process25.stdout).bold(`${title}:`), ...lines.map((line) => ` ${line}`)];
2709
+ return lines.length === 0 ? [] : [paint(process24.stdout).bold(`${title}:`), ...lines.map((line) => ` ${line}`)];
2712
2710
  }
2713
2711
  function staged({ index, from, path }) {
2714
2712
  return `${letter(index)} ${from === undefined ? "" : `${from} -> `}${path}`;
@@ -2748,12 +2746,12 @@ ${USAGE}`);
2748
2746
  summary(status, head.code === 0 ? head.stdout : "", extra),
2749
2747
  ...group("staged", status.changes.filter((change) => change.index !== ".").map(staged)),
2750
2748
  ...group("unstaged", status.changes.filter((change) => change.worktree !== ".").map((change) => `${letter(change.worktree)} ${change.path}`)),
2751
- ...group("untracked", status.untracked.map((file) => paint(process25.stdout).dim(file))),
2752
- ...group("conflicted", status.conflicted.map((file) => paint(process25.stdout).red(file))),
2753
- ...group("commits", commits.map(([commitSha = "", commitTitle = ""]) => `${role("id", process25.stdout)(commitSha)} ${commitTitle}`))
2749
+ ...group("untracked", status.untracked.map((file) => paint(process24.stdout).dim(file))),
2750
+ ...group("conflicted", status.conflicted.map((file) => paint(process24.stdout).red(file))),
2751
+ ...group("commits", commits.map(([commitSha = "", commitTitle = ""]) => `${role("id", process24.stdout)(commitSha)} ${commitTitle}`))
2754
2752
  ];
2755
2753
  console.log(lines.join(`
2756
2754
  `));
2757
2755
  return 0;
2758
2756
  }
2759
- process25.exitCode = await runMain({ name: "gst", run: main });
2757
+ process24.exitCode = await runMain({ name: "gst", run: main });
package/dist/gu.js CHANGED
@@ -652,21 +652,32 @@ function wholeNumber(value, name, fallback, min = 1) {
652
652
  badUsage(`${name.startsWith("<") ? name : `--${name}`} takes a whole number from ${min}, not ${value}`);
653
653
  return number;
654
654
  }
655
+ function durationMs(text, unit) {
656
+ if (BARE_DURATION.test(text))
657
+ return Number(text) * UNIT_MS[unit];
658
+ if (!DURATION.test(text))
659
+ return 0;
660
+ let ms = 0;
661
+ for (const [, amount, part] of text.matchAll(DURATION_PART))
662
+ ms += Number(amount) * UNIT_MS[part];
663
+ return ms;
664
+ }
655
665
  function duration(value, name, fallback, unit = "s") {
656
666
  if (value === undefined)
657
667
  return fallback;
658
- const match = DURATION.exec(value.trim());
659
- const ms = match === null ? 0 : Number(match[1]) * UNIT_MS[match[2] ?? unit];
668
+ const ms = durationMs(value.trim(), unit);
660
669
  if (ms < 1)
661
670
  badUsage(`--${name} takes a duration such as 30s, 5m, 1h or 7d, not ${value}`);
662
671
  return ms;
663
672
  }
664
- var WHOLE, DURATION, UNIT_MS;
673
+ var WHOLE, BARE_DURATION, DURATION, DURATION_PART, UNIT_MS;
665
674
  var init_input = __esm(() => {
666
675
  init_args();
667
676
  WHOLE = /^\d+$/;
668
- DURATION = /^(\d+(?:\.\d+)?)(ms|[smhd])?$/;
669
- UNIT_MS = { ms: 1, s: 1000, m: 60000, h: 3600000, d: 86400000 };
677
+ BARE_DURATION = /^\d+(?:\.\d+)?$/;
678
+ DURATION = /^(?:\d+(?:\.\d+)?(?:ms|min|[smhd]))+$/;
679
+ DURATION_PART = /(\d+(?:\.\d+)?)(ms|min|[smhd])/g;
680
+ UNIT_MS = { ms: 1, s: 1000, m: 60000, min: 60000, h: 3600000, d: 86400000 };
670
681
  });
671
682
 
672
683
  // ../kit/src/args.ts
@@ -1542,8 +1553,8 @@ var init_prompt = __esm(() => {
1542
1553
 
1543
1554
  // src/gu.ts
1544
1555
  import { mkdirSync as mkdirSync3, rmSync as rmSync2, writeFileSync as writeFileSync3 } from "fs";
1545
- import { join as join10, resolve as resolve5 } from "path";
1546
- import process23 from "process";
1556
+ import { join as join9, resolve as resolve4 } from "path";
1557
+ import process22 from "process";
1547
1558
 
1548
1559
  // ../kit/src/index.ts
1549
1560
  init_args();
@@ -1973,12 +1984,15 @@ import { join as join6 } from "path";
1973
1984
  import process16 from "process";
1974
1985
  var SOCKET_VARIABLE = "KAYNOOO_ASKPASS_SOCKET";
1975
1986
  var ECHOED = /username|yes\/no/i;
1987
+ var NO_PROMPTS = { GIT_TERMINAL_PROMPT: "0", GIT_ASKPASS: "", SSH_ASKPASS: "", SSH_ASKPASS_REQUIRE: "never" };
1976
1988
  var quoted = (text) => `'${text.replaceAll("'", `'\\''`)}'`;
1977
1989
  function askpass(pause = () => () => {
1978
1990
  return;
1979
1991
  }) {
1980
1992
  if (process16.stdin.isTTY !== true || process16.stderr.isTTY !== true || process16.argv[1] === undefined)
1981
- return;
1993
+ return { env: { ...NO_PROMPTS }, close: () => {
1994
+ return;
1995
+ } };
1982
1996
  const dir = mkdtempSync(join6(tmpdir(), "kaynooo-askpass-"));
1983
1997
  const socketPath = join6(dir, "socket");
1984
1998
  const script = join6(dir, "askpass");
@@ -2033,7 +2047,7 @@ ${SOCKET_VARIABLE}=${quoted(socketPath)} exec ${quoted(process16.execPath)} --no
2033
2047
  `);
2034
2048
  chmodSync(script, 448);
2035
2049
  return {
2036
- 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" },
2037
2051
  close: () => {
2038
2052
  server.stop(true);
2039
2053
  rmSync(dir, { recursive: true, force: true });
@@ -2456,22 +2470,6 @@ async function watching(value, step, stream = process20.stdout, sleep = Bun.slee
2456
2470
  }
2457
2471
  // ../kit/src/workspace-root.ts
2458
2472
  init_user_config();
2459
- import { homedir as homedir5 } from "os";
2460
- import { dirname as dirname5, join as join9, resolve as resolve4 } from "path";
2461
- import process21 from "process";
2462
- function expandHome(path, home) {
2463
- if (path === "~")
2464
- return home;
2465
- return path.startsWith("~/") ? join9(home, path.slice(2)) : path;
2466
- }
2467
- function configured(env, home) {
2468
- const folder = readUserConfig("config", { home, xdg: env.XDG_CONFIG_HOME }).workspace;
2469
- return typeof folder === "string" && folder !== "" ? folder : undefined;
2470
- }
2471
- function workspaceRoot({ given, env = process21.env, home = homedir5() } = {}) {
2472
- const fromEnv = env.KAYNOOO_WORKSPACE === "" ? undefined : env.KAYNOOO_WORKSPACE;
2473
- return resolve4(expandHome(given ?? fromEnv ?? configured(env, home) ?? join9(home, "Workspace"), home));
2474
- }
2475
2473
  // src/git.ts
2476
2474
  async function git2(args, env) {
2477
2475
  const ran = await runCommand(["git", "--no-optional-locks", "-c", "core.quotePath=false", ...args], env === undefined ? {} : { env });
@@ -2490,7 +2488,7 @@ var OPTIONS = {
2490
2488
  commit: { type: "boolean", short: "c", description: "undo the last commit, keeping its changes staged" },
2491
2489
  json: jsonOption("{action, paths?, saved?, commit?} of what was undone, saved being the patch of a discard")
2492
2490
  };
2493
- var LITERAL = { ...process23.env, GIT_LITERAL_PATHSPECS: "1" };
2491
+ var LITERAL = { ...process22.env, GIT_LITERAL_PATHSPECS: "1" };
2494
2492
  var PLAIN_PATCH = ["--binary", "--no-ext-diff", "--no-textconv", "--no-color", "--no-relative", "--submodule=short", "--src-prefix=a/", "--dst-prefix=b/"];
2495
2493
  var NOT_A_REPOSITORY = /not a git repository/i;
2496
2494
  async function checked(args, standing = "nothing undone") {
@@ -2548,8 +2546,8 @@ async function main(argv) {
2548
2546
  return 0;
2549
2547
  }
2550
2548
  const patch = await checked(["diff", ...PLAIN_PATCH, "--", ...positionals]);
2551
- const folder = join10(resolve5((await checked(["rev-parse", "--git-dir"])).trim()), "gu");
2552
- const saved = join10(folder, `${new Date().toISOString().replaceAll(":", "-")}.patch`);
2549
+ const folder = join9(resolve4((await checked(["rev-parse", "--git-dir"])).trim()), "gu");
2550
+ const saved = join9(folder, `${new Date().toISOString().replaceAll(":", "-")}.patch`);
2553
2551
  const top = (await checked(["rev-parse", "--show-toplevel"])).trim();
2554
2552
  mkdirSync3(folder, { recursive: true });
2555
2553
  writeFileSync3(saved, patch);
@@ -2563,7 +2561,7 @@ ${reverts.stderr.trim()}`, 1);
2563
2561
  if (intended.length > 0) {
2564
2562
  await checked(["-C", top, "rm", "--cached", "--quiet", "--", ...intended], standing);
2565
2563
  for (const path of intended)
2566
- rmSync2(join10(top, path), { force: true });
2564
+ rmSync2(join9(top, path), { force: true });
2567
2565
  }
2568
2566
  if (tracked.length > 0)
2569
2567
  await checked(["-C", top, "restore", "--", ...tracked], standing);
@@ -2573,4 +2571,4 @@ ${reverts.stderr.trim()}`, 1);
2573
2571
  console.log(`discarded ${paths.join(", ")}, saved to ${saved} (git apply puts it back)`);
2574
2572
  return 0;
2575
2573
  }
2576
- process23.exitCode = await runMain({ name: "gu", run: main });
2574
+ process22.exitCode = await runMain({ name: "gu", run: main });
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@kaynooo/cli-git",
3
3
  "type": "module",
4
- "version": "0.18.0",
5
- "description": "gst, gc, gb, gp, gf, gm, 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 branch merged with its conflicts listed, a clone into the workspace, the changes per file and an undo that keeps what it takes away.",
4
+ "version": "0.19.0",
5
+ "description": "gst, gc, gb, gp, gf, gm, 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 branch merged with its conflicts listed, a clone over ssh first, the changes per file and an undo that keeps what it takes away.",
6
6
  "author": "Kaynooo <contact@kaynooo.fr>",
7
7
  "license": "MIT",
8
8
  "homepage": "https://github.com/Kayno0o/cli/tree/main/packages/git#readme",
@@ -56,6 +56,6 @@
56
56
  "gu": "$npm_execpath src/gu.ts"
57
57
  },
58
58
  "devDependencies": {
59
- "@kaynooo/cli-kit": "0.46.1"
59
+ "@kaynooo/cli-kit": "0.46.4"
60
60
  }
61
61
  }