@ogpoyraz/wtx 0.8.4 → 0.8.5

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.
Files changed (2) hide show
  1. package/dist/cli.mjs +25 -2
  2. package/package.json +1 -1
package/dist/cli.mjs CHANGED
@@ -31096,7 +31096,7 @@ function isMissingWorktreePathError(message) {
31096
31096
  return message.includes("ENOENT") || message.includes("No such file") || message.includes("does not exist") || message.includes("not a git repository") || message.includes("cannot change to");
31097
31097
  }
31098
31098
  function isRecoverableWorktreeRemoveError(message) {
31099
- return message.includes("not a working tree") || message.includes("already removed") || isMissingWorktreePathError(message);
31099
+ return message.includes("not a working tree") || message.includes("already removed") || message.includes("submodule") || message.includes("containing submodules") || isMissingWorktreePathError(message);
31100
31100
  }
31101
31101
  function removeExistingPath(wtPath, opts) {
31102
31102
  if (!opts.dryRun && fs23.existsSync(wtPath)) {
@@ -31253,7 +31253,30 @@ function registerRemoveCommand(program2) {
31253
31253
  stepSuccess("Worktree removed", wtPath);
31254
31254
  } catch (err) {
31255
31255
  const msg = errorMessage(err);
31256
- if (isRecoverableWorktreeRemoveError(msg)) {
31256
+ const isSubmodule = msg.includes("submodule") || msg.includes("containing submodules");
31257
+ if (isSubmodule && !options.force && !args.includes("--force")) {
31258
+ stepWarning("Worktree contains submodules — retrying with --force", msg.split(`
31259
+ `)[0] ?? msg);
31260
+ try {
31261
+ await gitExec(["-C", repo.mainPath, "worktree", "remove", "--force", wtPath], globalOpts);
31262
+ stepSuccess("Worktree removed", wtPath);
31263
+ } catch (forceErr) {
31264
+ const forceMsg = errorMessage(forceErr);
31265
+ if (isRecoverableWorktreeRemoveError(forceMsg)) {
31266
+ stepWarning("Worktree already removed or invalid", forceMsg);
31267
+ try {
31268
+ await gitExec(["-C", repo.mainPath, "worktree", "prune"], globalOpts);
31269
+ } catch (pruneErr) {
31270
+ stepWarning("Worktree prune failed", errorMessage(pruneErr));
31271
+ }
31272
+ removeExistingPath(wtPath, globalOpts);
31273
+ await removeLocalBranchBestEffort(repo.mainPath, branch, globalOpts);
31274
+ stepSuccess("Worktree removed", wtPath);
31275
+ } else {
31276
+ throw forceErr;
31277
+ }
31278
+ }
31279
+ } else if (isRecoverableWorktreeRemoveError(msg)) {
31257
31280
  stepWarning("Worktree already removed or invalid", msg);
31258
31281
  try {
31259
31282
  await gitExec(["-C", repo.mainPath, "worktree", "prune"], globalOpts);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ogpoyraz/wtx",
3
- "version": "0.8.4",
3
+ "version": "0.8.5",
4
4
  "description": "Multi-repo git worktree manager",
5
5
  "type": "module",
6
6
  "bin": {