@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.
Files changed (99) hide show
  1. package/dist/commands/add-command.d.ts.map +1 -1
  2. package/dist/commands/checkout-command.d.ts +7 -24
  3. package/dist/commands/checkout-command.d.ts.map +1 -1
  4. package/dist/commands/clean-command.d.ts +34 -4
  5. package/dist/commands/clean-command.d.ts.map +1 -1
  6. package/dist/commands/clone-command.d.ts +62 -7
  7. package/dist/commands/clone-command.d.ts.map +1 -1
  8. package/dist/commands/core-config.d.ts +16 -0
  9. package/dist/commands/core-config.d.ts.map +1 -0
  10. package/dist/commands/fetch-command.d.ts +96 -14
  11. package/dist/commands/fetch-command.d.ts.map +1 -1
  12. package/dist/commands/index.d.ts +1 -0
  13. package/dist/commands/index.d.ts.map +1 -1
  14. package/dist/commands/index.js +2 -2
  15. package/dist/commands/init-command.d.ts.map +1 -1
  16. package/dist/commands/remote-command.d.ts +115 -6
  17. package/dist/commands/remote-command.d.ts.map +1 -1
  18. package/dist/commands/reset-command.d.ts.map +1 -1
  19. package/dist/commands/stash-apply-command.d.ts +35 -13
  20. package/dist/commands/stash-apply-command.d.ts.map +1 -1
  21. package/dist/commands/stash-create-command.d.ts +59 -25
  22. package/dist/commands/stash-create-command.d.ts.map +1 -1
  23. package/dist/commands/stash-drop-command.d.ts +8 -2
  24. package/dist/commands/stash-drop-command.d.ts.map +1 -1
  25. package/dist/commands/stash-list-command.d.ts +2 -4
  26. package/dist/commands/stash-list-command.d.ts.map +1 -1
  27. package/dist/commands/stash-working-tree.d.ts +72 -0
  28. package/dist/commands/stash-working-tree.d.ts.map +1 -0
  29. package/dist/commands/status-command.d.ts +29 -22
  30. package/dist/commands/status-command.d.ts.map +1 -1
  31. package/dist/commands/tree-restore.d.ts +52 -5
  32. package/dist/commands/tree-restore.d.ts.map +1 -1
  33. package/dist/commands/worktree-overwrite-checks.d.ts +64 -0
  34. package/dist/commands/worktree-overwrite-checks.d.ts.map +1 -0
  35. package/dist/{commands-BpeXZTC3.js → commands-CsLNyvZ1.js} +2940 -631
  36. package/dist/core-commands/add.command.impl.d.ts.map +1 -1
  37. package/dist/core-commands/index.d.ts +0 -3
  38. package/dist/core-commands/index.d.ts.map +1 -1
  39. package/dist/errors/checkout-errors.d.ts +13 -0
  40. package/dist/errors/checkout-errors.d.ts.map +1 -1
  41. package/dist/errors/index.js +18 -1
  42. package/dist/git-command.d.ts +10 -1
  43. package/dist/git-command.d.ts.map +1 -1
  44. package/dist/git.d.ts +21 -3
  45. package/dist/git.d.ts.map +1 -1
  46. package/dist/index.js +4 -4
  47. package/dist/remote-config/index.d.ts +1 -0
  48. package/dist/remote-config/index.d.ts.map +1 -1
  49. package/dist/remote-config/remote-config-store.d.ts +18 -0
  50. package/dist/remote-config/remote-config-store.d.ts.map +1 -1
  51. package/dist/remote-config/remote-refs.d.ts +37 -0
  52. package/dist/remote-config/remote-refs.d.ts.map +1 -0
  53. package/dist/results/clone-result.d.ts +6 -0
  54. package/dist/results/clone-result.d.ts.map +1 -1
  55. package/dist/results/fetch-result.d.ts +9 -1
  56. package/dist/results/fetch-result.d.ts.map +1 -1
  57. package/dist/results/index.js +2 -2
  58. package/dist/results/status-result.d.ts +91 -20
  59. package/dist/results/status-result.d.ts.map +1 -1
  60. package/dist/{status-result-BapZoQaR.js → status-result-BpyUK1Sg.js} +113 -5
  61. package/dist/transport-command.d.ts +12 -0
  62. package/dist/transport-command.d.ts.map +1 -1
  63. package/package.json +11 -10
  64. package/src/commands/add-command.ts +9 -7
  65. package/src/commands/checkout-command.ts +200 -118
  66. package/src/commands/clean-command.ts +187 -88
  67. package/src/commands/clone-command.ts +244 -40
  68. package/src/commands/core-config.ts +41 -0
  69. package/src/commands/fetch-command.ts +476 -57
  70. package/src/commands/index.ts +1 -0
  71. package/src/commands/init-command.ts +32 -7
  72. package/src/commands/remote-command.ts +429 -19
  73. package/src/commands/reset-command.ts +18 -5
  74. package/src/commands/stash-apply-command.ts +632 -97
  75. package/src/commands/stash-create-command.ts +142 -62
  76. package/src/commands/stash-drop-command.ts +53 -5
  77. package/src/commands/stash-list-command.ts +10 -4
  78. package/src/commands/stash-working-tree.ts +243 -0
  79. package/src/commands/status-command.ts +197 -91
  80. package/src/commands/tree-restore.ts +142 -13
  81. package/src/commands/worktree-overwrite-checks.ts +215 -0
  82. package/src/core-commands/add.command.impl.ts +2 -4
  83. package/src/core-commands/index.ts +0 -8
  84. package/src/errors/checkout-errors.ts +20 -0
  85. package/src/git-command.ts +42 -1
  86. package/src/git.ts +30 -2
  87. package/src/remote-config/index.ts +1 -0
  88. package/src/remote-config/remote-config-store.ts +84 -8
  89. package/src/remote-config/remote-refs.ts +103 -0
  90. package/src/results/clone-result.ts +6 -0
  91. package/src/results/fetch-result.ts +9 -1
  92. package/src/results/status-result.ts +212 -29
  93. package/src/transport-command.ts +18 -0
  94. package/dist/core-commands/checkout.command.d.ts +0 -103
  95. package/dist/core-commands/checkout.command.d.ts.map +0 -1
  96. package/dist/core-commands/checkout.command.impl.d.ts +0 -110
  97. package/dist/core-commands/checkout.command.impl.d.ts.map +0 -1
  98. package/src/core-commands/checkout.command.impl.ts +0 -564
  99. package/src/core-commands/checkout.command.ts +0 -125
@@ -72,8 +72,16 @@ export interface FetchResult {
72
72
  bytesReceived: number;
73
73
  /** Whether the remote repository was empty */
74
74
  isEmpty: boolean;
75
- /** Messages from the remote */
75
+ /**
76
+ * Messages as git prints them: the `followRemoteHEAD=warn` warning and its hint lines,
77
+ * the symbolic refs a prune left dangling
78
+ */
76
79
  messages: string[];
80
+ /**
81
+ * What failed without stopping the fetch (a refused prune), where git reports an error
82
+ * and exits 1; absent when nothing failed
83
+ */
84
+ errors?: string[];
77
85
  /** Submodule fetch results (if any) */
78
86
  submodules?: Map<string, FetchResult>;
79
87
  }
@@ -1,65 +1,248 @@
1
+ import type { ObjectId } from "@statewalker/vcs-core";
2
+ import type { StageStateValue } from "@statewalker/vcs-working-tree";
3
+
4
+ /**
5
+ * One column of `git status --porcelain`: `X` (the index against HEAD) or `Y` (the
6
+ * worktree against the index). `" "` unchanged, `M` modified, `T` type changed, `A` added,
7
+ * `D` deleted, `U` unmerged, `?` untracked, `!` ignored.
8
+ */
9
+ export type StatusCode = " " | "M" | "T" | "A" | "D" | "U" | "?" | "!";
10
+
11
+ /** A side of a path: its mode and object id. */
12
+ export interface StatusSide {
13
+ mode: number;
14
+ id: ObjectId;
15
+ }
16
+
1
17
  /**
2
- * Status of the staging area compared to HEAD.
18
+ * The status of one path, as a line of `git status --porcelain` describes it.
3
19
  *
4
- * This is a simplified version for repositories without working trees,
5
- * focusing on staged changes and conflicts.
20
+ * @example
21
+ * ```typescript
22
+ * const entry = status.files.find((f) => f.path === "a.txt");
23
+ * // { path: "a.txt", index: "M", worktree: " ", head: {...}, staged: {...} }
24
+ * ```
25
+ */
26
+ export interface StatusFileEntry {
27
+ path: string;
28
+ /** `X`: the index against HEAD (`U` for an unmerged path, `?`/`!` for untracked/ignored) */
29
+ index: StatusCode;
30
+ /** `Y`: the worktree against the index */
31
+ worktree: StatusCode;
32
+ /** The HEAD entry, if HEAD has the path */
33
+ head?: StatusSide;
34
+ /** The index entry (stage 0), if the index has the path */
35
+ staged?: StatusSide;
36
+ /** The mode git would stage for the worktree file, if there is one */
37
+ worktreeMode?: number;
38
+ /** A submodule whose checked-out commit differs from the index's (porcelain v2 `SC..`) */
39
+ submoduleCommitChanged?: boolean;
40
+ /** An unmerged path's stages 1-3 (base, ours, theirs) */
41
+ stages?: [StatusSide | undefined, StatusSide | undefined, StatusSide | undefined];
42
+ }
43
+
44
+ /**
45
+ * Status of the repository: the index against HEAD, and the worktree against the index, as
46
+ * `git status` reports them.
6
47
  *
7
- * Based on JGit's Status but without working tree operations.
48
+ * Based on JGit's Status.
8
49
  */
9
50
  export interface Status {
10
- /**
11
- * Files added to staging (not in HEAD).
12
- */
51
+ /** Files added to the index (not in HEAD). */
13
52
  readonly added: Set<string>;
14
-
15
- /**
16
- * Files modified in staging (different from HEAD).
17
- */
53
+ /** Files changed in the index (content, mode or type differs from HEAD). */
18
54
  readonly changed: Set<string>;
19
-
20
- /**
21
- * Files removed from staging (in HEAD but not in staging).
22
- */
55
+ /** Files removed from the index (in HEAD, not in the index). */
23
56
  readonly removed: Set<string>;
24
-
57
+ /** Files with merge conflicts (unmerged index entries). */
58
+ readonly conflicting: Set<string>;
59
+ /** The kind of each conflict (both modified, deleted by them, ...). */
60
+ readonly conflictingStageState: Map<string, StageStateValue>;
61
+ /** Tracked files whose worktree content, mode or type differs from the index. */
62
+ readonly modified: Set<string>;
63
+ /** Tracked files missing from the worktree. */
64
+ readonly missing: Set<string>;
65
+ /** Files the index does not track (a nested repository as `sub/`). */
66
+ readonly untracked: Set<string>;
67
+ /** Untracked files the ignore rules exclude (only with `setIgnored(true)`). */
68
+ readonly ignored: Set<string>;
25
69
  /**
26
- * Files with merge conflicts.
70
+ * Every path with a status, as the lines of `git status --porcelain`: a path HEAD has,
71
+ * the index removed and the worktree still holds appears twice (`D ` and `??`).
27
72
  */
28
- readonly conflicting: Set<string>;
73
+ readonly files: StatusFileEntry[];
29
74
 
30
75
  /**
31
- * Check if the staging area is clean (no changes, no conflicts).
76
+ * Whether there is nothing to report: no staged or unstaged change, no conflict and no
77
+ * untracked file (`git status`: "nothing to commit, working tree clean").
32
78
  */
33
79
  isClean(): boolean;
34
80
 
35
81
  /**
36
- * Check if there are uncommitted changes.
37
- * True if any files are added, changed, removed, or conflicting.
82
+ * Whether there are uncommitted changes to tracked files: staged, unstaged or conflicting
83
+ * (untracked files are not changes).
38
84
  */
39
85
  hasUncommittedChanges(): boolean;
40
86
  }
41
87
 
42
88
  /**
43
- * Implementation of Status interface.
89
+ * Implementation of the Status interface.
44
90
  */
45
91
  export class StatusImpl implements Status {
92
+ readonly modified: Set<string>;
93
+ readonly missing: Set<string>;
94
+ readonly untracked: Set<string>;
95
+ readonly ignored: Set<string>;
96
+ readonly conflictingStageState: Map<string, StageStateValue>;
97
+ readonly files: StatusFileEntry[];
98
+
46
99
  constructor(
47
100
  public readonly added: Set<string>,
48
101
  public readonly changed: Set<string>,
49
102
  public readonly removed: Set<string>,
50
103
  public readonly conflicting: Set<string>,
51
- ) {}
104
+ worktree: {
105
+ modified?: Set<string>;
106
+ missing?: Set<string>;
107
+ untracked?: Set<string>;
108
+ ignored?: Set<string>;
109
+ conflictingStageState?: Map<string, StageStateValue>;
110
+ files?: StatusFileEntry[];
111
+ } = {},
112
+ ) {
113
+ this.modified = worktree.modified ?? new Set();
114
+ this.missing = worktree.missing ?? new Set();
115
+ this.untracked = worktree.untracked ?? new Set();
116
+ this.ignored = worktree.ignored ?? new Set();
117
+ this.conflictingStageState = worktree.conflictingStageState ?? new Map();
118
+ this.files = worktree.files ?? [];
119
+ }
52
120
 
53
121
  isClean(): boolean {
122
+ return !this.hasUncommittedChanges() && this.untracked.size === 0;
123
+ }
124
+
125
+ hasUncommittedChanges(): boolean {
54
126
  return (
55
- this.added.size === 0 &&
56
- this.changed.size === 0 &&
57
- this.removed.size === 0 &&
58
- this.conflicting.size === 0
127
+ this.added.size > 0 ||
128
+ this.changed.size > 0 ||
129
+ this.removed.size > 0 ||
130
+ this.conflicting.size > 0 ||
131
+ this.modified.size > 0 ||
132
+ this.missing.size > 0
59
133
  );
60
134
  }
135
+ }
61
136
 
62
- hasUncommittedChanges(): boolean {
63
- return !this.isClean();
137
+ /** git's byte order of paths (UTF-8 code units, as `strcmp`). */
138
+ function comparePaths(a: string, b: string): number {
139
+ const ea = new TextEncoder().encode(a);
140
+ const eb = new TextEncoder().encode(b);
141
+ const n = Math.min(ea.length, eb.length);
142
+ for (let i = 0; i < n; i++) if (ea[i] !== eb[i]) return ea[i] - eb[i];
143
+ return ea.length - eb.length;
144
+ }
145
+
146
+ const ZERO_ID = "0".repeat(40);
147
+ const octal = (mode: number | undefined) => (mode ?? 0).toString(8).padStart(6, "0");
148
+
149
+ /**
150
+ * git's quoting of a path in status output (`core.quotePath`, on by default); porcelain v1
151
+ * quotes a path with a space too (`QUOTE_PATH_QUOTE_SP`), v2 does not.
152
+ */
153
+ function quotePath(path: string, quoteSpace = false): string {
154
+ const bytes = new TextEncoder().encode(path);
155
+ let needs = false;
156
+ let out = "";
157
+ for (const b of bytes) {
158
+ if (b === 0x22 || b === 0x5c) {
159
+ needs = true;
160
+ out += `\\${String.fromCharCode(b)}`;
161
+ } else if (b === 0x09) {
162
+ needs = true;
163
+ out += "\\t";
164
+ } else if (b === 0x0a) {
165
+ needs = true;
166
+ out += "\\n";
167
+ } else if (b === 0x20 && quoteSpace) {
168
+ needs = true;
169
+ out += " ";
170
+ } else if (b < 0x20 || b >= 0x7f) {
171
+ needs = true;
172
+ out += `\\${b.toString(8).padStart(3, "0")}`;
173
+ } else out += String.fromCharCode(b);
174
+ }
175
+ return needs ? `"${out}"` : path;
176
+ }
177
+
178
+ /**
179
+ * The status as `git status --porcelain` (v1) or `--porcelain=v2` prints it, with
180
+ * `--untracked-files=all` (and the ignored files when the status has them): the changed
181
+ * tracked paths first, then the untracked, then the ignored ones, each in git's path order.
182
+ * Renames are not detected (as `-c status.renames=false`).
183
+ *
184
+ * @example
185
+ * ```typescript
186
+ * formatStatusPorcelain(await git.status().call());
187
+ * // " M a.txt\nA b.txt\n?? new.txt\n"
188
+ * ```
189
+ */
190
+ export function formatStatusPorcelain(status: Status, version: 1 | 2 = 1): string {
191
+ const entries = status.files;
192
+ const tracked = entries
193
+ .filter((e) => e.index !== "?" && e.index !== "!")
194
+ .sort((a, b) => comparePaths(a.path, b.path));
195
+ const untracked = entries
196
+ .filter((e) => e.index === "?")
197
+ .sort((a, b) => comparePaths(a.path, b.path));
198
+ const ignored = entries
199
+ .filter((e) => e.index === "!")
200
+ .sort((a, b) => comparePaths(a.path, b.path));
201
+ const lines: string[] = [];
202
+ for (const e of tracked) {
203
+ const path = quotePath(e.path, version === 1);
204
+ if (version === 1) {
205
+ lines.push(`${e.index}${e.worktree} ${path}`);
206
+ continue;
207
+ }
208
+ const xy = `${e.index === " " ? "." : e.index}${e.worktree === " " ? "." : e.worktree}`;
209
+ const isSubmodule = e.staged?.mode === 0o160000 || e.head?.mode === 0o160000;
210
+ const sub = isSubmodule ? `S${e.submoduleCommitChanged ? "C" : "."}..` : "N...";
211
+ if (e.stages) {
212
+ const [s1, s2, s3] = e.stages;
213
+ lines.push(
214
+ [
215
+ "u",
216
+ xy,
217
+ sub,
218
+ octal(s1?.mode),
219
+ octal(s2?.mode),
220
+ octal(s3?.mode),
221
+ octal(e.worktreeMode),
222
+ s1?.id ?? ZERO_ID,
223
+ s2?.id ?? ZERO_ID,
224
+ s3?.id ?? ZERO_ID,
225
+ path,
226
+ ].join(" "),
227
+ );
228
+ continue;
229
+ }
230
+ lines.push(
231
+ [
232
+ "1",
233
+ xy,
234
+ sub,
235
+ octal(e.head?.mode),
236
+ octal(e.staged?.mode),
237
+ octal(e.worktreeMode),
238
+ e.head?.id ?? ZERO_ID,
239
+ e.staged?.id ?? ZERO_ID,
240
+ path,
241
+ ].join(" "),
242
+ );
64
243
  }
244
+ const mark = version === 1 ? ["??", "!!"] : ["?", "!"];
245
+ for (const e of untracked) lines.push(`${mark[0]} ${quotePath(e.path, version === 1)}`);
246
+ for (const e of ignored) lines.push(`${mark[1]} ${quotePath(e.path, version === 1)}`);
247
+ return lines.map((l) => `${l}\n`).join("");
65
248
  }
@@ -17,6 +17,8 @@ export interface TransportOptions {
17
17
  headers?: Record<string, string>;
18
18
  /** Request timeout in milliseconds */
19
19
  timeout?: number;
20
+ /** Gzip large fetch request bodies (default true, as git; see `setGzipRequests`) */
21
+ gzipRequests?: boolean;
20
22
  /** Progress callback */
21
23
  onProgress?: ProgressCallback;
22
24
  /** Raw progress message callback */
@@ -38,6 +40,8 @@ export abstract class TransportCommand<T> extends GitCommand<T> {
38
40
  protected timeout?: number;
39
41
  /** Custom HTTP headers */
40
42
  protected headers?: Record<string, string>;
43
+ /** Gzip large fetch request bodies (undefined: the transport's default, true) */
44
+ protected gzipRequests?: boolean;
41
45
  /** Progress callback */
42
46
  protected progressCallback?: ProgressCallback;
43
47
  /** Progress message callback */
@@ -77,6 +81,19 @@ export abstract class TransportCommand<T> extends GitCommand<T> {
77
81
  return this;
78
82
  }
79
83
 
84
+ /**
85
+ * Send large upload-pack request bodies (a fetch's have-batches over 1024 bytes) gzipped,
86
+ * with `Content-Encoding: gzip`, as git does (default true). Pass false for a browser behind
87
+ * a CORS proxy that does not allow that header (it is not CORS-safelisted).
88
+ *
89
+ * @param gzip Whether to gzip large request bodies
90
+ */
91
+ setGzipRequests(gzip: boolean): this {
92
+ this.checkCallable();
93
+ this.gzipRequests = gzip;
94
+ return this;
95
+ }
96
+
80
97
  /**
81
98
  * Set custom HTTP headers.
82
99
  *
@@ -118,6 +135,7 @@ export abstract class TransportCommand<T> extends GitCommand<T> {
118
135
  auth: this.credentials,
119
136
  headers: this.headers,
120
137
  timeout: this.timeout,
138
+ gzipRequests: this.gzipRequests,
121
139
  onProgress: this.progressCallback,
122
140
  onProgressMessage: this.progressMessageCallback,
123
141
  };
@@ -1,103 +0,0 @@
1
- /**
2
- * Checkout interface for materializing tree contents to filesystem.
3
- *
4
- * Supports:
5
- * - Branch/tag/commit checkout
6
- * - Path-specific checkout
7
- * - Conflict detection
8
- * - Progress reporting
9
- *
10
- * Reference: jgit/org.eclipse.jgit/src/org/eclipse/jgit/api/CheckoutCommand.java
11
- */
12
- import type { ObjectId } from "@statewalker/vcs-core";
13
- /**
14
- * Options for checkout operations.
15
- */
16
- export interface CheckoutOptions {
17
- /** Force checkout even if working tree has changes */
18
- force?: boolean;
19
- /** Create branch at target commit */
20
- createBranch?: string;
21
- /** Checkout specific paths only */
22
- paths?: string[];
23
- /** Source for path checkout (default: "index") */
24
- source?: "index" | "head" | ObjectId;
25
- /** Progress callback */
26
- onProgress?: (current: number, total: number, path: string) => void;
27
- }
28
- /**
29
- * Result of a checkout operation.
30
- */
31
- export interface CheckoutResult {
32
- /** Files updated in working tree */
33
- updated: string[];
34
- /** Files added to working tree */
35
- added: string[];
36
- /** Files removed from working tree */
37
- removed: string[];
38
- /** Files that couldn't be checked out (conflicts) */
39
- conflicts: string[];
40
- /** New HEAD after checkout */
41
- newHead?: ObjectId;
42
- /** New branch name if created */
43
- newBranch?: string;
44
- }
45
- /**
46
- * Checkout command interface.
47
- *
48
- * Materializes tree contents from commits, branches, or tags to the working tree.
49
- * Handles conflict detection and index updates.
50
- */
51
- export interface Checkout {
52
- /**
53
- * Checkout a branch, tag, or commit.
54
- *
55
- * If target is a branch name, HEAD becomes a symbolic ref to that branch.
56
- * If target is a tag or commit, HEAD becomes detached.
57
- *
58
- * @param target Branch name, tag name, or commit ID
59
- * @param options Checkout options
60
- * @returns Checkout result with lists of affected files
61
- * @throws Error if target cannot be resolved or conflicts exist (without force)
62
- */
63
- checkout(target: string, options?: CheckoutOptions): Promise<CheckoutResult>;
64
- /**
65
- * Checkout specific paths from index or commit.
66
- *
67
- * Unlike full checkout, this:
68
- * - Does not move HEAD
69
- * - Only updates specified paths
70
- * - Restores files from index (default) or a specific commit
71
- *
72
- * @param paths Paths to checkout
73
- * @param options Checkout options (source specifies where to get files)
74
- * @returns Checkout result
75
- */
76
- checkoutPaths(paths: string[], options?: CheckoutOptions): Promise<CheckoutResult>;
77
- }
78
- /**
79
- * Conflict information for a path.
80
- */
81
- export interface CheckoutConflict {
82
- /** Path with conflict */
83
- path: string;
84
- /** Reason for conflict */
85
- reason: CheckoutConflictReason;
86
- /** Local changes that would be overwritten (if applicable) */
87
- localChanges?: "modified" | "deleted" | "untracked";
88
- }
89
- /**
90
- * Reasons why checkout failed for a path.
91
- */
92
- export declare const CheckoutConflictReason: {
93
- /** Local modifications would be overwritten */
94
- readonly LOCAL_MODIFIED: "LOCAL_MODIFIED";
95
- /** Untracked file would be overwritten */
96
- readonly UNTRACKED_OVERWRITTEN: "UNTRACKED_OVERWRITTEN";
97
- /** File deleted locally but modified in target */
98
- readonly DELETED_LOCALLY: "DELETED_LOCALLY";
99
- /** Cannot delete directory - not empty */
100
- readonly DIRECTORY_NOT_EMPTY: "DIRECTORY_NOT_EMPTY";
101
- };
102
- export type CheckoutConflictReason = (typeof CheckoutConflictReason)[keyof typeof CheckoutConflictReason];
103
- //# sourceMappingURL=checkout.command.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"checkout.command.d.ts","sourceRoot":"","sources":["../../src/core-commands/checkout.command.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEtD;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,sDAAsD;IACtD,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB,qCAAqC;IACrC,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,mCAAmC;IACnC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IAEjB,kDAAkD;IAClD,MAAM,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAC;IAErC,wBAAwB;IACxB,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACrE;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,oCAAoC;IACpC,OAAO,EAAE,MAAM,EAAE,CAAC;IAElB,kCAAkC;IAClC,KAAK,EAAE,MAAM,EAAE,CAAC;IAEhB,sCAAsC;IACtC,OAAO,EAAE,MAAM,EAAE,CAAC;IAElB,qDAAqD;IACrD,SAAS,EAAE,MAAM,EAAE,CAAC;IAEpB,8BAA8B;IAC9B,OAAO,CAAC,EAAE,QAAQ,CAAC;IAEnB,iCAAiC;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;GAKG;AACH,MAAM,WAAW,QAAQ;IACvB;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IAE7E;;;;;;;;;;;OAWG;IACH,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;CACpF;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,yBAAyB;IACzB,IAAI,EAAE,MAAM,CAAC;IAEb,0BAA0B;IAC1B,MAAM,EAAE,sBAAsB,CAAC;IAE/B,8DAA8D;IAC9D,YAAY,CAAC,EAAE,UAAU,GAAG,SAAS,GAAG,WAAW,CAAC;CACrD;AAED;;GAEG;AACH,eAAO,MAAM,sBAAsB;IACjC,+CAA+C;aAC/C,cAAc,EAAE,gBAAgB;IAEhC,0CAA0C;aAC1C,qBAAqB,EAAE,uBAAuB;IAE9C,kDAAkD;aAClD,eAAe,EAAE,iBAAiB;IAElC,0CAA0C;aAC1C,mBAAmB,EAAE,qBAAqB;CAClC,CAAC;AAEX,MAAM,MAAM,sBAAsB,GAChC,CAAC,OAAO,sBAAsB,CAAC,CAAC,MAAM,OAAO,sBAAsB,CAAC,CAAC"}
@@ -1,110 +0,0 @@
1
- /**
2
- * CheckoutCommand - Materializes tree contents to filesystem.
3
- *
4
- * Implements the Checkout interface to:
5
- * - Checkout branches, tags, or commits
6
- * - Checkout specific paths from index or commits
7
- * - Detect and report conflicts
8
- * - Update HEAD and index after checkout
9
- *
10
- * Reference: jgit/org.eclipse.jgit/src/org/eclipse/jgit/api/CheckoutCommand.java
11
- */
12
- import { type Blobs, type Commits, type FilesApi, type Refs, type Trees } from "@statewalker/vcs-core";
13
- import type { Staging } from "@statewalker/vcs-working-tree";
14
- import type { Checkout, CheckoutOptions, CheckoutResult } from "./checkout.command.js";
15
- /**
16
- * Options for creating a CheckoutCommand.
17
- */
18
- export interface CheckoutCommandOptions {
19
- /** FilesApi for filesystem operations */
20
- files: FilesApi;
21
- /** Working tree root path */
22
- workTreeRoot: string;
23
- /** Blob storage for loading file content */
24
- blobs: Blobs;
25
- /** Tree storage for loading tree entries */
26
- trees: Trees;
27
- /** Commit storage for resolving commits */
28
- commits: Commits;
29
- /** Reference storage for resolving refs and updating HEAD */
30
- refs: Refs;
31
- /** Staging area (index) for updating after checkout */
32
- staging: Staging;
33
- }
34
- /**
35
- * CheckoutCommand implementation.
36
- */
37
- export declare class CheckoutCommand implements Checkout {
38
- private readonly files;
39
- private readonly workTreeRoot;
40
- private readonly blobs;
41
- private readonly trees;
42
- private readonly commits;
43
- private readonly refs;
44
- private readonly staging;
45
- constructor(options: CheckoutCommandOptions);
46
- /**
47
- * Checkout a branch, tag, or commit.
48
- */
49
- checkout(target: string, options?: CheckoutOptions): Promise<CheckoutResult>;
50
- /**
51
- * Checkout specific paths from index or commit.
52
- */
53
- checkoutPaths(paths: string[], options?: CheckoutOptions): Promise<CheckoutResult>;
54
- /**
55
- * Checkout a path from the index.
56
- */
57
- private checkoutFromIndex;
58
- /**
59
- * Checkout a path from a tree.
60
- */
61
- private checkoutFromTree;
62
- /**
63
- * Checkout an entire tree to the working directory.
64
- */
65
- private checkoutTree;
66
- /**
67
- * Write file content to working tree.
68
- */
69
- private writeFileContent;
70
- /**
71
- * Remove file from working tree.
72
- */
73
- private removeFile;
74
- /**
75
- * Remove empty parent directories.
76
- */
77
- private cleanEmptyParents;
78
- /**
79
- * Flatten a tree into a map of path -> entry.
80
- */
81
- private flattenTree;
82
- /**
83
- * Resolve target to commit ID.
84
- */
85
- private resolveTarget;
86
- /**
87
- * Check if name is a local branch.
88
- */
89
- private isLocalBranch;
90
- /**
91
- * Get HEAD's tree ID.
92
- */
93
- private getHeadTreeId;
94
- /**
95
- * Detect conflicts - files that would be overwritten.
96
- */
97
- private detectConflicts;
98
- /**
99
- * Rebuild index from tree.
100
- */
101
- private rebuildIndex;
102
- }
103
- /**
104
- * Create a CheckoutCommand.
105
- *
106
- * @param options Command options
107
- * @returns New CheckoutCommand instance
108
- */
109
- export declare function createCheckoutCommand(options: CheckoutCommandOptions): Checkout;
110
- //# sourceMappingURL=checkout.command.impl.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"checkout.command.impl.d.ts","sourceRoot":"","sources":["../../src/core-commands/checkout.command.impl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAEL,KAAK,KAAK,EACV,KAAK,OAAO,EAEZ,KAAK,QAAQ,EAIb,KAAK,IAAI,EAET,KAAK,KAAK,EACX,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAE7D,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAUvF;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,yCAAyC;IACzC,KAAK,EAAE,QAAQ,CAAC;IAEhB,6BAA6B;IAC7B,YAAY,EAAE,MAAM,CAAC;IAErB,4CAA4C;IAC5C,KAAK,EAAE,KAAK,CAAC;IAEb,4CAA4C;IAC5C,KAAK,EAAE,KAAK,CAAC;IAEb,2CAA2C;IAC3C,OAAO,EAAE,OAAO,CAAC;IAEjB,6DAA6D;IAC7D,IAAI,EAAE,IAAI,CAAC;IAEX,uDAAuD;IACvD,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;GAEG;AACH,qBAAa,eAAgB,YAAW,QAAQ;IAC9C,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAW;IACjC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAS;IACtC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAQ;IAC9B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAQ;IAC9B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAU;IAClC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAO;IAC5B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAU;IAElC,YAAY,OAAO,EAAE,sBAAsB,EAQ1C;IAED;;OAEG;IACG,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB,GAAG,OAAO,CAAC,cAAc,CAAC,CAiDrF;IAED;;OAEG;IACG,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,OAAO,GAAE,eAAoB,GAAG,OAAO,CAAC,cAAc,CAAC,CA4B3F;IAED;;OAEG;YACW,iBAAiB;IAS/B;;OAEG;YACW,gBAAgB;IA8B9B;;OAEG;YACW,YAAY;IA4E1B;;OAEG;YACW,gBAAgB;IAuB9B;;OAEG;YACW,UAAU;IASxB;;OAEG;YACW,iBAAiB;IA0B/B;;OAEG;YACW,WAAW;IAwBzB;;OAEG;YACW,aAAa;IA2B3B;;OAEG;YACW,aAAa;IAI3B;;OAEG;YACW,aAAa;IAQ3B;;OAEG;YACW,eAAe;IA6E7B;;OAEG;YACW,YAAY;CAgC3B;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,sBAAsB,GAAG,QAAQ,CAE/E"}