@statewalker/vcs-commands 0.3.2 → 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/README.md +19 -0
- package/dist/commands/add-command.d.ts +0 -6
- package/dist/commands/add-command.d.ts.map +1 -1
- package/dist/commands/blame-command.d.ts +14 -0
- package/dist/commands/blame-command.d.ts.map +1 -1
- package/dist/commands/branch-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 +61 -21
- 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 +104 -37
- 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/merge-command.d.ts +15 -2
- package/dist/commands/merge-command.d.ts.map +1 -1
- package/dist/commands/push-command.d.ts +58 -25
- package/dist/commands/push-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/tag-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-COO4tJhv.js → commands-CsLNyvZ1.js} +3370 -1057
- package/dist/core-commands/add.command.impl.d.ts +0 -4
- package/dist/core-commands/add.command.impl.d.ts.map +1 -1
- package/dist/core-commands/index.d.ts +1 -3
- package/dist/core-commands/index.d.ts.map +1 -1
- package/dist/core-commands/store-worktree-file.d.ts +6 -0
- package/dist/core-commands/store-worktree-file.d.ts.map +1 -0
- 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 +22 -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/diff-formatter.d.ts +14 -7
- package/dist/results/diff-formatter.d.ts.map +1 -1
- package/dist/results/fetch-result.d.ts +16 -1
- package/dist/results/fetch-result.d.ts.map +1 -1
- package/dist/results/index.js +28 -23
- package/dist/results/push-result.d.ts +9 -2
- package/dist/results/push-result.d.ts.map +1 -1
- package/dist/results/status-result.d.ts +91 -20
- package/dist/results/status-result.d.ts.map +1 -1
- package/dist/{status-result-BwAyxq6R.js → status-result-BpyUK1Sg.js} +115 -5
- package/dist/transport-command.d.ts +12 -0
- package/dist/transport-command.d.ts.map +1 -1
- package/package.json +14 -12
- package/src/commands/add-command.ts +23 -30
- package/src/commands/blame-command.ts +41 -0
- package/src/commands/branch-command.ts +2 -53
- package/src/commands/checkout-command.ts +205 -127
- package/src/commands/clean-command.ts +187 -81
- package/src/commands/clone-command.ts +334 -137
- package/src/commands/core-config.ts +41 -0
- package/src/commands/fetch-command.ts +536 -211
- package/src/commands/gc-command.ts +1 -1
- package/src/commands/index.ts +1 -0
- package/src/commands/init-command.ts +108 -11
- package/src/commands/merge-command.ts +60 -27
- package/src/commands/pack-refs-command.ts +2 -2
- package/src/commands/push-command.ts +242 -308
- package/src/commands/reflog-command.ts +2 -2
- 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/tag-command.ts +2 -53
- package/src/commands/tree-restore.ts +143 -18
- package/src/commands/worktree-overwrite-checks.ts +215 -0
- package/src/core-commands/add.command.impl.ts +15 -20
- package/src/core-commands/index.ts +1 -8
- package/src/core-commands/store-worktree-file.ts +5 -0
- 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 +95 -8
- package/src/remote-config/remote-refs.ts +103 -0
- package/src/results/clone-result.ts +6 -0
- package/src/results/diff-formatter.ts +31 -38
- package/src/results/fetch-result.ts +16 -1
- package/src/results/push-result.ts +9 -2
- 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 -114
- package/dist/core-commands/checkout.command.impl.d.ts.map +0 -1
- package/dist/pack-import/index.d.ts +0 -8
- package/dist/pack-import/index.d.ts.map +0 -1
- package/dist/pack-import/pack-import.d.ts +0 -11
- package/dist/pack-import/pack-import.d.ts.map +0 -1
- package/src/core-commands/checkout.command.impl.ts +0 -586
- package/src/core-commands/checkout.command.ts +0 -125
- package/src/pack-import/index.ts +0 -8
- package/src/pack-import/pack-import.ts +0 -24
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"push-result.d.ts","sourceRoot":"","sources":["../../src/results/push-result.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEtD;;;;GAIG;AACH,oBAAY,UAAU;IACpB,wCAAwC;IACxC,EAAE,OAAO;IACT,6CAA6C;IAC7C,uBAAuB,4BAA4B;IACnD,yCAAyC;IACzC,cAAc,mBAAmB;IACjC,mCAAmC;IACnC,MAAM,WAAW;IACjB,6CAA6C;IAC7C,aAAa,kBAAkB;IAC/B,gCAAgC;IAChC,UAAU,eAAe;IACzB,0DAA0D;IAC1D,eAAe,oBAAoB;CACpC;AAED;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,qCAAqC;IACrC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,uCAAuC;IACvC,UAAU,EAAE,MAAM,CAAC;IACnB,oDAAoD;IACpD,mBAAmB,CAAC,EAAE,QAAQ,CAAC;IAC/B,oCAAoC;IACpC,WAAW,EAAE,QAAQ,CAAC;IACtB,2BAA2B;IAC3B,MAAM,EAAE,UAAU,CAAC;IACnB,
|
|
1
|
+
{"version":3,"file":"push-result.d.ts","sourceRoot":"","sources":["../../src/results/push-result.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEtD;;;;GAIG;AACH,oBAAY,UAAU;IACpB,wCAAwC;IACxC,EAAE,OAAO;IACT,6CAA6C;IAC7C,u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
import type { StageStateValue } from "@statewalker/vcs-working-tree";
|
|
1
3
|
/**
|
|
2
|
-
*
|
|
4
|
+
* One column of `git status --porcelain`: `X` (the index against HEAD) or `Y` (the
|
|
5
|
+
* worktree against the index). `" "` unchanged, `M` modified, `T` type changed, `A` added,
|
|
6
|
+
* `D` deleted, `U` unmerged, `?` untracked, `!` ignored.
|
|
7
|
+
*/
|
|
8
|
+
export type StatusCode = " " | "M" | "T" | "A" | "D" | "U" | "?" | "!";
|
|
9
|
+
/** A side of a path: its mode and object id. */
|
|
10
|
+
export interface StatusSide {
|
|
11
|
+
mode: number;
|
|
12
|
+
id: ObjectId;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The status of one path, as a line of `git status --porcelain` describes it.
|
|
3
16
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* const entry = status.files.find((f) => f.path === "a.txt");
|
|
20
|
+
* // { path: "a.txt", index: "M", worktree: " ", head: {...}, staged: {...} }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export interface StatusFileEntry {
|
|
24
|
+
path: string;
|
|
25
|
+
/** `X`: the index against HEAD (`U` for an unmerged path, `?`/`!` for untracked/ignored) */
|
|
26
|
+
index: StatusCode;
|
|
27
|
+
/** `Y`: the worktree against the index */
|
|
28
|
+
worktree: StatusCode;
|
|
29
|
+
/** The HEAD entry, if HEAD has the path */
|
|
30
|
+
head?: StatusSide;
|
|
31
|
+
/** The index entry (stage 0), if the index has the path */
|
|
32
|
+
staged?: StatusSide;
|
|
33
|
+
/** The mode git would stage for the worktree file, if there is one */
|
|
34
|
+
worktreeMode?: number;
|
|
35
|
+
/** A submodule whose checked-out commit differs from the index's (porcelain v2 `SC..`) */
|
|
36
|
+
submoduleCommitChanged?: boolean;
|
|
37
|
+
/** An unmerged path's stages 1-3 (base, ours, theirs) */
|
|
38
|
+
stages?: [StatusSide | undefined, StatusSide | undefined, StatusSide | undefined];
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Status of the repository: the index against HEAD, and the worktree against the index, as
|
|
42
|
+
* `git status` reports them.
|
|
6
43
|
*
|
|
7
|
-
* Based on JGit's Status
|
|
44
|
+
* Based on JGit's Status.
|
|
8
45
|
*/
|
|
9
46
|
export interface Status {
|
|
10
|
-
/**
|
|
11
|
-
* Files added to staging (not in HEAD).
|
|
12
|
-
*/
|
|
47
|
+
/** Files added to the index (not in HEAD). */
|
|
13
48
|
readonly added: Set<string>;
|
|
14
|
-
/**
|
|
15
|
-
* Files modified in staging (different from HEAD).
|
|
16
|
-
*/
|
|
49
|
+
/** Files changed in the index (content, mode or type differs from HEAD). */
|
|
17
50
|
readonly changed: Set<string>;
|
|
18
|
-
/**
|
|
19
|
-
* Files removed from staging (in HEAD but not in staging).
|
|
20
|
-
*/
|
|
51
|
+
/** Files removed from the index (in HEAD, not in the index). */
|
|
21
52
|
readonly removed: Set<string>;
|
|
53
|
+
/** Files with merge conflicts (unmerged index entries). */
|
|
54
|
+
readonly conflicting: Set<string>;
|
|
55
|
+
/** The kind of each conflict (both modified, deleted by them, ...). */
|
|
56
|
+
readonly conflictingStageState: Map<string, StageStateValue>;
|
|
57
|
+
/** Tracked files whose worktree content, mode or type differs from the index. */
|
|
58
|
+
readonly modified: Set<string>;
|
|
59
|
+
/** Tracked files missing from the worktree. */
|
|
60
|
+
readonly missing: Set<string>;
|
|
61
|
+
/** Files the index does not track (a nested repository as `sub/`). */
|
|
62
|
+
readonly untracked: Set<string>;
|
|
63
|
+
/** Untracked files the ignore rules exclude (only with `setIgnored(true)`). */
|
|
64
|
+
readonly ignored: Set<string>;
|
|
22
65
|
/**
|
|
23
|
-
*
|
|
66
|
+
* Every path with a status, as the lines of `git status --porcelain`: a path HEAD has,
|
|
67
|
+
* the index removed and the worktree still holds appears twice (`D ` and `??`).
|
|
24
68
|
*/
|
|
25
|
-
readonly
|
|
69
|
+
readonly files: StatusFileEntry[];
|
|
26
70
|
/**
|
|
27
|
-
*
|
|
71
|
+
* Whether there is nothing to report: no staged or unstaged change, no conflict and no
|
|
72
|
+
* untracked file (`git status`: "nothing to commit, working tree clean").
|
|
28
73
|
*/
|
|
29
74
|
isClean(): boolean;
|
|
30
75
|
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
76
|
+
* Whether there are uncommitted changes to tracked files: staged, unstaged or conflicting
|
|
77
|
+
* (untracked files are not changes).
|
|
33
78
|
*/
|
|
34
79
|
hasUncommittedChanges(): boolean;
|
|
35
80
|
}
|
|
36
81
|
/**
|
|
37
|
-
* Implementation of Status interface.
|
|
82
|
+
* Implementation of the Status interface.
|
|
38
83
|
*/
|
|
39
84
|
export declare class StatusImpl implements Status {
|
|
40
85
|
readonly added: Set<string>;
|
|
41
86
|
readonly changed: Set<string>;
|
|
42
87
|
readonly removed: Set<string>;
|
|
43
88
|
readonly conflicting: Set<string>;
|
|
44
|
-
|
|
89
|
+
readonly modified: Set<string>;
|
|
90
|
+
readonly missing: Set<string>;
|
|
91
|
+
readonly untracked: Set<string>;
|
|
92
|
+
readonly ignored: Set<string>;
|
|
93
|
+
readonly conflictingStageState: Map<string, StageStateValue>;
|
|
94
|
+
readonly files: StatusFileEntry[];
|
|
95
|
+
constructor(added: Set<string>, changed: Set<string>, removed: Set<string>, conflicting: Set<string>, worktree?: {
|
|
96
|
+
modified?: Set<string>;
|
|
97
|
+
missing?: Set<string>;
|
|
98
|
+
untracked?: Set<string>;
|
|
99
|
+
ignored?: Set<string>;
|
|
100
|
+
conflictingStageState?: Map<string, StageStateValue>;
|
|
101
|
+
files?: StatusFileEntry[];
|
|
102
|
+
});
|
|
45
103
|
isClean(): boolean;
|
|
46
104
|
hasUncommittedChanges(): boolean;
|
|
47
105
|
}
|
|
106
|
+
/**
|
|
107
|
+
* The status as `git status --porcelain` (v1) or `--porcelain=v2` prints it, with
|
|
108
|
+
* `--untracked-files=all` (and the ignored files when the status has them): the changed
|
|
109
|
+
* tracked paths first, then the untracked, then the ignored ones, each in git's path order.
|
|
110
|
+
* Renames are not detected (as `-c status.renames=false`).
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* ```typescript
|
|
114
|
+
* formatStatusPorcelain(await git.status().call());
|
|
115
|
+
* // " M a.txt\nA b.txt\n?? new.txt\n"
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
export declare function formatStatusPorcelain(status: Status, version?: 1 | 2): string;
|
|
48
119
|
//# sourceMappingURL=status-result.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status-result.d.ts","sourceRoot":"","sources":["../../src/results/status-result.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"status-result.d.ts","sourceRoot":"","sources":["../../src/results/status-result.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAErE;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;AAEvE,gDAAgD;AAChD,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,QAAQ,CAAC;CACd;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,4FAA4F;IAC5F,KAAK,EAAE,UAAU,CAAC;IAClB,0CAA0C;IAC1C,QAAQ,EAAE,UAAU,CAAC;IACrB,2CAA2C;IAC3C,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,2DAA2D;IAC3D,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,sEAAsE;IACtE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,0FAA0F;IAC1F,sBAAsB,CAAC,EAAE,OA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
249
|
/** Update was rejected (not fast-forward) */
|
|
250
250
|
PushStatus["REJECTED_NONFASTFORWARD"] = "rejected-nonfastforward";
|
|
251
|
+
/** Update was rejected: the remote ref no longer has the leased value (`--force-with-lease`) */
|
|
252
|
+
PushStatus["REJECTED_REMOTE_CHANGED"] = "rejected-remote-changed";
|
|
251
253
|
/** Update was rejected (other reason) */
|
|
252
254
|
PushStatus["REJECTED_OTHER"] = "rejected-other";
|
|
253
255
|
/** Update failed (remote error) */
|
|
@@ -385,25 +387,133 @@ let StashApplyStatus = /* @__PURE__ */ function(StashApplyStatus) {
|
|
|
385
387
|
//#endregion
|
|
386
388
|
//#region src/results/status-result.ts
|
|
387
389
|
/**
|
|
388
|
-
* Implementation of Status interface.
|
|
390
|
+
* Implementation of the Status interface.
|
|
389
391
|
*/
|
|
390
392
|
var StatusImpl = class {
|
|
391
393
|
added;
|
|
392
394
|
changed;
|
|
393
395
|
removed;
|
|
394
396
|
conflicting;
|
|
395
|
-
|
|
397
|
+
modified;
|
|
398
|
+
missing;
|
|
399
|
+
untracked;
|
|
400
|
+
ignored;
|
|
401
|
+
conflictingStageState;
|
|
402
|
+
files;
|
|
403
|
+
constructor(added, changed, removed, conflicting, worktree = {}) {
|
|
396
404
|
this.added = added;
|
|
397
405
|
this.changed = changed;
|
|
398
406
|
this.removed = removed;
|
|
399
407
|
this.conflicting = conflicting;
|
|
408
|
+
this.modified = worktree.modified ?? /* @__PURE__ */ new Set();
|
|
409
|
+
this.missing = worktree.missing ?? /* @__PURE__ */ new Set();
|
|
410
|
+
this.untracked = worktree.untracked ?? /* @__PURE__ */ new Set();
|
|
411
|
+
this.ignored = worktree.ignored ?? /* @__PURE__ */ new Set();
|
|
412
|
+
this.conflictingStageState = worktree.conflictingStageState ?? /* @__PURE__ */ new Map();
|
|
413
|
+
this.files = worktree.files ?? [];
|
|
400
414
|
}
|
|
401
415
|
isClean() {
|
|
402
|
-
return this.
|
|
416
|
+
return !this.hasUncommittedChanges() && this.untracked.size === 0;
|
|
403
417
|
}
|
|
404
418
|
hasUncommittedChanges() {
|
|
405
|
-
return
|
|
419
|
+
return this.added.size > 0 || this.changed.size > 0 || this.removed.size > 0 || this.conflicting.size > 0 || this.modified.size > 0 || this.missing.size > 0;
|
|
406
420
|
}
|
|
407
421
|
};
|
|
422
|
+
/** git's byte order of paths (UTF-8 code units, as `strcmp`). */
|
|
423
|
+
function comparePaths(a, b) {
|
|
424
|
+
const ea = new TextEncoder().encode(a);
|
|
425
|
+
const eb = new TextEncoder().encode(b);
|
|
426
|
+
const n = Math.min(ea.length, eb.length);
|
|
427
|
+
for (let i = 0; i < n; i++) if (ea[i] !== eb[i]) return ea[i] - eb[i];
|
|
428
|
+
return ea.length - eb.length;
|
|
429
|
+
}
|
|
430
|
+
const ZERO_ID = "0".repeat(40);
|
|
431
|
+
const octal = (mode) => (mode ?? 0).toString(8).padStart(6, "0");
|
|
432
|
+
/**
|
|
433
|
+
* git's quoting of a path in status output (`core.quotePath`, on by default); porcelain v1
|
|
434
|
+
* quotes a path with a space too (`QUOTE_PATH_QUOTE_SP`), v2 does not.
|
|
435
|
+
*/
|
|
436
|
+
function quotePath(path, quoteSpace = false) {
|
|
437
|
+
const bytes = new TextEncoder().encode(path);
|
|
438
|
+
let needs = false;
|
|
439
|
+
let out = "";
|
|
440
|
+
for (const b of bytes) if (b === 34 || b === 92) {
|
|
441
|
+
needs = true;
|
|
442
|
+
out += `\\${String.fromCharCode(b)}`;
|
|
443
|
+
} else if (b === 9) {
|
|
444
|
+
needs = true;
|
|
445
|
+
out += "\\t";
|
|
446
|
+
} else if (b === 10) {
|
|
447
|
+
needs = true;
|
|
448
|
+
out += "\\n";
|
|
449
|
+
} else if (b === 32 && quoteSpace) {
|
|
450
|
+
needs = true;
|
|
451
|
+
out += " ";
|
|
452
|
+
} else if (b < 32 || b >= 127) {
|
|
453
|
+
needs = true;
|
|
454
|
+
out += `\\${b.toString(8).padStart(3, "0")}`;
|
|
455
|
+
} else out += String.fromCharCode(b);
|
|
456
|
+
return needs ? `"${out}"` : path;
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* The status as `git status --porcelain` (v1) or `--porcelain=v2` prints it, with
|
|
460
|
+
* `--untracked-files=all` (and the ignored files when the status has them): the changed
|
|
461
|
+
* tracked paths first, then the untracked, then the ignored ones, each in git's path order.
|
|
462
|
+
* Renames are not detected (as `-c status.renames=false`).
|
|
463
|
+
*
|
|
464
|
+
* @example
|
|
465
|
+
* ```typescript
|
|
466
|
+
* formatStatusPorcelain(await git.status().call());
|
|
467
|
+
* // " M a.txt\nA b.txt\n?? new.txt\n"
|
|
468
|
+
* ```
|
|
469
|
+
*/
|
|
470
|
+
function formatStatusPorcelain(status, version = 1) {
|
|
471
|
+
const entries = status.files;
|
|
472
|
+
const tracked = entries.filter((e) => e.index !== "?" && e.index !== "!").sort((a, b) => comparePaths(a.path, b.path));
|
|
473
|
+
const untracked = entries.filter((e) => e.index === "?").sort((a, b) => comparePaths(a.path, b.path));
|
|
474
|
+
const ignored = entries.filter((e) => e.index === "!").sort((a, b) => comparePaths(a.path, b.path));
|
|
475
|
+
const lines = [];
|
|
476
|
+
for (const e of tracked) {
|
|
477
|
+
const path = quotePath(e.path, version === 1);
|
|
478
|
+
if (version === 1) {
|
|
479
|
+
lines.push(`${e.index}${e.worktree} ${path}`);
|
|
480
|
+
continue;
|
|
481
|
+
}
|
|
482
|
+
const xy = `${e.index === " " ? "." : e.index}${e.worktree === " " ? "." : e.worktree}`;
|
|
483
|
+
const sub = e.staged?.mode === 57344 || e.head?.mode === 57344 ? `S${e.submoduleCommitChanged ? "C" : "."}..` : "N...";
|
|
484
|
+
if (e.stages) {
|
|
485
|
+
const [s1, s2, s3] = e.stages;
|
|
486
|
+
lines.push([
|
|
487
|
+
"u",
|
|
488
|
+
xy,
|
|
489
|
+
sub,
|
|
490
|
+
octal(s1?.mode),
|
|
491
|
+
octal(s2?.mode),
|
|
492
|
+
octal(s3?.mode),
|
|
493
|
+
octal(e.worktreeMode),
|
|
494
|
+
s1?.id ?? ZERO_ID,
|
|
495
|
+
s2?.id ?? ZERO_ID,
|
|
496
|
+
s3?.id ?? ZERO_ID,
|
|
497
|
+
path
|
|
498
|
+
].join(" "));
|
|
499
|
+
continue;
|
|
500
|
+
}
|
|
501
|
+
lines.push([
|
|
502
|
+
"1",
|
|
503
|
+
xy,
|
|
504
|
+
sub,
|
|
505
|
+
octal(e.head?.mode),
|
|
506
|
+
octal(e.staged?.mode),
|
|
507
|
+
octal(e.worktreeMode),
|
|
508
|
+
e.head?.id ?? ZERO_ID,
|
|
509
|
+
e.staged?.id ?? ZERO_ID,
|
|
510
|
+
path
|
|
511
|
+
].join(" "));
|
|
512
|
+
}
|
|
513
|
+
const mark = version === 1 ? ["??", "!!"] : ["?", "!"];
|
|
514
|
+
for (const e of untracked) lines.push(`${mark[0]} ${quotePath(e.path, version === 1)}`);
|
|
515
|
+
for (const e of ignored) lines.push(`${mark[1]} ${quotePath(e.path, version === 1)}`);
|
|
516
|
+
return lines.map((l) => `${l}\n`).join("");
|
|
517
|
+
}
|
|
408
518
|
//#endregion
|
|
409
|
-
export {
|
|
519
|
+
export { MergeStrategy as C, MergeStatus as S, CherryPickStatus as T, RefUpdateStatus as _, RebaseAction as a, ContentMergeStrategy as b, PushStatus as c, ChangeType as d, createAddEntry as f, createRenameEntry as g, createModifyEntry as h, RevertStatus as i, getFailedUpdates as l, createDeleteEntry as m, formatStatusPorcelain as n, RebaseStatus as o, createCopyEntry as p, StashApplyStatus as r, isRebaseSuccessful as s, StatusImpl as t, isPushSuccessful as u, getSuccessfulUpdates as v, isMergeSuccessful as w, FastForwardMode as x, hasUpdates as y };
|
|
@@ -14,6 +14,8 @@ export interface TransportOptions {
|
|
|
14
14
|
headers?: Record<string, string>;
|
|
15
15
|
/** Request timeout in milliseconds */
|
|
16
16
|
timeout?: number;
|
|
17
|
+
/** Gzip large fetch request bodies (default true, as git; see `setGzipRequests`) */
|
|
18
|
+
gzipRequests?: boolean;
|
|
17
19
|
/** Progress callback */
|
|
18
20
|
onProgress?: ProgressCallback;
|
|
19
21
|
/** Raw progress message callback */
|
|
@@ -34,6 +36,8 @@ export declare abstract class TransportCommand<T> extends GitCommand<T> {
|
|
|
34
36
|
protected timeout?: number;
|
|
35
37
|
/** Custom HTTP headers */
|
|
36
38
|
protected headers?: Record<string, string>;
|
|
39
|
+
/** Gzip large fetch request bodies (undefined: the transport's default, true) */
|
|
40
|
+
protected gzipRequests?: boolean;
|
|
37
41
|
/** Progress callback */
|
|
38
42
|
protected progressCallback?: ProgressCallback;
|
|
39
43
|
/** Progress message callback */
|
|
@@ -57,6 +61,14 @@ export declare abstract class TransportCommand<T> extends GitCommand<T> {
|
|
|
57
61
|
* @param timeout Timeout in milliseconds
|
|
58
62
|
*/
|
|
59
63
|
setTimeout(timeout: number): this;
|
|
64
|
+
/**
|
|
65
|
+
* Send large upload-pack request bodies (a fetch's have-batches over 1024 bytes) gzipped,
|
|
66
|
+
* with `Content-Encoding: gzip`, as git does (default true). Pass false for a browser behind
|
|
67
|
+
* a CORS proxy that does not allow that header (it is not CORS-safelisted).
|
|
68
|
+
*
|
|
69
|
+
* @param gzip Whether to gzip large request bodies
|
|
70
|
+
*/
|
|
71
|
+
setGzipRequests(gzip: boolean): this;
|
|
60
72
|
/**
|
|
61
73
|
* Set custom HTTP headers.
|
|
62
74
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport-command.d.ts","sourceRoot":"","sources":["../src/transport-command.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE5E,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,IAAI,EAAE,YAAY,KAAK,IAAI,CAAC;AAE5D;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,iCAAiC;IACjC,IAAI,CAAC,E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AE,gBAAgB,CAAC;IAC9C,gCAAgC;IAChC,SAAS,CAAC,uBAAuB,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAE9D;;;;OAIG;IACH,cAAc,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI,CAI7C;IAED;;;;;OAKG;IACH,sBAAsB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAI/D;IAED;;;;OAIG;IACH,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAIhC;IAED;;;;;;OAMG;IACH,eAAe,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAInC;IAED;;;;OAIG;IACH,UAAU,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAIhD;IAED;;;;OAIG;IACH,kBAAkB,CAAC,QAAQ,EAAE,gBAAgB,GAAG,IAAI,CAInD;IAED;;;;OAIG;IACH,0BAA0B,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,GAAG,IAAI,CAIpE;IAED;;OAEG;IACH,SAAS,CAAC,mBAAmB,IAAI,gBAAgB,CAShD;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@statewalker/vcs-commands",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Git-like VCS commands (commit, checkout, merge, diff, log)",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/statewalker/webrun-vcs/issues"
|
|
@@ -46,26 +46,28 @@
|
|
|
46
46
|
"src"
|
|
47
47
|
],
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@statewalker/vcs-core": "^0.
|
|
50
|
-
"@statewalker/vcs-store-mem": "^0.
|
|
51
|
-
"@statewalker/vcs-
|
|
52
|
-
"@statewalker/vcs-utils": "^0.
|
|
53
|
-
"@statewalker/vcs-
|
|
54
|
-
"@statewalker/vcs-
|
|
49
|
+
"@statewalker/vcs-core": "^0.5.0",
|
|
50
|
+
"@statewalker/vcs-store-mem": "^0.5.0",
|
|
51
|
+
"@statewalker/vcs-transport": "^0.5.0",
|
|
52
|
+
"@statewalker/vcs-utils": "^0.5.0",
|
|
53
|
+
"@statewalker/vcs-working-tree": "^0.5.0",
|
|
54
|
+
"@statewalker/vcs-store-files": "^0.5.0"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@types/node": "^26.6.4",
|
|
58
58
|
"rolldown": "^1.2.12",
|
|
59
59
|
"typescript": "^7.0.2",
|
|
60
|
-
"vitest": "^5.0
|
|
61
|
-
"@statewalker/vcs-
|
|
62
|
-
"@statewalker/vcs-
|
|
63
|
-
"@statewalker/vcs-
|
|
60
|
+
"vitest": "^5.1.0",
|
|
61
|
+
"@statewalker/vcs-store-kv": "^0.5.0",
|
|
62
|
+
"@statewalker/vcs-store-sql": "^0.5.0",
|
|
63
|
+
"@statewalker/vcs-transport-adapters": "^0.5.0",
|
|
64
|
+
"@statewalker/vcs-utils-node": "^0.5.0"
|
|
64
65
|
},
|
|
65
66
|
"scripts": {
|
|
66
67
|
"build": "rm -rf dist && rolldown -c && tsc --emitDeclarationOnly --declaration",
|
|
67
68
|
"test": "vitest run",
|
|
68
69
|
"lint": "biome lint src tests",
|
|
69
|
-
"typecheck": "tsc --noEmit"
|
|
70
|
+
"typecheck": "tsc --noEmit",
|
|
71
|
+
"typecheck:tests": "tsc --noEmit -p tsconfig.test.json"
|
|
70
72
|
}
|
|
71
73
|
}
|
|
@@ -31,12 +31,15 @@
|
|
|
31
31
|
* ```
|
|
32
32
|
*/
|
|
33
33
|
|
|
34
|
-
import { FileMode } from "@statewalker/vcs-core";
|
|
34
|
+
import { EMPTY_BLOB_ID, FileMode } from "@statewalker/vcs-core";
|
|
35
35
|
import {
|
|
36
36
|
DeleteStagingEntry,
|
|
37
|
+
entryStatOf,
|
|
38
|
+
modeFromWorktree,
|
|
37
39
|
UpdateStagingEntry,
|
|
38
40
|
type Worktree,
|
|
39
41
|
} from "@statewalker/vcs-working-tree";
|
|
42
|
+
import { storeWorktreeFile } from "../core-commands/index.js";
|
|
40
43
|
|
|
41
44
|
import {
|
|
42
45
|
IncompatibleOptionsError,
|
|
@@ -44,6 +47,7 @@ import {
|
|
|
44
47
|
StoreNotAvailableError,
|
|
45
48
|
} from "../errors/index.js";
|
|
46
49
|
import { GitCommand } from "../git-command.js";
|
|
50
|
+
import { worktreeModeTrust } from "./core-config.js";
|
|
47
51
|
|
|
48
52
|
/**
|
|
49
53
|
* Result of AddCommand execution.
|
|
@@ -419,6 +423,8 @@ export class AddCommand extends GitCommand<AddResult> {
|
|
|
419
423
|
|
|
420
424
|
// Process files
|
|
421
425
|
const editor = this.staging.createEditor();
|
|
426
|
+
// what the worktree's modes can be trusted for (git's core.filemode / core.symlinks)
|
|
427
|
+
const trust = worktreeModeTrust(this.workingCopy, worktree);
|
|
422
428
|
|
|
423
429
|
for (const file of filesToProcess) {
|
|
424
430
|
if (!file.exists) {
|
|
@@ -433,10 +439,15 @@ export class AddCommand extends GitCommand<AddResult> {
|
|
|
433
439
|
const worktreeEntry = await worktree.getEntry(file.path);
|
|
434
440
|
const mode = worktreeEntry?.mode ?? FileMode.REGULAR_FILE;
|
|
435
441
|
editor.add(
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
442
|
+
// the empty blob's id, flagged intent-to-add, as git records it (never an empty
|
|
443
|
+
// or all-zero id, which a worktree hash could be compared against)
|
|
444
|
+
new UpdateStagingEntry(
|
|
445
|
+
file.path,
|
|
446
|
+
EMPTY_BLOB_ID,
|
|
447
|
+
mode,
|
|
448
|
+
{ size: 0, mtime: Date.now() },
|
|
449
|
+
{ intentToAdd: true },
|
|
450
|
+
),
|
|
440
451
|
);
|
|
441
452
|
added.push(file.path);
|
|
442
453
|
continue;
|
|
@@ -450,15 +461,13 @@ export class AddCommand extends GitCommand<AddResult> {
|
|
|
450
461
|
}
|
|
451
462
|
|
|
452
463
|
// Hash and store content
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
}),
|
|
461
|
-
);
|
|
464
|
+
// the stat that matched the stored content (a fresh one after a retry)
|
|
465
|
+
const stored = await storeWorktreeFile(this.blobs, worktree, file.path, worktreeEntry);
|
|
466
|
+
|
|
467
|
+
// Add to staging, with the mode git's ce_mode_from_stat would record
|
|
468
|
+
const indexMode = (await this.staging.getEntry(file.path))?.mode;
|
|
469
|
+
const mode = modeFromWorktree(stored.entry.mode, indexMode, trust);
|
|
470
|
+
editor.add(new UpdateStagingEntry(file.path, stored.id, mode, entryStatOf(stored.entry)));
|
|
462
471
|
added.push(file.path);
|
|
463
472
|
}
|
|
464
473
|
|
|
@@ -475,20 +484,4 @@ export class AddCommand extends GitCommand<AddResult> {
|
|
|
475
484
|
totalProcessed: added.length + removed.length,
|
|
476
485
|
};
|
|
477
486
|
}
|
|
478
|
-
|
|
479
|
-
/**
|
|
480
|
-
* Store file content as blob and return object ID.
|
|
481
|
-
*
|
|
482
|
-
* Note: The object store handles blob header internally.
|
|
483
|
-
*/
|
|
484
|
-
private async storeFileContent(worktree: Worktree, path: string): Promise<string> {
|
|
485
|
-
// Read content from working tree
|
|
486
|
-
const chunks: Uint8Array[] = [];
|
|
487
|
-
for await (const chunk of worktree.readContent(path)) {
|
|
488
|
-
chunks.push(chunk);
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
// Store raw content - the blob store handles blob formatting
|
|
492
|
-
return this.blobs.store(chunks);
|
|
493
|
-
}
|
|
494
487
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Commit, ObjectId, PersonIdent, TreeEntry } from "@statewalker/vcs-core";
|
|
2
|
+
import { DEFAULT_BIG_FILE_THRESHOLD } from "@statewalker/vcs-core";
|
|
2
3
|
import type { Edit } from "@statewalker/vcs-utils";
|
|
3
4
|
import {
|
|
4
5
|
DEFAULT_ALGORITHM,
|
|
@@ -197,6 +198,7 @@ export class BlameCommand extends GitCommand<BlameResult> {
|
|
|
197
198
|
private followRenames = false;
|
|
198
199
|
private renameScore = DEFAULT_RENAME_SCORE;
|
|
199
200
|
private diffAlgorithm: DiffAlgorithm = getAlgorithm(DEFAULT_ALGORITHM);
|
|
201
|
+
private bigFileThreshold = DEFAULT_BIG_FILE_THRESHOLD;
|
|
200
202
|
|
|
201
203
|
/**
|
|
202
204
|
* Set the file path to blame.
|
|
@@ -258,6 +260,22 @@ export class BlameCommand extends GitCommand<BlameResult> {
|
|
|
258
260
|
return this;
|
|
259
261
|
}
|
|
260
262
|
|
|
263
|
+
/**
|
|
264
|
+
* Set the size above which a file is never loaded (git's
|
|
265
|
+
* `core.bigFileThreshold`, default 50 MiB).
|
|
266
|
+
*
|
|
267
|
+
* Blaming a file over it rejects. A parent version over it is not compared:
|
|
268
|
+
* the lines it would have taken stay with the child commit, and it is not a
|
|
269
|
+
* rename candidate.
|
|
270
|
+
*
|
|
271
|
+
* @param threshold Size in bytes
|
|
272
|
+
*/
|
|
273
|
+
setBigFileThreshold(threshold: number): this {
|
|
274
|
+
this.checkCallable();
|
|
275
|
+
this.bigFileThreshold = threshold;
|
|
276
|
+
return this;
|
|
277
|
+
}
|
|
278
|
+
|
|
261
279
|
/**
|
|
262
280
|
* Execute the blame command.
|
|
263
281
|
*
|
|
@@ -298,6 +316,13 @@ export class BlameCommand extends GitCommand<BlameResult> {
|
|
|
298
316
|
throw new Error(`File not found: ${resultPath}`);
|
|
299
317
|
}
|
|
300
318
|
|
|
319
|
+
const size = await this.blobs.size(blobId);
|
|
320
|
+
if (size > this.bigFileThreshold) {
|
|
321
|
+
throw new Error(
|
|
322
|
+
`${resultPath} is ${size} bytes, larger than bigFileThreshold (${this.bigFileThreshold})`,
|
|
323
|
+
);
|
|
324
|
+
}
|
|
325
|
+
|
|
301
326
|
// Get file content and count lines
|
|
302
327
|
const content = await this.collectBlob(blobId);
|
|
303
328
|
const lineCount = this.countLines(content);
|
|
@@ -401,6 +426,11 @@ export class BlameCommand extends GitCommand<BlameResult> {
|
|
|
401
426
|
}
|
|
402
427
|
}
|
|
403
428
|
|
|
429
|
+
// A parent version over the threshold is never loaded: treat it as unrelated
|
|
430
|
+
if (parentBlobId && parentBlobId !== candidate.blobId && (await this.isBig(parentBlobId))) {
|
|
431
|
+
parentBlobId = undefined;
|
|
432
|
+
}
|
|
433
|
+
|
|
404
434
|
if (!parentBlobId) {
|
|
405
435
|
// File was introduced in this commit - blame all regions
|
|
406
436
|
this.blameRegions(entries, candidate);
|
|
@@ -500,6 +530,10 @@ export class BlameCommand extends GitCommand<BlameResult> {
|
|
|
500
530
|
}
|
|
501
531
|
}
|
|
502
532
|
|
|
533
|
+
if (parentBlobId && parentBlobId !== candidate.blobId && (await this.isBig(parentBlobId))) {
|
|
534
|
+
parentBlobId = undefined;
|
|
535
|
+
}
|
|
536
|
+
|
|
503
537
|
if (parentBlobId) {
|
|
504
538
|
// If any parent has identical blob, pass all blame to that parent
|
|
505
539
|
if (parentBlobId === candidate.blobId) {
|
|
@@ -983,6 +1017,8 @@ export class BlameCommand extends GitCommand<BlameResult> {
|
|
|
983
1017
|
let bestMatch: { path: string; blobId: ObjectId; score: number } | undefined;
|
|
984
1018
|
|
|
985
1019
|
for (const { path: oldPath, entry } of deletedFiles) {
|
|
1020
|
+
if (await this.isBig(entry.id)) continue;
|
|
1021
|
+
|
|
986
1022
|
// Load the old file content
|
|
987
1023
|
const oldContent = await this.collectBlob(entry.id);
|
|
988
1024
|
|
|
@@ -1039,6 +1075,11 @@ export class BlameCommand extends GitCommand<BlameResult> {
|
|
|
1039
1075
|
}
|
|
1040
1076
|
}
|
|
1041
1077
|
|
|
1078
|
+
/** Whether a blob is over the threshold (from its size, without reading it). */
|
|
1079
|
+
private async isBig(blobId: ObjectId): Promise<boolean> {
|
|
1080
|
+
return (await this.blobs.size(blobId)) > this.bigFileThreshold;
|
|
1081
|
+
}
|
|
1082
|
+
|
|
1042
1083
|
/**
|
|
1043
1084
|
* Collect blob content into a single buffer.
|
|
1044
1085
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ObjectId, Ref } from "@statewalker/vcs-core";
|
|
2
|
-
import { isSymbolicRef } from "@statewalker/vcs-core";
|
|
2
|
+
import { compareRefNames, isSymbolicRef, isValidBranchName } from "@statewalker/vcs-core";
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
CannotDeleteCurrentBranchError,
|
|
@@ -11,57 +11,6 @@ import {
|
|
|
11
11
|
import { GitCommand } from "../git-command.js";
|
|
12
12
|
import { ListBranchMode } from "../types.js";
|
|
13
13
|
|
|
14
|
-
/**
|
|
15
|
-
* Validate a branch name according to Git rules.
|
|
16
|
-
*
|
|
17
|
-
* @param name Branch name to validate
|
|
18
|
-
* @returns true if valid
|
|
19
|
-
*/
|
|
20
|
-
function isValidBranchName(name: string): boolean {
|
|
21
|
-
// Cannot be empty
|
|
22
|
-
if (!name || name.length === 0) {
|
|
23
|
-
return false;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// Cannot start or end with /
|
|
27
|
-
if (name.startsWith("/") || name.endsWith("/")) {
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// Cannot contain ..
|
|
32
|
-
if (name.includes("..")) {
|
|
33
|
-
return false;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
// Cannot contain special characters (control chars, space, ~^:?*[\)
|
|
37
|
-
// biome-ignore lint/suspicious/noControlCharactersInRegex: Git ref validation requires checking for control characters
|
|
38
|
-
if (/[\x00-\x1f\x7f ~^:?*[\\]/.test(name)) {
|
|
39
|
-
return false;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// Cannot end with .lock
|
|
43
|
-
if (name.endsWith(".lock")) {
|
|
44
|
-
return false;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// Cannot start with -
|
|
48
|
-
if (name.startsWith("-")) {
|
|
49
|
-
return false;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// Cannot be @
|
|
53
|
-
if (name === "@") {
|
|
54
|
-
return false;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// Cannot contain @{
|
|
58
|
-
if (name.includes("@{")) {
|
|
59
|
-
return false;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return true;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
14
|
/**
|
|
66
15
|
* Create a new branch.
|
|
67
16
|
*
|
|
@@ -372,7 +321,7 @@ export class ListBranchCommand extends GitCommand<Ref[]> {
|
|
|
372
321
|
}
|
|
373
322
|
|
|
374
323
|
// Sort by name
|
|
375
|
-
branches.sort((a, b) => a.name
|
|
324
|
+
branches.sort((a, b) => compareRefNames(a.name, b.name));
|
|
376
325
|
|
|
377
326
|
return branches;
|
|
378
327
|
}
|