@solaqua/gji 0.7.2 → 0.8.1
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/clean.js +34 -19
- package/dist/gji-bundle.mjs +846 -266
- package/dist/remove.js +2 -2
- package/dist/worktree-management.d.ts +2 -1
- package/dist/worktree-management.js +23 -7
- package/dist/worktree-picker.d.ts +14 -2
- package/dist/worktree-picker.js +723 -27
- package/man/man1/gji-back.1 +1 -1
- package/man/man1/gji-clean.1 +1 -1
- package/man/man1/gji-completion.1 +1 -1
- package/man/man1/gji-config.1 +1 -1
- package/man/man1/gji-go.1 +1 -1
- package/man/man1/gji-history.1 +1 -1
- package/man/man1/gji-init.1 +1 -1
- package/man/man1/gji-ls.1 +1 -1
- package/man/man1/gji-new.1 +1 -1
- package/man/man1/gji-open.1 +1 -1
- package/man/man1/gji-pr.1 +1 -1
- package/man/man1/gji-remove.1 +1 -1
- package/man/man1/gji-root.1 +1 -1
- package/man/man1/gji-run-hook.1 +1 -1
- package/man/man1/gji-status.1 +1 -1
- package/man/man1/gji-sync-files.1 +1 -1
- package/man/man1/gji-sync.1 +1 -1
- package/man/man1/gji-warp.1 +1 -1
- package/man/man1/gji.1 +1 -1
- package/package.json +1 -1
package/dist/clean.js
CHANGED
|
@@ -3,7 +3,7 @@ import { loadEffectiveConfig } from "./config.js";
|
|
|
3
3
|
import { isBranchMergedInto, readWorktreeHealth, resolveRemoteDefaultBranch, runGit, } from "./git.js";
|
|
4
4
|
import { isHeadless } from "./headless.js";
|
|
5
5
|
import { formatLastCommit, formatUpstreamState, readWorktreeInfos, serializeWorktreeInfo, } from "./worktree-info.js";
|
|
6
|
-
import { deleteBranch, forceDeleteBranch, forceRemoveWorktree, isBranchUnmergedError,
|
|
6
|
+
import { deleteBranch, forceDeleteBranch, forceRemoveWorktree, isBranchUnmergedError, isWorktreeDeletionError, isWorktreeForceRemovalError, loadLinkedWorktrees, removeWorktree, } from "./worktree-management.js";
|
|
7
7
|
import { buildWorktreePromptEntries, promptForMultipleWorktrees, } from "./worktree-picker.js";
|
|
8
8
|
import { defaultConfirmForceDeleteBranch, defaultConfirmForceRemoveWorktree, } from "./worktree-prompts.js";
|
|
9
9
|
export function createCleanCommand(dependencies = {}) {
|
|
@@ -77,8 +77,8 @@ export function createCleanCommand(dependencies = {}) {
|
|
|
77
77
|
}
|
|
78
78
|
return 0;
|
|
79
79
|
}
|
|
80
|
-
const removedPaths = [];
|
|
81
80
|
const removedWorktrees = [];
|
|
81
|
+
const failures = [];
|
|
82
82
|
for (const worktree of selectedWorktrees) {
|
|
83
83
|
if (options.stale &&
|
|
84
84
|
!(await isStaleCleanupCandidate(repository.repoRoot, worktree, staleBaseRef))) {
|
|
@@ -89,31 +89,39 @@ export function createCleanCommand(dependencies = {}) {
|
|
|
89
89
|
await removeWorktree(repository.repoRoot, worktree.path);
|
|
90
90
|
}
|
|
91
91
|
catch (error) {
|
|
92
|
-
if (!
|
|
93
|
-
|
|
92
|
+
if (!isWorktreeForceRemovalError(error)) {
|
|
93
|
+
failures.push({
|
|
94
|
+
branch: worktree.branch,
|
|
95
|
+
message: toMessage(error),
|
|
96
|
+
path: worktree.path,
|
|
97
|
+
});
|
|
98
|
+
continue;
|
|
94
99
|
}
|
|
95
|
-
if (options.stale) {
|
|
100
|
+
if (options.stale && !isWorktreeDeletionError(error)) {
|
|
96
101
|
options.stderr(`Skipped ${worktree.path}: no longer a safe stale cleanup candidate\n`);
|
|
97
102
|
continue;
|
|
98
103
|
}
|
|
99
104
|
if (!options.force &&
|
|
100
105
|
!(await confirmForceRemoveWorktree(worktree.path))) {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
106
|
+
failures.push({
|
|
107
|
+
branch: worktree.branch,
|
|
108
|
+
message: "force removal declined",
|
|
109
|
+
path: worktree.path,
|
|
110
|
+
});
|
|
111
|
+
continue;
|
|
104
112
|
}
|
|
105
113
|
try {
|
|
106
114
|
await forceRemoveWorktree(repository.repoRoot, worktree.path);
|
|
107
115
|
}
|
|
108
116
|
catch (forceError) {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
117
|
+
failures.push({
|
|
118
|
+
branch: worktree.branch,
|
|
119
|
+
message: toMessage(forceError),
|
|
120
|
+
path: worktree.path,
|
|
121
|
+
});
|
|
122
|
+
continue;
|
|
114
123
|
}
|
|
115
124
|
}
|
|
116
|
-
removedPaths.push(worktree.path);
|
|
117
125
|
removedWorktrees.push(worktree);
|
|
118
126
|
if (worktree.branch) {
|
|
119
127
|
try {
|
|
@@ -145,12 +153,16 @@ export function createCleanCommand(dependencies = {}) {
|
|
|
145
153
|
? { branch: worktree.branch, path: worktree.path }
|
|
146
154
|
: serializeWorktreeInfo(info);
|
|
147
155
|
});
|
|
148
|
-
|
|
156
|
+
const payload = failures.length === 0 ? { removed } : { removed, failed: failures };
|
|
157
|
+
options.stdout(`${JSON.stringify(payload, null, 2)}\n`);
|
|
158
|
+
}
|
|
159
|
+
else if (failures.length > 0) {
|
|
160
|
+
reportCleanFailures(failures, options.stderr);
|
|
149
161
|
}
|
|
150
162
|
else {
|
|
151
163
|
options.stdout(`${repository.repoRoot}\n`);
|
|
152
164
|
}
|
|
153
|
-
return 0;
|
|
165
|
+
return failures.length === 0 ? 0 : 1;
|
|
154
166
|
};
|
|
155
167
|
}
|
|
156
168
|
export const runCleanCommand = createCleanCommand();
|
|
@@ -216,9 +228,12 @@ function resolveSelectedWorktrees(worktrees, selections) {
|
|
|
216
228
|
}
|
|
217
229
|
return selectedWorktrees;
|
|
218
230
|
}
|
|
219
|
-
function
|
|
220
|
-
|
|
221
|
-
|
|
231
|
+
function reportCleanFailures(failures, stderr) {
|
|
232
|
+
const noun = failures.length === 1 ? "worktree" : "worktrees";
|
|
233
|
+
stderr(`Failed to clean ${failures.length} ${noun}:\n`);
|
|
234
|
+
for (const failure of failures) {
|
|
235
|
+
const branch = failure.branch === null ? "detached" : failure.branch;
|
|
236
|
+
stderr(`- ${failure.path} (${branch}): ${failure.message}\n`);
|
|
222
237
|
}
|
|
223
238
|
}
|
|
224
239
|
function formatCleanInfo(info) {
|