@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/remove.js
CHANGED
|
@@ -4,7 +4,7 @@ import { loadEffectiveConfig } from "./config.js";
|
|
|
4
4
|
import { isHeadless } from "./headless.js";
|
|
5
5
|
import { extractHooks, runHook } from "./hooks.js";
|
|
6
6
|
import { writeShellOutput } from "./shell-handoff.js";
|
|
7
|
-
import { deleteBranch, forceDeleteBranch, forceRemoveWorktree, isBranchUnmergedError,
|
|
7
|
+
import { deleteBranch, forceDeleteBranch, forceRemoveWorktree, isBranchUnmergedError, isWorktreeForceRemovalError, loadLinkedWorktrees, removeWorktree, } from "./worktree-management.js";
|
|
8
8
|
import { buildWorktreePromptEntries, promptForSingleWorktree, } from "./worktree-picker.js";
|
|
9
9
|
import { defaultConfirmForceDeleteBranch, defaultConfirmForceRemoveWorktree, } from "./worktree-prompts.js";
|
|
10
10
|
const REMOVE_OUTPUT_FILE_ENV = "GJI_REMOVE_OUTPUT_FILE";
|
|
@@ -83,7 +83,7 @@ export function createRemoveCommand(dependencies = {}) {
|
|
|
83
83
|
await removeWorktree(repository.repoRoot, worktree.path);
|
|
84
84
|
}
|
|
85
85
|
catch (error) {
|
|
86
|
-
if (!
|
|
86
|
+
if (!isWorktreeForceRemovalError(error)) {
|
|
87
87
|
throw error;
|
|
88
88
|
}
|
|
89
89
|
if (!options.force &&
|
|
@@ -8,5 +8,6 @@ export declare function removeWorktree(repoRoot: string, worktreePath: string):
|
|
|
8
8
|
export declare function forceRemoveWorktree(repoRoot: string, worktreePath: string): Promise<void>;
|
|
9
9
|
export declare function deleteBranch(repoRoot: string, branch: string): Promise<void>;
|
|
10
10
|
export declare function forceDeleteBranch(repoRoot: string, branch: string): Promise<void>;
|
|
11
|
-
export declare function
|
|
11
|
+
export declare function isWorktreeForceRemovalError(error: unknown): boolean;
|
|
12
|
+
export declare function isWorktreeDeletionError(error: unknown): boolean;
|
|
12
13
|
export declare function isBranchUnmergedError(error: unknown): boolean;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { execFile } from "node:child_process";
|
|
2
|
+
import { rm } from "node:fs/promises";
|
|
2
3
|
import { promisify } from "node:util";
|
|
3
4
|
import { detectRepository, listWorktrees, } from "./repo.js";
|
|
4
5
|
const execFileAsync = promisify(execFile);
|
|
@@ -19,10 +20,19 @@ export async function removeWorktree(repoRoot, worktreePath) {
|
|
|
19
20
|
});
|
|
20
21
|
}
|
|
21
22
|
export async function forceRemoveWorktree(repoRoot, worktreePath) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
try {
|
|
24
|
+
await execFileAsync("git", ["worktree", "remove", "--force", worktreePath], {
|
|
25
|
+
cwd: repoRoot,
|
|
26
|
+
env: GIT_ENV,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
const worktreeIsStillRegistered = (await listWorktrees(repoRoot)).some((worktree) => worktree.path === worktreePath);
|
|
31
|
+
if (worktreeIsStillRegistered) {
|
|
32
|
+
throw error;
|
|
33
|
+
}
|
|
34
|
+
await rm(worktreePath, { force: true, recursive: true });
|
|
35
|
+
}
|
|
26
36
|
}
|
|
27
37
|
export async function deleteBranch(repoRoot, branch) {
|
|
28
38
|
await execFileAsync("git", ["branch", "-d", branch], {
|
|
@@ -36,9 +46,15 @@ export async function forceDeleteBranch(repoRoot, branch) {
|
|
|
36
46
|
env: GIT_ENV,
|
|
37
47
|
});
|
|
38
48
|
}
|
|
39
|
-
export function
|
|
40
|
-
|
|
41
|
-
|
|
49
|
+
export function isWorktreeForceRemovalError(error) {
|
|
50
|
+
if (!hasStderr(error)) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
return (error.stderr.includes("contains modified or untracked files") ||
|
|
54
|
+
isWorktreeDeletionError(error));
|
|
55
|
+
}
|
|
56
|
+
export function isWorktreeDeletionError(error) {
|
|
57
|
+
return hasStderr(error) && error.stderr.includes("failed to delete");
|
|
42
58
|
}
|
|
43
59
|
export function isBranchUnmergedError(error) {
|
|
44
60
|
return hasStderr(error) && error.stderr.includes("is not fully merged");
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Readable, Writable } from "node:stream";
|
|
1
2
|
import type { WorktreeEntry } from "./repo.js";
|
|
2
3
|
export interface WorktreePromptSource {
|
|
3
4
|
repoName: string;
|
|
@@ -6,9 +7,20 @@ export interface WorktreePromptSource {
|
|
|
6
7
|
export interface WorktreePromptEntry extends WorktreeEntry {
|
|
7
8
|
group: "recent" | "other";
|
|
8
9
|
label: string;
|
|
10
|
+
metadata?: string | null;
|
|
9
11
|
repoName: string;
|
|
10
12
|
}
|
|
13
|
+
export interface WorktreePickerIO {
|
|
14
|
+
input?: Readable & {
|
|
15
|
+
isTTY?: boolean;
|
|
16
|
+
setRawMode?: (mode: boolean) => void;
|
|
17
|
+
};
|
|
18
|
+
output?: Writable & {
|
|
19
|
+
columns?: number;
|
|
20
|
+
rows?: number;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
11
23
|
export declare function buildWorktreePromptEntries(sources: WorktreePromptSource[]): Promise<WorktreePromptEntry[]>;
|
|
12
24
|
export declare function resolveWorktreeQuery(sources: WorktreePromptSource[], query: string): WorktreePromptSource | null;
|
|
13
|
-
export declare function promptForSingleWorktree(message: string, worktrees: WorktreePromptEntry[]): Promise<string | null>;
|
|
14
|
-
export declare function promptForMultipleWorktrees(message: string, worktrees: WorktreePromptEntry[]): Promise<string[] | null>;
|
|
25
|
+
export declare function promptForSingleWorktree(message: string, worktrees: WorktreePromptEntry[], io?: WorktreePickerIO): Promise<string | null>;
|
|
26
|
+
export declare function promptForMultipleWorktrees(message: string, worktrees: WorktreePromptEntry[], io?: WorktreePickerIO): Promise<string[] | null>;
|