@statewalker/vcs-commands 0.4.0 → 0.5.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/commands/add-command.d.ts.map +1 -1
- package/dist/commands/checkout-command.d.ts +7 -24
- package/dist/commands/checkout-command.d.ts.map +1 -1
- package/dist/commands/clean-command.d.ts +34 -4
- package/dist/commands/clean-command.d.ts.map +1 -1
- package/dist/commands/clone-command.d.ts +62 -7
- package/dist/commands/clone-command.d.ts.map +1 -1
- package/dist/commands/core-config.d.ts +16 -0
- package/dist/commands/core-config.d.ts.map +1 -0
- package/dist/commands/fetch-command.d.ts +96 -14
- package/dist/commands/fetch-command.d.ts.map +1 -1
- package/dist/commands/index.d.ts +1 -0
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +2 -2
- package/dist/commands/init-command.d.ts.map +1 -1
- package/dist/commands/remote-command.d.ts +115 -6
- package/dist/commands/remote-command.d.ts.map +1 -1
- package/dist/commands/reset-command.d.ts.map +1 -1
- package/dist/commands/stash-apply-command.d.ts +35 -13
- package/dist/commands/stash-apply-command.d.ts.map +1 -1
- package/dist/commands/stash-create-command.d.ts +59 -25
- package/dist/commands/stash-create-command.d.ts.map +1 -1
- package/dist/commands/stash-drop-command.d.ts +8 -2
- package/dist/commands/stash-drop-command.d.ts.map +1 -1
- package/dist/commands/stash-list-command.d.ts +2 -4
- package/dist/commands/stash-list-command.d.ts.map +1 -1
- package/dist/commands/stash-working-tree.d.ts +72 -0
- package/dist/commands/stash-working-tree.d.ts.map +1 -0
- package/dist/commands/status-command.d.ts +29 -22
- package/dist/commands/status-command.d.ts.map +1 -1
- package/dist/commands/tree-restore.d.ts +52 -5
- package/dist/commands/tree-restore.d.ts.map +1 -1
- package/dist/commands/worktree-overwrite-checks.d.ts +64 -0
- package/dist/commands/worktree-overwrite-checks.d.ts.map +1 -0
- package/dist/{commands-BpeXZTC3.js → commands-CsLNyvZ1.js} +2940 -631
- package/dist/core-commands/add.command.impl.d.ts.map +1 -1
- package/dist/core-commands/index.d.ts +0 -3
- package/dist/core-commands/index.d.ts.map +1 -1
- package/dist/errors/checkout-errors.d.ts +13 -0
- package/dist/errors/checkout-errors.d.ts.map +1 -1
- package/dist/errors/index.js +18 -1
- package/dist/git-command.d.ts +10 -1
- package/dist/git-command.d.ts.map +1 -1
- package/dist/git.d.ts +21 -3
- package/dist/git.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/remote-config/index.d.ts +1 -0
- package/dist/remote-config/index.d.ts.map +1 -1
- package/dist/remote-config/remote-config-store.d.ts +18 -0
- package/dist/remote-config/remote-config-store.d.ts.map +1 -1
- package/dist/remote-config/remote-refs.d.ts +37 -0
- package/dist/remote-config/remote-refs.d.ts.map +1 -0
- package/dist/results/clone-result.d.ts +6 -0
- package/dist/results/clone-result.d.ts.map +1 -1
- package/dist/results/fetch-result.d.ts +9 -1
- package/dist/results/fetch-result.d.ts.map +1 -1
- package/dist/results/index.js +2 -2
- package/dist/results/status-result.d.ts +91 -20
- package/dist/results/status-result.d.ts.map +1 -1
- package/dist/{status-result-BapZoQaR.js → status-result-BpyUK1Sg.js} +113 -5
- package/dist/transport-command.d.ts +12 -0
- package/dist/transport-command.d.ts.map +1 -1
- package/package.json +11 -10
- package/src/commands/add-command.ts +9 -7
- package/src/commands/checkout-command.ts +200 -118
- package/src/commands/clean-command.ts +187 -88
- package/src/commands/clone-command.ts +244 -40
- package/src/commands/core-config.ts +41 -0
- package/src/commands/fetch-command.ts +476 -57
- package/src/commands/index.ts +1 -0
- package/src/commands/init-command.ts +32 -7
- package/src/commands/remote-command.ts +429 -19
- package/src/commands/reset-command.ts +18 -5
- package/src/commands/stash-apply-command.ts +632 -97
- package/src/commands/stash-create-command.ts +142 -62
- package/src/commands/stash-drop-command.ts +53 -5
- package/src/commands/stash-list-command.ts +10 -4
- package/src/commands/stash-working-tree.ts +243 -0
- package/src/commands/status-command.ts +197 -91
- package/src/commands/tree-restore.ts +142 -13
- package/src/commands/worktree-overwrite-checks.ts +215 -0
- package/src/core-commands/add.command.impl.ts +2 -4
- package/src/core-commands/index.ts +0 -8
- package/src/errors/checkout-errors.ts +20 -0
- package/src/git-command.ts +42 -1
- package/src/git.ts +30 -2
- package/src/remote-config/index.ts +1 -0
- package/src/remote-config/remote-config-store.ts +84 -8
- package/src/remote-config/remote-refs.ts +103 -0
- package/src/results/clone-result.ts +6 -0
- package/src/results/fetch-result.ts +9 -1
- package/src/results/status-result.ts +212 -29
- package/src/transport-command.ts +18 -0
- package/dist/core-commands/checkout.command.d.ts +0 -103
- package/dist/core-commands/checkout.command.d.ts.map +0 -1
- package/dist/core-commands/checkout.command.impl.d.ts +0 -110
- package/dist/core-commands/checkout.command.impl.d.ts.map +0 -1
- package/src/core-commands/checkout.command.impl.ts +0 -564
- package/src/core-commands/checkout.command.ts +0 -125
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Writing a tree back into the working tree.
|
|
3
3
|
*
|
|
4
4
|
* Shared by the commands that make the working tree match a tree object -
|
|
5
|
-
* `reset --hard
|
|
6
|
-
* and validate the whole restore first, then write. A tree that cannot be
|
|
5
|
+
* `reset --hard`, `stash apply` and the checkout of `clone`. All need the
|
|
6
|
+
* same two-phase shape: plan and validate the whole restore first, then write. A tree that cannot be
|
|
7
7
|
* restored faithfully therefore fails with the working tree still intact,
|
|
8
8
|
* rather than half-way through rewriting it.
|
|
9
9
|
*/
|
|
@@ -26,19 +26,57 @@ export interface TreeRestorePlan {
|
|
|
26
26
|
* is one the target tree deletes.
|
|
27
27
|
*/
|
|
28
28
|
paths: Set<string>;
|
|
29
|
+
/** The gitlinks (submodules) of the tree, which are not written. */
|
|
30
|
+
gitlinks: RestoreEntry[];
|
|
31
|
+
/**
|
|
32
|
+
* With `ignoreCase`: files whose paths differ only in case (`README`, `readme`). Both are
|
|
33
|
+
* written, the last one wins, as git checks them out with its "the following paths have
|
|
34
|
+
* collided" warning.
|
|
35
|
+
*/
|
|
36
|
+
collided: string[];
|
|
37
|
+
}
|
|
38
|
+
/** Options of {@link planTreeRestore}. */
|
|
39
|
+
export interface TreeRestoreOptions {
|
|
40
|
+
/**
|
|
41
|
+
* Plan symlinks as entries to write (their blob is the link target), for a
|
|
42
|
+
* worktree that writes mode `0o120000` as a link or as a file holding the
|
|
43
|
+
* target, as git does. Without it a symlink fails the plan.
|
|
44
|
+
*/
|
|
45
|
+
symlinks?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Compare paths case-insensitively (`core.ignorecase`), as a case-folding filesystem
|
|
48
|
+
* would: a path beneath a file, link or submodule of another case (`A` a link, `a/x`)
|
|
49
|
+
* is refused, it would be written through the link; two files differing only in case
|
|
50
|
+
* are both planned (the last wins) and reported in `collided`, as git does.
|
|
51
|
+
*/
|
|
52
|
+
ignoreCase?: boolean;
|
|
53
|
+
/** The worktree is on Windows (`capabilities.windowsPaths`): git's Windows path rules. */
|
|
54
|
+
windows?: boolean;
|
|
55
|
+
/** Top-level names the worktree's storage reserves (`capabilities.reservedNames`) */
|
|
56
|
+
reservedNames?: string[];
|
|
57
|
+
/**
|
|
58
|
+
* Only these paths will be written: the blobs of the others are not checked (every path
|
|
59
|
+
* is still validated). Absent: every blob is checked.
|
|
60
|
+
*/
|
|
61
|
+
writing?: Set<string>;
|
|
29
62
|
}
|
|
30
63
|
/**
|
|
31
64
|
* Walk a tree and plan which files to restore, validating as it goes.
|
|
32
65
|
*
|
|
33
66
|
* Throws on anything that cannot be restored faithfully, so the caller can
|
|
34
|
-
* abort before mutating the working tree
|
|
67
|
+
* abort before mutating the working tree: a path git's `verify_path` refuses
|
|
68
|
+
* (`.git` under any spelling, a symlinked `.gitmodules`), and two entries that
|
|
69
|
+
* collide - the same path twice, a file and a directory of one name, or a path
|
|
70
|
+
* beneath a planned file, symlink or submodule (which would write through the
|
|
71
|
+
* link), compared case-insensitively with `ignoreCase`.
|
|
35
72
|
*
|
|
36
73
|
* @param trees Tree storage to walk
|
|
37
74
|
* @param blobs Blob storage, checked for the content of every planned file
|
|
38
75
|
* @param treeId Tree to restore
|
|
39
76
|
* @param operation Names the operation in failure messages, e.g. `reset --hard`
|
|
77
|
+
* @param options What else the worktree can restore
|
|
40
78
|
*/
|
|
41
|
-
export declare function planTreeRestore(trees: CommandTrees, blobs: Blobs, treeId: ObjectId, operation: string): Promise<TreeRestorePlan>;
|
|
79
|
+
export declare function planTreeRestore(trees: CommandTrees, blobs: Blobs, treeId: ObjectId, operation: string, options?: TreeRestoreOptions): Promise<TreeRestorePlan>;
|
|
42
80
|
/**
|
|
43
81
|
* Execute a plan produced by {@link planTreeRestore}, writing every file.
|
|
44
82
|
*
|
|
@@ -47,5 +85,14 @@ export declare function planTreeRestore(trees: CommandTrees, blobs: Blobs, treeI
|
|
|
47
85
|
* @param plan The validated plan
|
|
48
86
|
* @param operation Names the operation in failure messages
|
|
49
87
|
*/
|
|
50
|
-
export declare function writeTreeRestorePlan(worktree: Worktree, blobs: Blobs, plan: TreeRestorePlan, operation: string): Promise<void>;
|
|
88
|
+
export declare function writeTreeRestorePlan(worktree: Worktree, blobs: Blobs, plan: TreeRestorePlan, operation: string, options?: TreeWriteOptions): Promise<void>;
|
|
89
|
+
/** Options of {@link writeTreeRestorePlan}. */
|
|
90
|
+
export interface TreeWriteOptions {
|
|
91
|
+
/** Write symlinks as links (default); false writes them as files holding the target. */
|
|
92
|
+
symlinks?: boolean;
|
|
93
|
+
/** A forced checkout: unlink a file or link standing where a directory must go. */
|
|
94
|
+
replaceInTheWay?: boolean;
|
|
95
|
+
/** Create an empty directory for each gitlink (submodule). */
|
|
96
|
+
gitlinks?: boolean;
|
|
97
|
+
}
|
|
51
98
|
//# sourceMappingURL=tree-restore.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tree-restore.d.ts","sourceRoot":"","sources":["../../src/commands/tree-restore.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,QAAQ,E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ACnB;;;;;OAKG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,0FAA0F;IAC1F,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,qFAAqF;IACrF,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB;;;OAGG;IACH,OAAO,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CACvB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,eAAe,CACnC,KAAK,EAAE,YAAY,EACnB,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,QAAQ,EAChB,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,kBAAuB,GAC/B,OAAO,CAAC,eAAe,CAAC,CAI1B;AAkGD;;;;;;;GAOG;AACH,wBAAsB,oBAAoB,CACxC,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,eAAe,EACrB,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,gBAAqB,GAC7B,OAAO,CAAC,IAAI,CAAC,CAIf;AA+BD,+CAA+C;AAC/C,MAAM,WAAW,gBAAgB;IAC/B,wFAAwF;IACxF,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,mFAAmF;IACnF,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a checkout or a stash apply must not overwrite, as git's unpack-trees checks it
|
|
3
|
+
* before writing anything: local changes (`verify_uptodate`), untracked files on a path or
|
|
4
|
+
* a leading component (`verify_absent`, `check_leading_path`), and untracked files in a
|
|
5
|
+
* directory a file replaces (`verify_clean_subdirectory`).
|
|
6
|
+
*/
|
|
7
|
+
import { type ObjectId } from "@statewalker/vcs-core";
|
|
8
|
+
import type { Worktree, WorktreeModeTrust } from "@statewalker/vcs-working-tree";
|
|
9
|
+
/** An index or tree entry, with the index's stat where it has one. */
|
|
10
|
+
export interface CheckedEntry {
|
|
11
|
+
objectId: ObjectId;
|
|
12
|
+
mode: number;
|
|
13
|
+
size?: number;
|
|
14
|
+
mtime?: number;
|
|
15
|
+
ctime?: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Whether the worktree file at `path` no longer holds the index entry (git's
|
|
19
|
+
* `verify_uptodate`): changed content, type, or executable bit where the worktree shows it.
|
|
20
|
+
* A missing file is no local change.
|
|
21
|
+
*/
|
|
22
|
+
export declare function worktreeDiffers(worktree: Worktree, path: string, entry: CheckedEntry, trust?: WorktreeModeTrust): Promise<boolean>;
|
|
23
|
+
/** What stands where an operation writes: untracked files, and directories with some. */
|
|
24
|
+
export interface InTheWay {
|
|
25
|
+
/** Untracked files or links on a written path, or on a leading component of one */
|
|
26
|
+
untracked: string[];
|
|
27
|
+
/**
|
|
28
|
+
* Directories a written file replaces that hold untracked files, or tracked files the
|
|
29
|
+
* operation does not remove (never replaced behind the index's back)
|
|
30
|
+
*/
|
|
31
|
+
lostDirs: string[];
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Finds what stands where `writes` (paths not in the index) are written, `removes` being
|
|
35
|
+
* the tracked paths the operation deletes first. Ignored files are expendable, as in git.
|
|
36
|
+
* With `ignoreCase`, a file that is one of `removes` in another case is no obstacle (a
|
|
37
|
+
* case-only rename on a case-folding worktree).
|
|
38
|
+
*/
|
|
39
|
+
export declare function findInTheWay(worktree: Worktree, options: {
|
|
40
|
+
writes: string[];
|
|
41
|
+
removes: Set<string>;
|
|
42
|
+
index: Map<string, unknown>;
|
|
43
|
+
ignoreCase?: boolean;
|
|
44
|
+
}): Promise<InTheWay>;
|
|
45
|
+
/**
|
|
46
|
+
* Removes the directory at `dir` if it holds nothing at all, as git's `rmdir`: never a
|
|
47
|
+
* directory with a file, link, subdirectory, nested repository (`.git`) or FIFO in it, and
|
|
48
|
+
* never recursively. Returns whether it was removed.
|
|
49
|
+
*/
|
|
50
|
+
export declare function removeDirectoryIfEmpty(worktree: Worktree, dir: string): Promise<boolean>;
|
|
51
|
+
/**
|
|
52
|
+
* Removes the directories a removal left empty, bottom-up to the worktree root, as git's
|
|
53
|
+
* `schedule_dir_for_removal`: each only if it is truly empty, stopping at the first that is
|
|
54
|
+
* not (a nested repository, an ignored or untracked file, a FIFO keeps its directory).
|
|
55
|
+
*/
|
|
56
|
+
export declare function pruneEmptyParents(worktree: Worktree, path: string): Promise<void>;
|
|
57
|
+
/** git's refusal messages (unpack-trees), for `checkout` or `merge` (stash apply). */
|
|
58
|
+
export declare function overwriteMessage(action: "checkout" | "merge", found: {
|
|
59
|
+
local?: string[];
|
|
60
|
+
lostDirs?: string[];
|
|
61
|
+
untracked?: string[];
|
|
62
|
+
untrackedRemoved?: string[];
|
|
63
|
+
}): string | undefined;
|
|
64
|
+
//# sourceMappingURL=worktree-overwrite-checks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worktree-overwrite-checks.d.ts","sourceRoot":"","sources":["../../src/commands/worktree-overwrite-checks.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAY,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,KAAK,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAEjF,sEAAsE;AACtE,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,QAAQ,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;GAIG;AACH,wBAAsB,eAAe,CACnC,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,YAAY,EACnB,KAAK,CAAC,EAAE,iBAAiB,GACxB,OAAO,CAAC,OAAO,CAAC,CA2BlB;AAED,yFA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