@staff0rd/assist 0.904.1 → 0.905.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/index.js CHANGED
@@ -6,7 +6,7 @@ import { Command } from "commander";
6
6
  // package.json
7
7
  var package_default = {
8
8
  name: "@staff0rd/assist",
9
- version: "0.904.1",
9
+ version: "0.905.0",
10
10
  type: "module",
11
11
  main: "dist/index.js",
12
12
  bin: {
@@ -4633,7 +4633,8 @@ import { promisify as promisify3 } from "util";
4633
4633
  var execFileAsync3 = promisify3(execFile3);
4634
4634
  async function execGit(cwd, args, opts = {}) {
4635
4635
  const { maxBuffer, allowFailure } = opts;
4636
- const { file, argv } = /^[A-Za-z]:[\\/]/.test(cwd) ? { file: "git.exe", argv: ["-C", cwd, ...args] } : { file: "git", argv: args };
4636
+ const unquoted = ["-c", "core.quotePath=false", ...args];
4637
+ const { file, argv } = /^[A-Za-z]:[\\/]/.test(cwd) ? { file: "git.exe", argv: ["-C", cwd, ...unquoted] } : { file: "git", argv: unquoted };
4637
4638
  try {
4638
4639
  const { stdout } = await execFileAsync3(file, argv, {
4639
4640
  encoding: "utf8",
@@ -9663,28 +9664,64 @@ async function performRestart(target, deps2 = {}) {
9663
9664
  import { relative as relative4 } from "path";
9664
9665
 
9665
9666
  // src/commands/sessions/web/revertPathChanges.ts
9667
+ function git(cwd, args) {
9668
+ return execGit(cwd, ["--literal-pathspecs", ...args]);
9669
+ }
9666
9670
  async function isTracked(cwd, path109) {
9667
9671
  try {
9668
- await execGit(cwd, ["ls-files", "--error-unmatch", "--", path109]);
9672
+ await git(cwd, ["ls-files", "--error-unmatch", "--", path109]);
9669
9673
  return true;
9670
9674
  } catch {
9671
9675
  return false;
9672
9676
  }
9673
9677
  }
9674
9678
  async function isInHead(cwd, path109) {
9675
- const listing = await execGit(cwd, ["ls-tree", "HEAD", "--", path109]);
9679
+ const listing = await git(cwd, ["ls-tree", "HEAD", "--", path109]);
9676
9680
  return listing.trim().length > 0;
9677
9681
  }
9678
- async function revertPathChanges(cwd, path109) {
9679
- if (!await isTracked(cwd, path109)) {
9680
- await execGit(cwd, ["clean", "-f", "--", path109]);
9681
- return;
9682
+ async function hasChanges(cwd, path109) {
9683
+ const status2 = await git(cwd, [
9684
+ "status",
9685
+ "--porcelain",
9686
+ "-z",
9687
+ "--untracked-files=all",
9688
+ "--",
9689
+ path109
9690
+ ]);
9691
+ return status2.length > 0;
9692
+ }
9693
+ async function renameSources(cwd, path109) {
9694
+ const fields = (await git(cwd, ["diff", "HEAD", "--name-status", "-z"])).split("\0");
9695
+ const sources = [];
9696
+ for (let i = 0; i < fields.length; ) {
9697
+ const status2 = fields[i];
9698
+ if (status2.startsWith("R")) {
9699
+ if (fields[i + 2] === path109) sources.push(fields[i + 1]);
9700
+ i += 3;
9701
+ } else {
9702
+ i += status2.startsWith("C") ? 3 : 2;
9703
+ }
9682
9704
  }
9705
+ return sources;
9706
+ }
9707
+ async function restorePath(cwd, path109) {
9683
9708
  if (await isInHead(cwd, path109)) {
9684
- await execGit(cwd, ["checkout", "HEAD", "--", path109]);
9709
+ await git(cwd, ["checkout", "HEAD", "--", path109]);
9685
9710
  return;
9686
9711
  }
9687
- await execGit(cwd, ["rm", "-f", "--", path109]);
9712
+ if (await isTracked(cwd, path109)) {
9713
+ await git(cwd, ["rm", "-f", "--", path109]);
9714
+ return;
9715
+ }
9716
+ await git(cwd, ["clean", "-f", "--", path109]);
9717
+ }
9718
+ async function revertPathChanges(cwd, path109) {
9719
+ if (!await hasChanges(cwd, path109))
9720
+ throw new Error(`No uncommitted changes found for ${path109}`);
9721
+ for (const target of [...await renameSources(cwd, path109), path109])
9722
+ await restorePath(cwd, target);
9723
+ if (await hasChanges(cwd, path109))
9724
+ throw new Error(`${path109} still has uncommitted changes`);
9688
9725
  }
9689
9726
 
9690
9727
  // src/commands/sessions/web/revertDiffFile.ts
@@ -11750,7 +11787,7 @@ function gitInvocation(cwd, args) {
11750
11787
  }
11751
11788
  };
11752
11789
  }
11753
- function git(cwd, args) {
11790
+ function git2(cwd, args) {
11754
11791
  const { file, argv, options: options2 } = gitInvocation(cwd, args);
11755
11792
  return new Promise((resolve31, reject) => {
11756
11793
  execFile10(file, argv, options2, (error, stdout) => {
@@ -11761,14 +11798,14 @@ function git(cwd, args) {
11761
11798
  }
11762
11799
  async function gitOrNull(cwd, args) {
11763
11800
  try {
11764
- return (await git(cwd, args)).trim() || null;
11801
+ return (await git2(cwd, args)).trim() || null;
11765
11802
  } catch {
11766
11803
  return null;
11767
11804
  }
11768
11805
  }
11769
11806
  async function gitResult(cwd, args) {
11770
11807
  try {
11771
- return { ok: true, out: (await git(cwd, args)).trim() };
11808
+ return { ok: true, out: (await git2(cwd, args)).trim() };
11772
11809
  } catch (error) {
11773
11810
  return {
11774
11811
  ok: false,
@@ -21496,7 +21533,7 @@ function collectCommitRefs(message3) {
21496
21533
 
21497
21534
  // src/commands/commit/pullKeepingIndex.ts
21498
21535
  import { execSync as execSync26 } from "child_process";
21499
- function git2(args, input) {
21536
+ function git3(args, input) {
21500
21537
  return execSync26(`git --literal-pathspecs ${args}`, {
21501
21538
  encoding: "utf8",
21502
21539
  input,
@@ -21506,16 +21543,16 @@ function git2(args, input) {
21506
21543
  }
21507
21544
  function restoreIndex(paths, patch2) {
21508
21545
  const pathspec = paths.join("\0");
21509
- git2("reset -q --pathspec-from-file=- --pathspec-file-nul", pathspec);
21546
+ git3("reset -q --pathspec-from-file=- --pathspec-file-nul", pathspec);
21510
21547
  try {
21511
- git2("apply --cached --binary", patch2);
21548
+ git3("apply --cached --binary", patch2);
21512
21549
  } catch {
21513
- git2("add -A --pathspec-from-file=- --pathspec-file-nul", pathspec);
21550
+ git3("add -A --pathspec-from-file=- --pathspec-file-nul", pathspec);
21514
21551
  }
21515
21552
  }
21516
21553
  function pullKeepingIndex() {
21517
- const paths = git2("diff --cached --name-only -z --no-renames").split("\0").filter(Boolean);
21518
- const patch2 = git2("diff-index --cached -p --binary --no-renames HEAD");
21554
+ const paths = git3("diff --cached --name-only -z --no-renames").split("\0").filter(Boolean);
21555
+ const patch2 = git3("diff-index --cached -p --binary --no-renames HEAD");
21519
21556
  execSync26("git pull --autostash", { stdio: "inherit" });
21520
21557
  if (paths.length === 0 || findUnmergedPaths().length > 0) return;
21521
21558
  restoreIndex(paths, patch2);
@@ -22192,7 +22229,7 @@ function formatResultLine(entry, failing) {
22192
22229
  // src/commands/complexity/maintainability/getMaintainabilityGitState.ts
22193
22230
  import { execSync as execSync30 } from "child_process";
22194
22231
  import path34 from "path";
22195
- function git3(command) {
22232
+ function git4(command) {
22196
22233
  return execSync30(command, { encoding: "utf8" });
22197
22234
  }
22198
22235
  function toAbsolute(root2, repoRelative) {
@@ -22200,7 +22237,7 @@ function toAbsolute(root2, repoRelative) {
22200
22237
  }
22201
22238
  function collectShrunkFiles(root2) {
22202
22239
  const shrunk = /* @__PURE__ */ new Set();
22203
- const numstat = git3("git diff --numstat HEAD").trim();
22240
+ const numstat = git4("git diff --numstat HEAD").trim();
22204
22241
  if (numstat === "") return shrunk;
22205
22242
  for (const line of numstat.split("\n")) {
22206
22243
  const [addedRaw, removedRaw, ...rest] = line.split(" ");
@@ -22213,7 +22250,7 @@ function collectShrunkFiles(root2) {
22213
22250
  return shrunk;
22214
22251
  }
22215
22252
  function hasNewSourceFile() {
22216
- const status2 = git3("git status --porcelain --untracked-files=all").trim();
22253
+ const status2 = git4("git status --porcelain --untracked-files=all").trim();
22217
22254
  if (status2 === "") return false;
22218
22255
  for (const line of status2.split("\n")) {
22219
22256
  const code = line.slice(0, 2);
@@ -22225,7 +22262,7 @@ function hasNewSourceFile() {
22225
22262
  }
22226
22263
  function getMaintainabilityGitState() {
22227
22264
  try {
22228
- const root2 = git3("git rev-parse --show-toplevel").trim();
22265
+ const root2 = git4("git rev-parse --show-toplevel").trim();
22229
22266
  return {
22230
22267
  shrunkFiles: collectShrunkFiles(root2),
22231
22268
  newFileCreated: hasNewSourceFile()
@@ -45834,7 +45871,7 @@ function holdsAGitDirectoryRatherThanALink(worktreePath) {
45834
45871
  }
45835
45872
  async function pruneBookkeeping(clone, worktreePath) {
45836
45873
  try {
45837
- await git(clone, ["worktree", "prune"]);
45874
+ await git2(clone, ["worktree", "prune"]);
45838
45875
  daemonLog(
45839
45876
  `worktree bookkeeping pruned in clone ${clone} after deleting ${worktreePath} directly`
45840
45877
  );
@@ -45876,7 +45913,7 @@ function reason2(error) {
45876
45913
 
45877
45914
  // src/commands/sessions/daemon/worktree/removeTree.ts
45878
45915
  async function removeTree(clone, worktreePath, force) {
45879
- const remove2 = (forced) => git(clone, [
45916
+ const remove2 = (forced) => git2(clone, [
45880
45917
  "worktree",
45881
45918
  "remove",
45882
45919
  ...forced ? ["--force"] : [],
@@ -45954,7 +45991,7 @@ async function deleteWorktreeBranch(clone, branch2) {
45954
45991
  const current = await gitOrNull(clone, ["symbolic-ref", "--short", "HEAD"]);
45955
45992
  if (branch2 === current) return;
45956
45993
  try {
45957
- await git(clone, ["branch", "-D", branch2]);
45994
+ await git2(clone, ["branch", "-D", branch2]);
45958
45995
  daemonLog(`worktree branch ${branch2} deleted from clone ${clone}`);
45959
45996
  } catch (error) {
45960
45997
  daemonLog(
@@ -49005,7 +49042,7 @@ async function reclaimVanishedWorktrees(clone, paths) {
49005
49042
  }
49006
49043
  async function pruneBookkeeping2(clone) {
49007
49044
  try {
49008
- await git(clone, ["worktree", "prune"]);
49045
+ await git2(clone, ["worktree", "prune"]);
49009
49046
  daemonLog(`worktree bookkeeping pruned for clone ${clone}`);
49010
49047
  } catch (error) {
49011
49048
  daemonLog(
@@ -49016,7 +49053,7 @@ async function pruneBookkeeping2(clone) {
49016
49053
  async function reclaimBranch(clone, branch2) {
49017
49054
  if (!listLocalBranches(clone).includes(branch2)) return true;
49018
49055
  try {
49019
- await git(clone, ["branch", "-d", branch2]);
49056
+ await git2(clone, ["branch", "-d", branch2]);
49020
49057
  daemonLog(`stale worktree branch ${branch2} pruned from clone ${clone}`);
49021
49058
  return true;
49022
49059
  } catch {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@staff0rd/assist",
3
- "version": "0.904.1",
3
+ "version": "0.905.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "bin": {