@statewalker/vcs-commands 0.14.0 → 0.15.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/add-patch/patch-backend.d.ts +1 -1
- package/dist/commands/add-patch/patch-backend.d.ts.map +1 -1
- package/dist/commands/archive/remote-archive-command.d.ts +4 -1
- package/dist/commands/archive/remote-archive-command.d.ts.map +1 -1
- package/dist/commands/branch-command.d.ts +14 -2
- package/dist/commands/branch-command.d.ts.map +1 -1
- package/dist/commands/cat-file/batch-format.d.ts +8 -12
- package/dist/commands/cat-file/batch-format.d.ts.map +1 -1
- package/dist/commands/cat-file/cat-file-command.d.ts +39 -5
- package/dist/commands/cat-file/cat-file-command.d.ts.map +1 -1
- package/dist/commands/check-ignore-command.d.ts.map +1 -1
- package/dist/commands/checkout-command.d.ts +4 -0
- package/dist/commands/checkout-command.d.ts.map +1 -1
- package/dist/commands/checkout-paths.d.ts +9 -0
- package/dist/commands/checkout-paths.d.ts.map +1 -1
- package/dist/commands/cherry-pick-command.d.ts +3 -0
- package/dist/commands/cherry-pick-command.d.ts.map +1 -1
- package/dist/commands/clean-interactive.d.ts +0 -9
- package/dist/commands/clean-interactive.d.ts.map +1 -1
- package/dist/commands/clone-command.d.ts +2 -0
- package/dist/commands/clone-command.d.ts.map +1 -1
- package/dist/commands/column/column-config.d.ts +23 -0
- package/dist/commands/column/column-config.d.ts.map +1 -0
- package/dist/commands/column/column-layout.d.ts +129 -0
- package/dist/commands/column/column-layout.d.ts.map +1 -0
- package/dist/commands/column/index.d.ts +3 -0
- package/dist/commands/column/index.d.ts.map +1 -0
- package/dist/commands/column-command.d.ts +59 -0
- package/dist/commands/column-command.d.ts.map +1 -0
- package/dist/commands/comment-char-config.d.ts +15 -0
- package/dist/commands/comment-char-config.d.ts.map +1 -1
- package/dist/commands/commit-command.d.ts +21 -2
- package/dist/commands/commit-command.d.ts.map +1 -1
- package/dist/commands/config-command.d.ts +12 -0
- package/dist/commands/config-command.d.ts.map +1 -1
- package/dist/commands/credential-helper.d.ts +214 -0
- package/dist/commands/credential-helper.d.ts.map +1 -0
- package/dist/commands/default-branch.d.ts +17 -1
- package/dist/commands/default-branch.d.ts.map +1 -1
- package/dist/commands/diff-color-config.d.ts +4 -0
- package/dist/commands/diff-color-config.d.ts.map +1 -1
- package/dist/commands/diff-command.d.ts +12 -0
- package/dist/commands/diff-command.d.ts.map +1 -1
- package/dist/commands/fast-export/fast-export-command.d.ts +89 -2
- package/dist/commands/fast-export/fast-export-command.d.ts.map +1 -1
- package/dist/commands/fast-export/fast-import-command.d.ts +113 -8
- package/dist/commands/fast-export/fast-import-command.d.ts.map +1 -1
- package/dist/commands/fast-export/fast-stream-support.d.ts +0 -9
- package/dist/commands/fast-export/fast-stream-support.d.ts.map +1 -1
- package/dist/commands/fetch-command.d.ts +21 -0
- package/dist/commands/fetch-command.d.ts.map +1 -1
- package/dist/commands/git-hooks.d.ts +28 -0
- package/dist/commands/git-hooks.d.ts.map +1 -1
- package/dist/commands/history-command.d.ts +173 -7
- package/dist/commands/history-command.d.ts.map +1 -1
- package/dist/commands/index-host.d.ts +19 -0
- package/dist/commands/index-host.d.ts.map +1 -1
- package/dist/commands/index-refresh.d.ts +36 -0
- package/dist/commands/index-refresh.d.ts.map +1 -0
- package/dist/commands/index.d.ts +9 -0
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +7 -6
- package/dist/commands/init-command.d.ts +20 -0
- package/dist/commands/init-command.d.ts.map +1 -1
- package/dist/commands/local-transport.d.ts +29 -1
- package/dist/commands/local-transport.d.ts.map +1 -1
- package/dist/commands/log-command.d.ts +7 -0
- package/dist/commands/log-command.d.ts.map +1 -1
- package/dist/commands/log-output.d.ts +11 -0
- package/dist/commands/log-output.d.ts.map +1 -1
- package/dist/commands/maintenance-schedule-command.d.ts +122 -0
- package/dist/commands/maintenance-schedule-command.d.ts.map +1 -0
- package/dist/commands/merge-command.d.ts +2 -0
- package/dist/commands/merge-command.d.ts.map +1 -1
- package/dist/commands/merge-index-command.d.ts +42 -0
- package/dist/commands/merge-index-command.d.ts.map +1 -0
- package/dist/commands/merge-one-file.d.ts +129 -0
- package/dist/commands/merge-one-file.d.ts.map +1 -0
- package/dist/commands/merge-support.d.ts +21 -2
- package/dist/commands/merge-support.d.ts.map +1 -1
- package/dist/commands/object-disk-info.d.ts +35 -0
- package/dist/commands/object-disk-info.d.ts.map +1 -0
- package/dist/commands/octopus-merge.d.ts +3 -3
- package/dist/commands/octopus-merge.d.ts.map +1 -1
- package/dist/commands/promisor-remote.d.ts.map +1 -1
- package/dist/commands/pull-command.d.ts +55 -7
- package/dist/commands/pull-command.d.ts.map +1 -1
- package/dist/commands/push-command.d.ts +18 -1
- package/dist/commands/push-command.d.ts.map +1 -1
- package/dist/commands/range-diff/range-diff-command.d.ts +37 -1
- package/dist/commands/range-diff/range-diff-command.d.ts.map +1 -1
- package/dist/commands/rebase-command.d.ts +13 -1
- package/dist/commands/rebase-command.d.ts.map +1 -1
- package/dist/commands/ref-filter/for-each-ref-command.d.ts +3 -2
- package/dist/commands/ref-filter/for-each-ref-command.d.ts.map +1 -1
- package/dist/commands/ref-filter/ref-filter.d.ts.map +1 -1
- package/dist/commands/ref-filter/ref-format.d.ts +26 -1
- package/dist/commands/ref-filter/ref-format.d.ts.map +1 -1
- package/dist/commands/ref-filter/ref-listing-command.d.ts +9 -0
- package/dist/commands/ref-filter/ref-listing-command.d.ts.map +1 -1
- package/dist/commands/remote-transport.d.ts +27 -0
- package/dist/commands/remote-transport.d.ts.map +1 -1
- package/dist/commands/repack-command.d.ts +18 -2
- package/dist/commands/repack-command.d.ts.map +1 -1
- package/dist/commands/repo-command.d.ts +2 -7
- package/dist/commands/repo-command.d.ts.map +1 -1
- package/dist/commands/reset-command.d.ts +4 -1
- package/dist/commands/reset-command.d.ts.map +1 -1
- package/dist/commands/restore-command.d.ts.map +1 -1
- package/dist/commands/rev-list-command.d.ts +65 -0
- package/dist/commands/rev-list-command.d.ts.map +1 -1
- package/dist/commands/revert-command.d.ts +3 -0
- package/dist/commands/revert-command.d.ts.map +1 -1
- package/dist/commands/revision-filenames.d.ts.map +1 -1
- package/dist/commands/revision-range.d.ts +17 -0
- package/dist/commands/revision-range.d.ts.map +1 -1
- package/dist/commands/revision-resolver.d.ts +12 -0
- package/dist/commands/revision-resolver.d.ts.map +1 -1
- package/dist/commands/serve-repository.d.ts +17 -1
- package/dist/commands/serve-repository.d.ts.map +1 -1
- package/dist/commands/served-lazy-fetch.d.ts +61 -0
- package/dist/commands/served-lazy-fetch.d.ts.map +1 -0
- package/dist/commands/signing.d.ts +10 -4
- package/dist/commands/signing.d.ts.map +1 -1
- package/dist/commands/status-color-config.d.ts +33 -0
- package/dist/commands/status-color-config.d.ts.map +1 -0
- package/dist/commands/status-command.d.ts +15 -0
- package/dist/commands/status-command.d.ts.map +1 -1
- package/dist/commands/status-format.d.ts +46 -4
- package/dist/commands/status-format.d.ts.map +1 -1
- package/dist/commands/tag-command.d.ts +15 -1
- package/dist/commands/tag-command.d.ts.map +1 -1
- package/dist/commands/tree-restore.d.ts +14 -0
- package/dist/commands/tree-restore.d.ts.map +1 -1
- package/dist/commands/verify-command.d.ts +22 -2
- package/dist/commands/verify-command.d.ts.map +1 -1
- package/dist/commands/worktree-add-command.d.ts.map +1 -1
- package/dist/commands/worktree-overwrite-checks.d.ts +31 -6
- package/dist/commands/worktree-overwrite-checks.d.ts.map +1 -1
- package/dist/{commands-C9M78Chn.js → commands-DT3VEv50.js} +14879 -16703
- package/dist/errors/commit-errors.d.ts +23 -3
- package/dist/errors/commit-errors.d.ts.map +1 -1
- package/dist/errors/git-api-error.d.ts +6 -0
- package/dist/errors/git-api-error.d.ts.map +1 -1
- package/dist/errors/index.js +30 -4
- package/dist/{fsck-C4US3l0B.js → fsck-BZ508Elg.js} +1 -1
- package/dist/git-command.d.ts +33 -1
- package/dist/git-command.d.ts.map +1 -1
- package/dist/git.d.ts +104 -1
- package/dist/git.d.ts.map +1 -1
- package/dist/index.js +8 -7
- package/dist/{remote-transport-C43eykfK.js → local-transport-D98U6p4d.js} +184 -683
- package/dist/{maintenance-run-command-CoJFKr2p.js → maintenance-run-command-DZFnbnbo.js} +2285 -79
- package/dist/remote-config/remote-config-store.d.ts +6 -0
- package/dist/remote-config/remote-config-store.d.ts.map +1 -1
- package/dist/remote-transport-zvSqwpOB.js +4865 -0
- package/dist/results/cherry-pick-result.d.ts +4 -3
- package/dist/results/cherry-pick-result.d.ts.map +1 -1
- package/dist/results/diff-output.d.ts +7 -0
- package/dist/results/diff-output.d.ts.map +1 -1
- package/dist/results/diff-words.d.ts +14 -3
- package/dist/results/diff-words.d.ts.map +1 -1
- package/dist/results/index.js +1 -1
- package/dist/results/line-prefix-sink.d.ts +50 -0
- package/dist/results/line-prefix-sink.d.ts.map +1 -0
- package/dist/results/merge-result.d.ts +4 -3
- package/dist/results/merge-result.d.ts.map +1 -1
- package/dist/results/rebase-result.d.ts +5 -0
- package/dist/results/rebase-result.d.ts.map +1 -1
- package/dist/results/revert-result.d.ts +4 -3
- package/dist/results/revert-result.d.ts.map +1 -1
- package/dist/{results-B0CWLCAp.js → results-rF81cQse.js} +1425 -202
- package/dist/transport-command.d.ts +10 -0
- package/dist/transport-command.d.ts.map +1 -1
- package/package.json +12 -12
- package/src/commands/add-command.ts +15 -2
- package/src/commands/add-patch/patch-backend.ts +6 -44
- package/src/commands/archive/remote-archive-command.ts +10 -3
- package/src/commands/branch-command.ts +57 -4
- package/src/commands/cat-file/batch-format.ts +17 -18
- package/src/commands/cat-file/cat-file-command.ts +181 -15
- package/src/commands/check-ignore-command.ts +61 -17
- package/src/commands/checkout-command.ts +149 -21
- package/src/commands/checkout-index-command.ts +2 -1
- package/src/commands/checkout-paths.ts +13 -0
- package/src/commands/cherry-pick-command.ts +9 -0
- package/src/commands/clean-interactive.ts +20 -74
- package/src/commands/clone-command.ts +13 -0
- package/src/commands/column/column-config.ts +63 -0
- package/src/commands/column/column-layout.ts +396 -0
- package/src/commands/column/index.ts +2 -0
- package/src/commands/column-command.ts +171 -0
- package/src/commands/comment-char-config.ts +42 -0
- package/src/commands/commit-command.ts +61 -21
- package/src/commands/config-command.ts +28 -0
- package/src/commands/credential-helper.ts +807 -0
- package/src/commands/default-branch.ts +38 -0
- package/src/commands/diff-color-config.ts +23 -10
- package/src/commands/diff-command.ts +25 -2
- package/src/commands/fast-export/fast-export-command.ts +661 -35
- package/src/commands/fast-export/fast-import-command.ts +694 -94
- package/src/commands/fast-export/fast-stream-support.ts +18 -1
- package/src/commands/fetch-command.ts +103 -14
- package/src/commands/git-hooks.ts +85 -0
- package/src/commands/history-command.ts +952 -20
- package/src/commands/index-host.ts +51 -0
- package/src/commands/index-refresh.ts +121 -0
- package/src/commands/index.ts +9 -0
- package/src/commands/init-command.ts +34 -1
- package/src/commands/legacy-remotes.ts +4 -20
- package/src/commands/local-transport.ts +130 -9
- package/src/commands/log-command.ts +39 -1
- package/src/commands/log-output.ts +31 -4
- package/src/commands/maintenance-schedule-command.ts +418 -0
- package/src/commands/merge-command.ts +10 -0
- package/src/commands/merge-index-command.ts +202 -0
- package/src/commands/merge-one-file.ts +451 -0
- package/src/commands/merge-support.ts +127 -11
- package/src/commands/object-disk-info.ts +169 -0
- package/src/commands/octopus-merge.ts +37 -128
- package/src/commands/promisor-remote.ts +14 -3
- package/src/commands/pull-command.ts +173 -27
- package/src/commands/push-command.ts +50 -5
- package/src/commands/range-diff/range-diff-command.ts +86 -3
- package/src/commands/rebase-command.ts +46 -1
- package/src/commands/ref-filter/for-each-ref-command.ts +4 -3
- package/src/commands/ref-filter/ref-filter.ts +59 -4
- package/src/commands/ref-filter/ref-format.ts +83 -10
- package/src/commands/ref-filter/ref-listing-command.ts +30 -0
- package/src/commands/remote-command.ts +2 -2
- package/src/commands/remote-transport.ts +66 -3
- package/src/commands/repack-command.ts +75 -9
- package/src/commands/repo-command.ts +6 -70
- package/src/commands/reset-command.ts +11 -1
- package/src/commands/restore-command.ts +1 -0
- package/src/commands/rev-list-command.ts +205 -3
- package/src/commands/revert-command.ts +9 -0
- package/src/commands/revision-filenames.ts +32 -4
- package/src/commands/revision-range.ts +2 -2
- package/src/commands/revision-resolver.ts +21 -1
- package/src/commands/serve-repository.ts +34 -8
- package/src/commands/served-lazy-fetch.ts +164 -0
- package/src/commands/signing.ts +18 -10
- package/src/commands/status-color-config.ts +92 -0
- package/src/commands/status-command.ts +50 -2
- package/src/commands/status-format.ts +198 -50
- package/src/commands/tag-command.ts +57 -2
- package/src/commands/tree-restore.ts +17 -0
- package/src/commands/verify-command.ts +84 -12
- package/src/commands/worktree-add-command.ts +2 -0
- package/src/commands/worktree-overwrite-checks.ts +75 -14
- package/src/errors/commit-errors.ts +31 -3
- package/src/errors/git-api-error.ts +7 -0
- package/src/git-command.ts +105 -4
- package/src/git.ts +153 -0
- package/src/remote-config/remote-config-store.ts +16 -0
- package/src/results/cherry-pick-result.ts +4 -3
- package/src/results/diff-output.ts +8 -0
- package/src/results/diff-words.ts +160 -32
- package/src/results/line-prefix-sink.ts +102 -0
- package/src/results/merge-result.ts +4 -3
- package/src/results/rebase-result.ts +5 -0
- package/src/results/revert-result.ts +4 -3
- package/src/transport-command.ts +48 -2
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where diff.c's `diff_line_prefix` (the graph's padding under `log --graph`) goes in a diff
|
|
3
|
+
* output: a sink recording a position before every line pushed to it, except in the bytes a
|
|
4
|
+
* writer marks as placing the prefix itself (git's word diff writes it only where
|
|
5
|
+
* `fn_out_diff_words_write_helper` and `color_words_output_graph_prefix` put it). The log
|
|
6
|
+
* inserts the prefix afterwards ({@link insertLinePrefix}), once its graph has printed the
|
|
7
|
+
* commit's header and the padding is known.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* const sink = new LinePrefixSink();
|
|
12
|
+
* sink.text("diff --git a/f b/f\n");
|
|
13
|
+
* sink.push(markLinePrefix(encodeGitPath("-old\n"), { before: 0, own: true }));
|
|
14
|
+
* insertLinePrefix(sink.bytes(), sink.points, encodeGitPath("| ")); // "| diff --git a/f b/f\n-old\n"
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* Marks follow the chunk itself (a `WeakMap` of arrays), so they survive a sink that holds
|
|
18
|
+
* chunks before passing them on unchanged (`MovedLineBuffer`), but not one that joins them.
|
|
19
|
+
*
|
|
20
|
+
* @module
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
import { ByteSink } from "@statewalker/vcs-utils";
|
|
24
|
+
|
|
25
|
+
/** Where a marked chunk has the line prefix */
|
|
26
|
+
export interface LinePrefixMark {
|
|
27
|
+
/** How many prefixes go right before the chunk */
|
|
28
|
+
before: number;
|
|
29
|
+
/** The chunk places its prefixes itself: none at its line starts */
|
|
30
|
+
own: boolean;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const MARKS = new WeakMap<Uint8Array, LinePrefixMark>();
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Marks `bytes` for a {@link LinePrefixSink}. The mark belongs to the array object: mark a
|
|
37
|
+
* view of its own (`bytes.subarray(0)`) for each push of shared bytes.
|
|
38
|
+
*/
|
|
39
|
+
export function markLinePrefix(bytes: Uint8Array, mark: LinePrefixMark): Uint8Array {
|
|
40
|
+
MARKS.set(bytes, mark);
|
|
41
|
+
return bytes;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** A byte sink recording where the line prefix goes: each line start, marked chunks aside */
|
|
45
|
+
export class LinePrefixSink extends ByteSink {
|
|
46
|
+
/** The offsets in the output where a prefix goes, ascending (one offset may repeat) */
|
|
47
|
+
readonly points: number[] = [];
|
|
48
|
+
private offset = 0;
|
|
49
|
+
private atLineStart = true;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* A prefix at the current end of the output, written straight to the file (diff.c's
|
|
53
|
+
* `fputs(line_prefix)`): ahead of what a `MovedLineBuffer` still holds
|
|
54
|
+
*/
|
|
55
|
+
addPoint(): void {
|
|
56
|
+
this.points.push(this.offset);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
override push(bytes: Uint8Array): void {
|
|
60
|
+
if (bytes.length === 0) return;
|
|
61
|
+
const mark = MARKS.get(bytes);
|
|
62
|
+
for (let i = 0; i < (mark?.before ?? 0); i++) this.points.push(this.offset);
|
|
63
|
+
if (mark?.own) {
|
|
64
|
+
super.push(bytes);
|
|
65
|
+
this.offset += bytes.length;
|
|
66
|
+
// whatever git writes next through emit_line_0 (a context line, a hunk header, the
|
|
67
|
+
// next file's header) starts with the prefix
|
|
68
|
+
this.atLineStart = true;
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
super.push(bytes);
|
|
72
|
+
let at = 0;
|
|
73
|
+
while (at < bytes.length) {
|
|
74
|
+
if (this.atLineStart) this.points.push(this.offset + at);
|
|
75
|
+
const nl = bytes.indexOf(0x0a, at);
|
|
76
|
+
this.atLineStart = nl >= 0;
|
|
77
|
+
at = nl < 0 ? bytes.length : nl + 1;
|
|
78
|
+
}
|
|
79
|
+
this.offset += bytes.length;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** `bytes` with `prefix` inserted at each of `points` (ascending offsets) */
|
|
84
|
+
export function insertLinePrefix(
|
|
85
|
+
bytes: Uint8Array,
|
|
86
|
+
points: readonly number[],
|
|
87
|
+
prefix: Uint8Array,
|
|
88
|
+
): Uint8Array {
|
|
89
|
+
if (points.length === 0 || prefix.length === 0) return bytes;
|
|
90
|
+
const out = new Uint8Array(bytes.length + points.length * prefix.length);
|
|
91
|
+
let size = 0;
|
|
92
|
+
let from = 0;
|
|
93
|
+
for (const point of points) {
|
|
94
|
+
out.set(bytes.subarray(from, point), size);
|
|
95
|
+
size += point - from;
|
|
96
|
+
out.set(prefix, size);
|
|
97
|
+
size += prefix.length;
|
|
98
|
+
from = point;
|
|
99
|
+
}
|
|
100
|
+
out.set(bytes.subarray(from), size);
|
|
101
|
+
return out;
|
|
102
|
+
}
|
|
@@ -136,9 +136,10 @@ export interface MergeResult {
|
|
|
136
136
|
*/
|
|
137
137
|
readonly output?: string[];
|
|
138
138
|
/**
|
|
139
|
-
*
|
|
140
|
-
*
|
|
141
|
-
*
|
|
139
|
+
* Warnings git printed on stderr, line by line: first git 2.5x's `core.commentChar=auto`
|
|
140
|
+
* deprecation warning and its advice, then what the sparse checkout printed while the
|
|
141
|
+
* result was written (the patterns' warnings, git's "The following paths are not up to
|
|
142
|
+
* date and were left despite sparse patterns:" block). Absent when there was nothing to say.
|
|
142
143
|
*/
|
|
143
144
|
readonly warnings?: string[];
|
|
144
145
|
/**
|
|
@@ -173,6 +173,11 @@ export interface RebaseResult {
|
|
|
173
173
|
* said nothing.
|
|
174
174
|
*/
|
|
175
175
|
readonly rerereOutput?: string[];
|
|
176
|
+
/**
|
|
177
|
+
* What git printed on stderr as it started, line by line: git 2.5x's
|
|
178
|
+
* `core.commentChar=auto` deprecation warning and its advice. Absent when it said nothing.
|
|
179
|
+
*/
|
|
180
|
+
readonly warnings?: string[];
|
|
176
181
|
}
|
|
177
182
|
|
|
178
183
|
/**
|
|
@@ -37,9 +37,10 @@ export interface RevertResult {
|
|
|
37
37
|
/** What is printed on stdout: merge-ort's `Auto-merging f`, `CONFLICT (...)` lines */
|
|
38
38
|
readonly output?: string[];
|
|
39
39
|
/**
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
40
|
+
* Warnings git printed on stderr, line by line: first git 2.5x's `core.commentChar=auto`
|
|
41
|
+
* deprecation warning and its advice, then what the sparse checkout printed while the
|
|
42
|
+
* result was written (the patterns' warnings, git's "The following paths are not up to
|
|
43
|
+
* date and were left despite sparse patterns:" block). Absent when there was nothing to say.
|
|
43
44
|
*/
|
|
44
45
|
readonly warnings?: string[];
|
|
45
46
|
/**
|
package/src/transport-command.ts
CHANGED
|
@@ -13,12 +13,16 @@ import {
|
|
|
13
13
|
createBundleUriHost,
|
|
14
14
|
fetchBundleUri,
|
|
15
15
|
} from "./commands/bundle/index.js";
|
|
16
|
+
import { configuresCredentialHelper, credentialHelperOf } from "./commands/credential-helper.js";
|
|
17
|
+
import { hookRunnerOf } from "./commands/git-hooks.js";
|
|
16
18
|
import { hostEnvironmentOf } from "./commands/git-ident.js";
|
|
17
19
|
import { httpClientSettingsOf } from "./commands/http-config.js";
|
|
20
|
+
import { remoteHookSession } from "./commands/local-transport.js";
|
|
18
21
|
import { createPromisorFetcher, promisorOf } from "./commands/promisor-remote.js";
|
|
19
22
|
import {
|
|
20
23
|
bundleRemoteOf,
|
|
21
24
|
httpSessionSettings,
|
|
25
|
+
localLazyFetchOf,
|
|
22
26
|
openResolvedRemote,
|
|
23
27
|
type PreparedRemote,
|
|
24
28
|
prepareRemote,
|
|
@@ -82,6 +86,8 @@ export abstract class TransportCommand<T> extends GitCommand<T> {
|
|
|
82
86
|
protected credentialHelper?: HttpCredentialHelper;
|
|
83
87
|
/** git's `warning:` lines of the HTTP client */
|
|
84
88
|
protected warningCallback?: (line: string) => void;
|
|
89
|
+
/** The helper built from `credential.helper` for this command (see {@link httpCredentialHelper}) */
|
|
90
|
+
private configCredentialHelper?: HttpCredentialHelper | null;
|
|
85
91
|
|
|
86
92
|
constructor(workingCopy: WorkingCopy) {
|
|
87
93
|
super(workingCopy);
|
|
@@ -239,6 +245,24 @@ export abstract class TransportCommand<T> extends GitCommand<T> {
|
|
|
239
245
|
return this;
|
|
240
246
|
}
|
|
241
247
|
|
|
248
|
+
/**
|
|
249
|
+
* The credential helper this command's HTTP requests ask: the one given to
|
|
250
|
+
* {@link setCredentialHelper}, else, when the configuration names a `credential.helper`
|
|
251
|
+
* and the host has a hook runner, git's helpers of that configuration (credential.c through
|
|
252
|
+
* {@link credentialHelperOf}: their stderr in the hook output), as git's transports read
|
|
253
|
+
* them; else none.
|
|
254
|
+
*/
|
|
255
|
+
protected httpCredentialHelper(): HttpCredentialHelper | undefined {
|
|
256
|
+
if (this.credentialHelper) return this.credentialHelper;
|
|
257
|
+
if (this.configCredentialHelper === undefined) {
|
|
258
|
+
this.configCredentialHelper =
|
|
259
|
+
hookRunnerOf(this._workingCopy) && configuresCredentialHelper(this._workingCopy)
|
|
260
|
+
? credentialHelperOf(this._workingCopy, { hooks: this.hooks })
|
|
261
|
+
: null;
|
|
262
|
+
}
|
|
263
|
+
return this.configCredentialHelper ?? undefined;
|
|
264
|
+
}
|
|
265
|
+
|
|
242
266
|
/**
|
|
243
267
|
* Receives the `warning:` lines git's HTTP client prints on stderr (`rate limited, waiting
|
|
244
268
|
* <n> seconds before retry`).
|
|
@@ -356,8 +380,23 @@ export abstract class TransportCommand<T> extends GitCommand<T> {
|
|
|
356
380
|
...(this.gzipRequests !== undefined ? { gzipRequests: this.gzipRequests } : {}),
|
|
357
381
|
protocolVersion: protocolVersionOf(RemoteConfigStore.from(this._workingCopy)),
|
|
358
382
|
httpSettings: (url) => this.httpSettingsFor(url),
|
|
359
|
-
...(this.
|
|
383
|
+
...credentialHelperOption(this.httpCredentialHelper()),
|
|
360
384
|
...httpSessionSettings(this._workingCopy),
|
|
385
|
+
// a local remote's upload-pack runs the protected uploadpack.packObjectsHook through
|
|
386
|
+
// this host's runner, in the remote's git directory, with local_repo_env cleared
|
|
387
|
+
localHooks: (remote) => remoteHookSession(this._workingCopy, remote, { localPush: true }),
|
|
388
|
+
// GIT_NAMESPACE: what a local remote's upload-pack and receive-pack serve
|
|
389
|
+
...(() => {
|
|
390
|
+
const namespace = hostEnvironmentOf(this._workingCopy)?.namespace;
|
|
391
|
+
return namespace ? { namespace } : {};
|
|
392
|
+
})(),
|
|
393
|
+
// GIT_NO_LAZY_FETCH=0: a local remote's upload-pack fetches what it lacks
|
|
394
|
+
...localLazyFetchOf(hostEnvironmentOf(this._workingCopy), {
|
|
395
|
+
transports: this.getTransports(),
|
|
396
|
+
...(this.credentialHelper ? { credentialHelper: this.credentialHelper } : {}),
|
|
397
|
+
...(this.timeout !== undefined ? { timeout: this.timeout } : {}),
|
|
398
|
+
...(this.warningCallback ? { warningCallback: this.warningCallback } : {}),
|
|
399
|
+
}),
|
|
361
400
|
};
|
|
362
401
|
}
|
|
363
402
|
|
|
@@ -441,7 +480,7 @@ export abstract class TransportCommand<T> extends GitCommand<T> {
|
|
|
441
480
|
...(options.remoteUrl !== undefined ? { remoteUrl: options.remoteUrl } : {}),
|
|
442
481
|
...(this.credentials ? { credentials: this.credentials } : {}),
|
|
443
482
|
...(this.headers ? { headers: this.headers } : {}),
|
|
444
|
-
...(this.
|
|
483
|
+
...credentialHelperOption(this.httpCredentialHelper()),
|
|
445
484
|
httpSettings: (url) => this.httpSettingsFor(url),
|
|
446
485
|
configValue: (key) => store.value(key),
|
|
447
486
|
setConfigValue:
|
|
@@ -505,3 +544,10 @@ export abstract class TransportCommand<T> extends GitCommand<T> {
|
|
|
505
544
|
};
|
|
506
545
|
}
|
|
507
546
|
}
|
|
547
|
+
|
|
548
|
+
/** The `credentialHelper` option of a session or host, when there is one. */
|
|
549
|
+
function credentialHelperOption(helper: HttpCredentialHelper | undefined): {
|
|
550
|
+
credentialHelper?: HttpCredentialHelper;
|
|
551
|
+
} {
|
|
552
|
+
return helper ? { credentialHelper: helper } : {};
|
|
553
|
+
}
|