gitx.do 0.0.2 → 0.0.3
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/cli/commands/blame.d.ts +259 -0
- package/dist/cli/commands/blame.d.ts.map +1 -0
- package/dist/cli/commands/blame.js +609 -0
- package/dist/cli/commands/blame.js.map +1 -0
- package/dist/cli/commands/branch.d.ts +249 -0
- package/dist/cli/commands/branch.d.ts.map +1 -0
- package/dist/cli/commands/branch.js +693 -0
- package/dist/cli/commands/branch.js.map +1 -0
- package/dist/cli/commands/commit.d.ts +182 -0
- package/dist/cli/commands/commit.d.ts.map +1 -0
- package/dist/cli/commands/commit.js +437 -0
- package/dist/cli/commands/commit.js.map +1 -0
- package/dist/cli/commands/diff.d.ts +464 -0
- package/dist/cli/commands/diff.d.ts.map +1 -0
- package/dist/cli/commands/diff.js +958 -0
- package/dist/cli/commands/diff.js.map +1 -0
- package/dist/cli/commands/log.d.ts +239 -0
- package/dist/cli/commands/log.d.ts.map +1 -0
- package/dist/cli/commands/log.js +535 -0
- package/dist/cli/commands/log.js.map +1 -0
- package/dist/cli/commands/review.d.ts +457 -0
- package/dist/cli/commands/review.d.ts.map +1 -0
- package/dist/cli/commands/review.js +533 -0
- package/dist/cli/commands/review.js.map +1 -0
- package/dist/cli/commands/status.d.ts +269 -0
- package/dist/cli/commands/status.d.ts.map +1 -0
- package/dist/cli/commands/status.js +493 -0
- package/dist/cli/commands/status.js.map +1 -0
- package/dist/cli/commands/web.d.ts +199 -0
- package/dist/cli/commands/web.d.ts.map +1 -0
- package/dist/cli/commands/web.js +696 -0
- package/dist/cli/commands/web.js.map +1 -0
- package/dist/cli/fs-adapter.d.ts +656 -0
- package/dist/cli/fs-adapter.d.ts.map +1 -0
- package/dist/cli/fs-adapter.js +1179 -0
- package/dist/cli/fs-adapter.js.map +1 -0
- package/dist/cli/index.d.ts +387 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +523 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/ui/components/DiffView.d.ts +7 -0
- package/dist/cli/ui/components/DiffView.d.ts.map +1 -0
- package/dist/cli/ui/components/DiffView.js +11 -0
- package/dist/cli/ui/components/DiffView.js.map +1 -0
- package/dist/cli/ui/components/ErrorDisplay.d.ts +6 -0
- package/dist/cli/ui/components/ErrorDisplay.d.ts.map +1 -0
- package/dist/cli/ui/components/ErrorDisplay.js +11 -0
- package/dist/cli/ui/components/ErrorDisplay.js.map +1 -0
- package/dist/cli/ui/components/FuzzySearch.d.ts +9 -0
- package/dist/cli/ui/components/FuzzySearch.d.ts.map +1 -0
- package/dist/cli/ui/components/FuzzySearch.js +12 -0
- package/dist/cli/ui/components/FuzzySearch.js.map +1 -0
- package/dist/cli/ui/components/LoadingSpinner.d.ts +6 -0
- package/dist/cli/ui/components/LoadingSpinner.d.ts.map +1 -0
- package/dist/cli/ui/components/LoadingSpinner.js +10 -0
- package/dist/cli/ui/components/LoadingSpinner.js.map +1 -0
- package/dist/cli/ui/components/NavigationList.d.ts +9 -0
- package/dist/cli/ui/components/NavigationList.d.ts.map +1 -0
- package/dist/cli/ui/components/NavigationList.js +11 -0
- package/dist/cli/ui/components/NavigationList.js.map +1 -0
- package/dist/cli/ui/components/ScrollableContent.d.ts +8 -0
- package/dist/cli/ui/components/ScrollableContent.d.ts.map +1 -0
- package/dist/cli/ui/components/ScrollableContent.js +11 -0
- package/dist/cli/ui/components/ScrollableContent.js.map +1 -0
- package/dist/cli/ui/components/index.d.ts +7 -0
- package/dist/cli/ui/components/index.d.ts.map +1 -0
- package/dist/cli/ui/components/index.js +9 -0
- package/dist/cli/ui/components/index.js.map +1 -0
- package/dist/cli/ui/terminal-ui.d.ts +52 -0
- package/dist/cli/ui/terminal-ui.d.ts.map +1 -0
- package/dist/cli/ui/terminal-ui.js +121 -0
- package/dist/cli/ui/terminal-ui.js.map +1 -0
- package/dist/durable-object/object-store.d.ts +401 -23
- package/dist/durable-object/object-store.d.ts.map +1 -1
- package/dist/durable-object/object-store.js +414 -25
- package/dist/durable-object/object-store.js.map +1 -1
- package/dist/durable-object/schema.d.ts +188 -0
- package/dist/durable-object/schema.d.ts.map +1 -1
- package/dist/durable-object/schema.js +160 -0
- package/dist/durable-object/schema.js.map +1 -1
- package/dist/durable-object/wal.d.ts +336 -31
- package/dist/durable-object/wal.d.ts.map +1 -1
- package/dist/durable-object/wal.js +272 -27
- package/dist/durable-object/wal.js.map +1 -1
- package/dist/index.d.ts +379 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +379 -7
- package/dist/index.js.map +1 -1
- package/dist/mcp/adapter.d.ts +579 -38
- package/dist/mcp/adapter.d.ts.map +1 -1
- package/dist/mcp/adapter.js +426 -33
- package/dist/mcp/adapter.js.map +1 -1
- package/dist/mcp/sandbox.d.ts +532 -29
- package/dist/mcp/sandbox.d.ts.map +1 -1
- package/dist/mcp/sandbox.js +389 -22
- package/dist/mcp/sandbox.js.map +1 -1
- package/dist/mcp/sdk-adapter.d.ts +478 -56
- package/dist/mcp/sdk-adapter.d.ts.map +1 -1
- package/dist/mcp/sdk-adapter.js +346 -44
- package/dist/mcp/sdk-adapter.js.map +1 -1
- package/dist/mcp/tools.d.ts +445 -30
- package/dist/mcp/tools.d.ts.map +1 -1
- package/dist/mcp/tools.js +363 -33
- package/dist/mcp/tools.js.map +1 -1
- package/dist/ops/blame.d.ts +424 -21
- package/dist/ops/blame.d.ts.map +1 -1
- package/dist/ops/blame.js +303 -20
- package/dist/ops/blame.js.map +1 -1
- package/dist/ops/branch.d.ts +583 -32
- package/dist/ops/branch.d.ts.map +1 -1
- package/dist/ops/branch.js +365 -23
- package/dist/ops/branch.js.map +1 -1
- package/dist/ops/commit-traversal.d.ts +164 -24
- package/dist/ops/commit-traversal.d.ts.map +1 -1
- package/dist/ops/commit-traversal.js +68 -2
- package/dist/ops/commit-traversal.js.map +1 -1
- package/dist/ops/commit.d.ts +387 -53
- package/dist/ops/commit.d.ts.map +1 -1
- package/dist/ops/commit.js +249 -29
- package/dist/ops/commit.js.map +1 -1
- package/dist/ops/merge-base.d.ts +195 -21
- package/dist/ops/merge-base.d.ts.map +1 -1
- package/dist/ops/merge-base.js +122 -12
- package/dist/ops/merge-base.js.map +1 -1
- package/dist/ops/merge.d.ts +600 -130
- package/dist/ops/merge.d.ts.map +1 -1
- package/dist/ops/merge.js +408 -60
- package/dist/ops/merge.js.map +1 -1
- package/dist/ops/tag.d.ts +67 -2
- package/dist/ops/tag.d.ts.map +1 -1
- package/dist/ops/tag.js +42 -1
- package/dist/ops/tag.js.map +1 -1
- package/dist/ops/tree-builder.d.ts +102 -6
- package/dist/ops/tree-builder.d.ts.map +1 -1
- package/dist/ops/tree-builder.js +30 -5
- package/dist/ops/tree-builder.js.map +1 -1
- package/dist/ops/tree-diff.d.ts +50 -2
- package/dist/ops/tree-diff.d.ts.map +1 -1
- package/dist/ops/tree-diff.js +50 -2
- package/dist/ops/tree-diff.js.map +1 -1
- package/dist/pack/delta.d.ts +211 -39
- package/dist/pack/delta.d.ts.map +1 -1
- package/dist/pack/delta.js +232 -46
- package/dist/pack/delta.js.map +1 -1
- package/dist/pack/format.d.ts +390 -28
- package/dist/pack/format.d.ts.map +1 -1
- package/dist/pack/format.js +344 -33
- package/dist/pack/format.js.map +1 -1
- package/dist/pack/full-generation.d.ts +313 -28
- package/dist/pack/full-generation.d.ts.map +1 -1
- package/dist/pack/full-generation.js +238 -19
- package/dist/pack/full-generation.js.map +1 -1
- package/dist/pack/generation.d.ts +346 -23
- package/dist/pack/generation.d.ts.map +1 -1
- package/dist/pack/generation.js +269 -21
- package/dist/pack/generation.js.map +1 -1
- package/dist/pack/index.d.ts +407 -86
- package/dist/pack/index.d.ts.map +1 -1
- package/dist/pack/index.js +351 -70
- package/dist/pack/index.js.map +1 -1
- package/dist/refs/branch.d.ts +517 -71
- package/dist/refs/branch.d.ts.map +1 -1
- package/dist/refs/branch.js +410 -26
- package/dist/refs/branch.js.map +1 -1
- package/dist/refs/storage.d.ts +610 -57
- package/dist/refs/storage.d.ts.map +1 -1
- package/dist/refs/storage.js +481 -29
- package/dist/refs/storage.js.map +1 -1
- package/dist/refs/tag.d.ts +677 -67
- package/dist/refs/tag.d.ts.map +1 -1
- package/dist/refs/tag.js +497 -30
- package/dist/refs/tag.js.map +1 -1
- package/dist/storage/lru-cache.d.ts +556 -53
- package/dist/storage/lru-cache.d.ts.map +1 -1
- package/dist/storage/lru-cache.js +439 -36
- package/dist/storage/lru-cache.js.map +1 -1
- package/dist/storage/object-index.d.ts +483 -38
- package/dist/storage/object-index.d.ts.map +1 -1
- package/dist/storage/object-index.js +388 -22
- package/dist/storage/object-index.js.map +1 -1
- package/dist/storage/r2-pack.d.ts +957 -94
- package/dist/storage/r2-pack.d.ts.map +1 -1
- package/dist/storage/r2-pack.js +756 -48
- package/dist/storage/r2-pack.js.map +1 -1
- package/dist/tiered/cdc-pipeline.d.ts +1610 -38
- package/dist/tiered/cdc-pipeline.d.ts.map +1 -1
- package/dist/tiered/cdc-pipeline.js +1131 -22
- package/dist/tiered/cdc-pipeline.js.map +1 -1
- package/dist/tiered/migration.d.ts +903 -41
- package/dist/tiered/migration.d.ts.map +1 -1
- package/dist/tiered/migration.js +646 -24
- package/dist/tiered/migration.js.map +1 -1
- package/dist/tiered/parquet-writer.d.ts +944 -47
- package/dist/tiered/parquet-writer.d.ts.map +1 -1
- package/dist/tiered/parquet-writer.js +667 -39
- package/dist/tiered/parquet-writer.js.map +1 -1
- package/dist/tiered/read-path.d.ts +728 -34
- package/dist/tiered/read-path.d.ts.map +1 -1
- package/dist/tiered/read-path.js +310 -27
- package/dist/tiered/read-path.js.map +1 -1
- package/dist/types/objects.d.ts +457 -0
- package/dist/types/objects.d.ts.map +1 -1
- package/dist/types/objects.js +305 -4
- package/dist/types/objects.js.map +1 -1
- package/dist/types/storage.d.ts +407 -35
- package/dist/types/storage.d.ts.map +1 -1
- package/dist/types/storage.js +27 -3
- package/dist/types/storage.js.map +1 -1
- package/dist/utils/hash.d.ts +133 -12
- package/dist/utils/hash.d.ts.map +1 -1
- package/dist/utils/hash.js +133 -12
- package/dist/utils/hash.js.map +1 -1
- package/dist/utils/sha1.d.ts +102 -9
- package/dist/utils/sha1.d.ts.map +1 -1
- package/dist/utils/sha1.js +114 -11
- package/dist/utils/sha1.js.map +1 -1
- package/dist/wire/capabilities.d.ts +896 -88
- package/dist/wire/capabilities.d.ts.map +1 -1
- package/dist/wire/capabilities.js +566 -62
- package/dist/wire/capabilities.js.map +1 -1
- package/dist/wire/pkt-line.d.ts +293 -15
- package/dist/wire/pkt-line.d.ts.map +1 -1
- package/dist/wire/pkt-line.js +251 -15
- package/dist/wire/pkt-line.js.map +1 -1
- package/dist/wire/receive-pack.d.ts +814 -64
- package/dist/wire/receive-pack.d.ts.map +1 -1
- package/dist/wire/receive-pack.js +542 -41
- package/dist/wire/receive-pack.js.map +1 -1
- package/dist/wire/smart-http.d.ts +575 -97
- package/dist/wire/smart-http.d.ts.map +1 -1
- package/dist/wire/smart-http.js +337 -46
- package/dist/wire/smart-http.js.map +1 -1
- package/dist/wire/upload-pack.d.ts +492 -98
- package/dist/wire/upload-pack.d.ts.map +1 -1
- package/dist/wire/upload-pack.js +347 -59
- package/dist/wire/upload-pack.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,333 +1,727 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Git upload-pack
|
|
2
|
+
* @fileoverview Git upload-pack Protocol Implementation
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* objects from a remote repository.
|
|
4
|
+
* This module implements the server-side of Git's upload-pack service, which is
|
|
5
|
+
* used by `git-fetch` and `git-clone` to retrieve objects from a remote repository.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
* 1. Server advertises refs (ref advertisement)
|
|
9
|
-
* 2. Client sends "want" lines for desired objects
|
|
10
|
-
* 3. Client sends "have" lines for objects it already has
|
|
11
|
-
* 4. Server responds with ACK/NAK
|
|
12
|
-
* 5. Server sends packfile with requested objects
|
|
7
|
+
* @module wire/upload-pack
|
|
13
8
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
9
|
+
* ## Protocol Flow
|
|
10
|
+
*
|
|
11
|
+
* 1. **Ref Advertisement**: Server advertises available refs with capabilities
|
|
12
|
+
* 2. **Want Phase**: Client sends "want" lines for objects it needs
|
|
13
|
+
* 3. **Negotiation**: Client sends "have" lines, server responds with ACK/NAK
|
|
14
|
+
* 4. **Done**: Client signals negotiation complete with "done"
|
|
15
|
+
* 5. **Packfile**: Server generates and sends packfile with requested objects
|
|
16
|
+
*
|
|
17
|
+
* ## Features
|
|
18
|
+
*
|
|
19
|
+
* - Side-band multiplexing for progress reporting
|
|
20
|
+
* - Thin pack support for bandwidth efficiency
|
|
21
|
+
* - Shallow clone support with depth limiting
|
|
22
|
+
* - Multi-ack negotiation for optimal object transfer
|
|
23
|
+
*
|
|
24
|
+
* @see {@link https://git-scm.com/docs/protocol-v2} Git Protocol v2
|
|
25
|
+
* @see {@link https://git-scm.com/docs/pack-protocol} Git Pack Protocol
|
|
26
|
+
*
|
|
27
|
+
* @example Basic fetch operation
|
|
28
|
+
* ```typescript
|
|
29
|
+
* import { createSession, advertiseRefs, handleFetch } from './wire/upload-pack'
|
|
30
|
+
*
|
|
31
|
+
* // Create session and advertise refs
|
|
32
|
+
* const session = createSession('my-repo', await store.getRefs())
|
|
33
|
+
* const advertisement = await advertiseRefs(store)
|
|
34
|
+
*
|
|
35
|
+
* // Process fetch request
|
|
36
|
+
* const response = await handleFetch(session, requestBody, store)
|
|
37
|
+
* ```
|
|
16
38
|
*/
|
|
17
39
|
import type { ObjectType } from '../types/objects';
|
|
18
40
|
/**
|
|
19
|
-
* A reference (branch, tag, etc.) with its SHA and optional peeled value
|
|
41
|
+
* A reference (branch, tag, etc.) with its SHA and optional peeled value.
|
|
42
|
+
*
|
|
43
|
+
* @description
|
|
44
|
+
* Represents a Git reference that can be advertised to clients. For annotated
|
|
45
|
+
* tags, the `peeled` field contains the SHA of the underlying commit.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```typescript
|
|
49
|
+
* const branch: Ref = {
|
|
50
|
+
* name: 'refs/heads/main',
|
|
51
|
+
* sha: 'abc123def456...'
|
|
52
|
+
* }
|
|
53
|
+
*
|
|
54
|
+
* const annotatedTag: Ref = {
|
|
55
|
+
* name: 'refs/tags/v1.0.0',
|
|
56
|
+
* sha: 'tag-object-sha...',
|
|
57
|
+
* peeled: 'target-commit-sha...'
|
|
58
|
+
* }
|
|
59
|
+
* ```
|
|
20
60
|
*/
|
|
21
61
|
export interface Ref {
|
|
62
|
+
/** Full ref name (e.g., 'refs/heads/main', 'refs/tags/v1.0.0') */
|
|
22
63
|
name: string;
|
|
64
|
+
/** SHA-1 hash of the object this ref points to */
|
|
23
65
|
sha: string;
|
|
66
|
+
/** For annotated tags, the SHA of the target object (commit) */
|
|
24
67
|
peeled?: string;
|
|
25
68
|
}
|
|
26
69
|
/**
|
|
27
|
-
* Capabilities supported by the upload-pack service
|
|
70
|
+
* Capabilities supported by the upload-pack service.
|
|
71
|
+
*
|
|
72
|
+
* @description
|
|
73
|
+
* These capabilities are advertised to clients and negotiated during the
|
|
74
|
+
* initial handshake. Clients select which capabilities to use based on
|
|
75
|
+
* what the server supports.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```typescript
|
|
79
|
+
* const caps: UploadPackCapabilities = {
|
|
80
|
+
* sideBand64k: true,
|
|
81
|
+
* thinPack: true,
|
|
82
|
+
* shallow: true,
|
|
83
|
+
* includeTag: true,
|
|
84
|
+
* multiAckDetailed: true,
|
|
85
|
+
* agent: 'my-server/1.0'
|
|
86
|
+
* }
|
|
87
|
+
* ```
|
|
28
88
|
*/
|
|
29
89
|
export interface UploadPackCapabilities {
|
|
30
|
-
/** Side-band multiplexing for progress reporting */
|
|
90
|
+
/** Side-band multiplexing for progress reporting (8KB limit) */
|
|
31
91
|
sideBand?: boolean;
|
|
92
|
+
/** Side-band-64k multiplexing (64KB limit, preferred) */
|
|
32
93
|
sideBand64k?: boolean;
|
|
33
94
|
/** Thin pack support - allows deltas against objects client has */
|
|
34
95
|
thinPack?: boolean;
|
|
35
|
-
/** Include tags that point to fetched objects */
|
|
96
|
+
/** Include tags that point to fetched objects automatically */
|
|
36
97
|
includeTag?: boolean;
|
|
37
|
-
/** Shallow clone support */
|
|
98
|
+
/** Shallow clone support (limited history depth) */
|
|
38
99
|
shallow?: boolean;
|
|
39
100
|
/** Deepen relative to current shallow boundary */
|
|
40
101
|
deepenRelative?: boolean;
|
|
41
|
-
/** Don't send
|
|
102
|
+
/** Don't send progress messages */
|
|
42
103
|
noProgress?: boolean;
|
|
43
|
-
/** Object filtering (partial clone) */
|
|
104
|
+
/** Object filtering (partial clone) support */
|
|
44
105
|
filter?: boolean;
|
|
45
|
-
/** Allow fetching reachable SHA-1 not advertised */
|
|
106
|
+
/** Allow fetching reachable SHA-1 not advertised in refs */
|
|
46
107
|
allowReachableSha1InWant?: boolean;
|
|
47
|
-
/** Allow fetching any SHA-1 */
|
|
108
|
+
/** Allow fetching any SHA-1 (dangerous, usually disabled) */
|
|
48
109
|
allowAnySha1InWant?: boolean;
|
|
49
|
-
/** Multi-ack for
|
|
110
|
+
/** Multi-ack for negotiation optimization */
|
|
50
111
|
multiAck?: boolean;
|
|
112
|
+
/** Multi-ack with detailed status */
|
|
51
113
|
multiAckDetailed?: boolean;
|
|
52
114
|
/** Object format (sha1 or sha256) */
|
|
53
115
|
objectFormat?: 'sha1' | 'sha256';
|
|
54
|
-
/**
|
|
116
|
+
/** Server agent identification string */
|
|
55
117
|
agent?: string;
|
|
56
118
|
}
|
|
57
119
|
/**
|
|
58
|
-
* Session state for an upload-pack operation
|
|
120
|
+
* Session state for an upload-pack operation.
|
|
121
|
+
*
|
|
122
|
+
* @description
|
|
123
|
+
* Maintains state across the multi-phase upload-pack protocol. For stateless
|
|
124
|
+
* protocols like HTTP, some state must be reconstructed from each request.
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* ```typescript
|
|
128
|
+
* const session = createSession('my-repo', refs, false)
|
|
129
|
+
* // session.wants, session.haves populated during negotiation
|
|
130
|
+
* // session.negotiationComplete set to true when ready for packfile
|
|
131
|
+
* ```
|
|
59
132
|
*/
|
|
60
133
|
export interface UploadPackSession {
|
|
61
|
-
/** Repository identifier */
|
|
134
|
+
/** Repository identifier for logging/tracking */
|
|
62
135
|
repoId: string;
|
|
63
|
-
/** Advertised references */
|
|
136
|
+
/** Advertised references from the repository */
|
|
64
137
|
refs: Ref[];
|
|
65
|
-
/** Capabilities negotiated with client */
|
|
138
|
+
/** Capabilities negotiated with the client */
|
|
66
139
|
capabilities: UploadPackCapabilities;
|
|
67
|
-
/**
|
|
140
|
+
/** Object SHAs the client wants to receive */
|
|
68
141
|
wants: string[];
|
|
69
|
-
/**
|
|
142
|
+
/** Object SHAs the client already has */
|
|
70
143
|
haves: string[];
|
|
71
|
-
/** Common
|
|
144
|
+
/** Common ancestor commits found during negotiation */
|
|
72
145
|
commonAncestors: string[];
|
|
73
146
|
/** Shallow boundary commits (for shallow clones) */
|
|
74
147
|
shallowCommits: string[];
|
|
75
148
|
/** Depth limit for shallow clone */
|
|
76
149
|
depth?: number;
|
|
77
|
-
/** Deepen-since timestamp */
|
|
150
|
+
/** Deepen-since timestamp for shallow clone */
|
|
78
151
|
deepenSince?: number;
|
|
79
|
-
/**
|
|
152
|
+
/** Refs to exclude when deepening */
|
|
80
153
|
deepenNot?: string[];
|
|
81
|
-
/** Whether negotiation is complete */
|
|
154
|
+
/** Whether negotiation is complete and packfile should be sent */
|
|
82
155
|
negotiationComplete: boolean;
|
|
83
|
-
/** Whether this is a stateless request (HTTP) */
|
|
156
|
+
/** Whether this is a stateless request (HTTP protocol) */
|
|
84
157
|
stateless: boolean;
|
|
85
158
|
}
|
|
86
159
|
/**
|
|
87
|
-
* Result of want/have negotiation
|
|
160
|
+
* Result of want/have negotiation.
|
|
161
|
+
*
|
|
162
|
+
* @description
|
|
163
|
+
* Contains the ACK/NAK responses to send to the client and information
|
|
164
|
+
* about which objects need to be included in the packfile.
|
|
88
165
|
*/
|
|
89
166
|
export interface WantHaveNegotiation {
|
|
90
|
-
/** ACK responses for common objects */
|
|
167
|
+
/** ACK responses for common objects found */
|
|
91
168
|
acks: Array<{
|
|
92
169
|
sha: string;
|
|
93
170
|
status: 'common' | 'ready' | 'continue';
|
|
94
171
|
}>;
|
|
95
|
-
/** Whether server has nothing in common (NAK) */
|
|
172
|
+
/** Whether server has nothing in common with client (NAK) */
|
|
96
173
|
nak: boolean;
|
|
97
|
-
/** Common ancestor commits found */
|
|
174
|
+
/** Common ancestor commits found during negotiation */
|
|
98
175
|
commonAncestors: string[];
|
|
99
|
-
/**
|
|
176
|
+
/** Object SHAs that need to be sent to the client */
|
|
100
177
|
objectsToSend: string[];
|
|
101
178
|
/** Whether negotiation is complete and packfile should be sent */
|
|
102
179
|
ready: boolean;
|
|
103
180
|
}
|
|
104
181
|
/**
|
|
105
|
-
* Side-band channel types
|
|
182
|
+
* Side-band channel types for multiplexed output.
|
|
183
|
+
*
|
|
184
|
+
* @description
|
|
185
|
+
* When side-band is enabled, the server can send data on multiple channels:
|
|
186
|
+
* - Channel 1: Packfile data
|
|
187
|
+
* - Channel 2: Progress messages (displayed to user)
|
|
188
|
+
* - Channel 3: Error messages (fatal, abort transfer)
|
|
106
189
|
*/
|
|
107
190
|
export declare enum SideBandChannel {
|
|
108
|
-
/** Packfile data */
|
|
191
|
+
/** Packfile data - the actual objects being transferred */
|
|
109
192
|
PACK_DATA = 1,
|
|
110
|
-
/** Progress messages */
|
|
193
|
+
/** Progress messages - informational output for the user */
|
|
111
194
|
PROGRESS = 2,
|
|
112
|
-
/** Error messages */
|
|
195
|
+
/** Error messages - fatal errors that abort the transfer */
|
|
113
196
|
ERROR = 3
|
|
114
197
|
}
|
|
115
198
|
/**
|
|
116
|
-
* Progress callback for packfile generation
|
|
199
|
+
* Progress callback for packfile generation.
|
|
200
|
+
*
|
|
201
|
+
* @description
|
|
202
|
+
* Called during packfile generation to report progress. Messages are
|
|
203
|
+
* typically sent via side-band channel 2 to the client.
|
|
204
|
+
*
|
|
205
|
+
* @param message - Progress message to display
|
|
117
206
|
*/
|
|
118
207
|
export type ProgressCallback = (message: string) => void;
|
|
119
208
|
/**
|
|
120
|
-
* Options for packfile generation
|
|
209
|
+
* Options for packfile generation.
|
|
210
|
+
*
|
|
211
|
+
* @description
|
|
212
|
+
* Controls how the packfile is generated, including delta compression
|
|
213
|
+
* settings and progress reporting.
|
|
121
214
|
*/
|
|
122
215
|
export interface PackfileOptions {
|
|
123
216
|
/** Generate thin pack (use deltas against client's objects) */
|
|
124
217
|
thinPack?: boolean;
|
|
125
218
|
/** Include tags pointing to requested objects */
|
|
126
219
|
includeTag?: boolean;
|
|
127
|
-
/** Progress callback */
|
|
220
|
+
/** Progress callback for status updates */
|
|
128
221
|
onProgress?: ProgressCallback;
|
|
129
|
-
/** Objects client already has (for thin pack) */
|
|
222
|
+
/** Objects client already has (for thin pack delta bases) */
|
|
130
223
|
clientHasObjects?: string[];
|
|
131
|
-
/** Maximum delta depth */
|
|
224
|
+
/** Maximum delta chain depth */
|
|
132
225
|
maxDeltaDepth?: number;
|
|
133
|
-
/** Window size for delta compression */
|
|
226
|
+
/** Window size for delta compression algorithm */
|
|
134
227
|
deltaWindowSize?: number;
|
|
135
228
|
}
|
|
136
229
|
/**
|
|
137
|
-
* Result of packfile generation
|
|
230
|
+
* Result of packfile generation.
|
|
231
|
+
*
|
|
232
|
+
* @description
|
|
233
|
+
* Contains the generated packfile along with metadata about what
|
|
234
|
+
* was included.
|
|
138
235
|
*/
|
|
139
236
|
export interface PackfileResult {
|
|
140
|
-
/** The packfile data */
|
|
237
|
+
/** The generated packfile binary data */
|
|
141
238
|
packfile: Uint8Array;
|
|
142
239
|
/** Number of objects in the pack */
|
|
143
240
|
objectCount: number;
|
|
144
|
-
/**
|
|
241
|
+
/** List of object SHAs included in the pack */
|
|
145
242
|
includedObjects: string[];
|
|
146
243
|
}
|
|
147
244
|
/**
|
|
148
|
-
* Object storage interface for retrieving git objects
|
|
245
|
+
* Object storage interface for retrieving git objects.
|
|
246
|
+
*
|
|
247
|
+
* @description
|
|
248
|
+
* Defines the methods required from an object store to support
|
|
249
|
+
* upload-pack operations. Implementations typically wrap a Git
|
|
250
|
+
* object database or similar storage.
|
|
251
|
+
*
|
|
252
|
+
* @example
|
|
253
|
+
* ```typescript
|
|
254
|
+
* class MyObjectStore implements ObjectStore {
|
|
255
|
+
* async getObject(sha: string) {
|
|
256
|
+
* return this.database.get(sha)
|
|
257
|
+
* }
|
|
258
|
+
* async hasObject(sha: string) {
|
|
259
|
+
* return this.database.has(sha)
|
|
260
|
+
* }
|
|
261
|
+
* // ... other methods
|
|
262
|
+
* }
|
|
263
|
+
* ```
|
|
149
264
|
*/
|
|
150
265
|
export interface ObjectStore {
|
|
151
|
-
/**
|
|
266
|
+
/**
|
|
267
|
+
* Get an object by its SHA.
|
|
268
|
+
* @param sha - The SHA-1 hash of the object
|
|
269
|
+
* @returns The object type and data, or null if not found
|
|
270
|
+
*/
|
|
152
271
|
getObject(sha: string): Promise<{
|
|
153
272
|
type: ObjectType;
|
|
154
273
|
data: Uint8Array;
|
|
155
274
|
} | null>;
|
|
156
|
-
/**
|
|
275
|
+
/**
|
|
276
|
+
* Check if an object exists in the store.
|
|
277
|
+
* @param sha - The SHA-1 hash to check
|
|
278
|
+
* @returns true if the object exists
|
|
279
|
+
*/
|
|
157
280
|
hasObject(sha: string): Promise<boolean>;
|
|
158
|
-
/**
|
|
281
|
+
/**
|
|
282
|
+
* Get the parent commit SHAs for a commit.
|
|
283
|
+
* @param sha - The commit SHA
|
|
284
|
+
* @returns Array of parent commit SHAs
|
|
285
|
+
*/
|
|
159
286
|
getCommitParents(sha: string): Promise<string[]>;
|
|
160
|
-
/**
|
|
287
|
+
/**
|
|
288
|
+
* Get all refs in the repository.
|
|
289
|
+
* @returns Array of Ref objects
|
|
290
|
+
*/
|
|
161
291
|
getRefs(): Promise<Ref[]>;
|
|
162
|
-
/**
|
|
292
|
+
/**
|
|
293
|
+
* Get all objects reachable from a given SHA.
|
|
294
|
+
* @param sha - Starting object SHA
|
|
295
|
+
* @param depth - Optional depth limit
|
|
296
|
+
* @returns Array of reachable object SHAs
|
|
297
|
+
*/
|
|
163
298
|
getReachableObjects(sha: string, depth?: number): Promise<string[]>;
|
|
164
299
|
}
|
|
165
300
|
/**
|
|
166
|
-
* Shallow clone
|
|
301
|
+
* Shallow clone information.
|
|
302
|
+
*
|
|
303
|
+
* @description
|
|
304
|
+
* Contains information about shallow boundary changes during
|
|
305
|
+
* fetch operations with depth limiting.
|
|
167
306
|
*/
|
|
168
307
|
export interface ShallowInfo {
|
|
169
|
-
/** Commits at the shallow boundary */
|
|
308
|
+
/** Commits at the new shallow boundary */
|
|
170
309
|
shallowCommits: string[];
|
|
171
|
-
/** Commits that are no longer shallow */
|
|
310
|
+
/** Commits that are no longer shallow (deepened) */
|
|
172
311
|
unshallowCommits: string[];
|
|
173
312
|
}
|
|
174
313
|
/**
|
|
175
|
-
* Build capability string for ref advertisement
|
|
314
|
+
* Build capability string for ref advertisement.
|
|
315
|
+
*
|
|
316
|
+
* @description
|
|
317
|
+
* Converts a capabilities object into a space-separated string suitable
|
|
318
|
+
* for inclusion in the ref advertisement. Boolean capabilities become
|
|
319
|
+
* simple names, while capabilities with values become "name=value".
|
|
176
320
|
*
|
|
177
321
|
* @param capabilities - Capabilities to advertise
|
|
178
322
|
* @returns Space-separated capability string
|
|
323
|
+
*
|
|
324
|
+
* @example
|
|
325
|
+
* ```typescript
|
|
326
|
+
* const caps: UploadPackCapabilities = {
|
|
327
|
+
* sideBand64k: true,
|
|
328
|
+
* thinPack: true,
|
|
329
|
+
* agent: 'my-server/1.0'
|
|
330
|
+
* }
|
|
331
|
+
* const str = buildCapabilityString(caps)
|
|
332
|
+
* // 'side-band-64k thin-pack agent=my-server/1.0'
|
|
333
|
+
* ```
|
|
179
334
|
*/
|
|
180
335
|
export declare function buildCapabilityString(capabilities: UploadPackCapabilities): string;
|
|
181
336
|
/**
|
|
182
|
-
* Parse capabilities from first want line
|
|
337
|
+
* Parse capabilities from first want line.
|
|
338
|
+
*
|
|
339
|
+
* @description
|
|
340
|
+
* Parses a space-separated capability string (typically from the first
|
|
341
|
+
* want line of a fetch request) into a structured capabilities object.
|
|
183
342
|
*
|
|
184
|
-
* @param capsString - Space-separated capabilities
|
|
185
|
-
* @returns Parsed capabilities
|
|
343
|
+
* @param capsString - Space-separated capabilities from client
|
|
344
|
+
* @returns Parsed capabilities object
|
|
345
|
+
*
|
|
346
|
+
* @example
|
|
347
|
+
* ```typescript
|
|
348
|
+
* const caps = parseCapabilities('side-band-64k thin-pack agent=git/2.30.0')
|
|
349
|
+
* // caps.sideBand64k === true
|
|
350
|
+
* // caps.thinPack === true
|
|
351
|
+
* // caps.agent === 'git/2.30.0'
|
|
352
|
+
* ```
|
|
186
353
|
*/
|
|
187
354
|
export declare function parseCapabilities(capsString: string): UploadPackCapabilities;
|
|
188
355
|
/**
|
|
189
|
-
* Create a new upload-pack session
|
|
356
|
+
* Create a new upload-pack session.
|
|
357
|
+
*
|
|
358
|
+
* @description
|
|
359
|
+
* Initializes a new session for an upload-pack operation. The session
|
|
360
|
+
* tracks state across the negotiation and packfile generation phases.
|
|
190
361
|
*
|
|
191
|
-
* @param repoId - Repository identifier
|
|
192
|
-
* @param refs - Available refs
|
|
362
|
+
* @param repoId - Repository identifier for logging/tracking
|
|
363
|
+
* @param refs - Available refs to advertise
|
|
193
364
|
* @param stateless - Whether this is a stateless (HTTP) request
|
|
194
365
|
* @returns New session object
|
|
366
|
+
*
|
|
367
|
+
* @example
|
|
368
|
+
* ```typescript
|
|
369
|
+
* const refs = await store.getRefs()
|
|
370
|
+
* const session = createSession('my-repo', refs, true) // HTTP
|
|
371
|
+
* // session.negotiationComplete === false initially
|
|
372
|
+
* ```
|
|
195
373
|
*/
|
|
196
374
|
export declare function createSession(repoId: string, refs: Ref[], stateless?: boolean): UploadPackSession;
|
|
197
375
|
/**
|
|
198
|
-
* Parse a want line from the client
|
|
376
|
+
* Parse a want line from the client.
|
|
377
|
+
*
|
|
378
|
+
* @description
|
|
379
|
+
* Parses a "want" line which has the format:
|
|
380
|
+
* `want <sha> [capabilities...]`
|
|
199
381
|
*
|
|
200
|
-
*
|
|
382
|
+
* The first want line typically includes capabilities, subsequent ones don't.
|
|
383
|
+
*
|
|
384
|
+
* @param line - The want line (e.g., "want abc123... side-band-64k")
|
|
201
385
|
* @returns Parsed SHA and capabilities
|
|
386
|
+
*
|
|
387
|
+
* @throws {Error} If the line format is invalid or SHA is malformed
|
|
388
|
+
*
|
|
389
|
+
* @example
|
|
390
|
+
* ```typescript
|
|
391
|
+
* // First want line with capabilities
|
|
392
|
+
* const { sha, capabilities } = parseWantLine(
|
|
393
|
+
* 'want abc123... side-band-64k thin-pack'
|
|
394
|
+
* )
|
|
395
|
+
* // sha === 'abc123...'
|
|
396
|
+
* // capabilities.sideBand64k === true
|
|
397
|
+
*
|
|
398
|
+
* // Subsequent want line
|
|
399
|
+
* const { sha: sha2 } = parseWantLine('want def456...')
|
|
400
|
+
* ```
|
|
202
401
|
*/
|
|
203
402
|
export declare function parseWantLine(line: string): {
|
|
204
403
|
sha: string;
|
|
205
404
|
capabilities: UploadPackCapabilities;
|
|
206
405
|
};
|
|
207
406
|
/**
|
|
208
|
-
* Parse a have line from the client
|
|
407
|
+
* Parse a have line from the client.
|
|
408
|
+
*
|
|
409
|
+
* @description
|
|
410
|
+
* Parses a "have" line which has the simple format:
|
|
411
|
+
* `have <sha>`
|
|
412
|
+
*
|
|
413
|
+
* @param line - The have line (e.g., "have abc123...")
|
|
414
|
+
* @returns The parsed SHA
|
|
415
|
+
*
|
|
416
|
+
* @throws {Error} If the line format is invalid or SHA is malformed
|
|
209
417
|
*
|
|
210
|
-
* @
|
|
211
|
-
*
|
|
418
|
+
* @example
|
|
419
|
+
* ```typescript
|
|
420
|
+
* const sha = parseHaveLine('have abc123def456...')
|
|
421
|
+
* // sha === 'abc123def456...'
|
|
422
|
+
* ```
|
|
212
423
|
*/
|
|
213
424
|
export declare function parseHaveLine(line: string): string;
|
|
214
425
|
/**
|
|
215
|
-
* Advertise refs to the client
|
|
426
|
+
* Advertise refs to the client.
|
|
427
|
+
*
|
|
428
|
+
* @description
|
|
429
|
+
* Generates the ref advertisement response for the initial phase of
|
|
430
|
+
* upload-pack. This includes:
|
|
431
|
+
* - HEAD reference with capabilities
|
|
432
|
+
* - Sorted refs with symref information
|
|
433
|
+
* - Peeled refs for annotated tags
|
|
216
434
|
*
|
|
217
435
|
* @param store - Object store to get refs from
|
|
218
|
-
* @param capabilities -
|
|
436
|
+
* @param capabilities - Optional server capabilities to advertise
|
|
219
437
|
* @returns Pkt-line formatted ref advertisement
|
|
438
|
+
*
|
|
439
|
+
* @example
|
|
440
|
+
* ```typescript
|
|
441
|
+
* const advertisement = await advertiseRefs(store, {
|
|
442
|
+
* sideBand64k: true,
|
|
443
|
+
* thinPack: true
|
|
444
|
+
* })
|
|
445
|
+
* // Send as response to GET /info/refs?service=git-upload-pack
|
|
446
|
+
* ```
|
|
220
447
|
*/
|
|
221
448
|
export declare function advertiseRefs(store: ObjectStore, capabilities?: Partial<UploadPackCapabilities>): Promise<string>;
|
|
222
449
|
/**
|
|
223
|
-
* Format an ACK response
|
|
450
|
+
* Format an ACK response.
|
|
451
|
+
*
|
|
452
|
+
* @description
|
|
453
|
+
* Creates a pkt-line formatted ACK response for negotiation:
|
|
454
|
+
* - Simple ACK: `ACK <sha>` (when negotiation is complete)
|
|
455
|
+
* - Status ACK: `ACK <sha> <status>` (during multi_ack negotiation)
|
|
224
456
|
*
|
|
225
457
|
* @param sha - The SHA being acknowledged
|
|
226
458
|
* @param status - ACK status (common, ready, continue, or none for simple ACK)
|
|
227
459
|
* @returns Pkt-line formatted ACK
|
|
460
|
+
*
|
|
461
|
+
* @example
|
|
462
|
+
* ```typescript
|
|
463
|
+
* // Simple ACK
|
|
464
|
+
* const ack = formatAck('abc123...')
|
|
465
|
+
* // '0014ACK abc123...\n'
|
|
466
|
+
*
|
|
467
|
+
* // Multi-ack with status
|
|
468
|
+
* const ackContinue = formatAck('abc123...', 'continue')
|
|
469
|
+
* // '001dACK abc123... continue\n'
|
|
470
|
+
* ```
|
|
228
471
|
*/
|
|
229
472
|
export declare function formatAck(sha: string, status?: 'common' | 'ready' | 'continue'): string;
|
|
230
473
|
/**
|
|
231
|
-
* Format a NAK response
|
|
474
|
+
* Format a NAK response.
|
|
475
|
+
*
|
|
476
|
+
* @description
|
|
477
|
+
* Creates a pkt-line formatted NAK response. NAK indicates that the
|
|
478
|
+
* server has no objects in common with the client's "have" list.
|
|
232
479
|
*
|
|
233
480
|
* @returns Pkt-line formatted NAK
|
|
481
|
+
*
|
|
482
|
+
* @example
|
|
483
|
+
* ```typescript
|
|
484
|
+
* const nak = formatNak()
|
|
485
|
+
* // '0008NAK\n'
|
|
486
|
+
* ```
|
|
234
487
|
*/
|
|
235
488
|
export declare function formatNak(): string;
|
|
236
489
|
/**
|
|
237
|
-
* Process client wants and update session
|
|
490
|
+
* Process client wants and update session.
|
|
491
|
+
*
|
|
492
|
+
* @description
|
|
493
|
+
* Validates and processes the "want" SHAs from a client fetch request.
|
|
494
|
+
* Verifies that all wanted objects exist in the repository.
|
|
238
495
|
*
|
|
239
496
|
* @param session - Current session state
|
|
240
|
-
* @param wants - Array of want SHAs
|
|
497
|
+
* @param wants - Array of want SHAs from the client
|
|
241
498
|
* @param store - Object store to verify objects exist
|
|
242
499
|
* @returns Updated session
|
|
500
|
+
*
|
|
501
|
+
* @throws {Error} If any wanted object doesn't exist
|
|
502
|
+
*
|
|
503
|
+
* @example
|
|
504
|
+
* ```typescript
|
|
505
|
+
* const session = createSession('repo', refs)
|
|
506
|
+
* await processWants(session, ['abc123...', 'def456...'], store)
|
|
507
|
+
* // session.wants now contains the validated wants
|
|
508
|
+
* ```
|
|
243
509
|
*/
|
|
244
510
|
export declare function processWants(session: UploadPackSession, wants: string[], store: ObjectStore): Promise<UploadPackSession>;
|
|
245
511
|
/**
|
|
246
|
-
* Process client haves and perform negotiation
|
|
512
|
+
* Process client haves and perform negotiation.
|
|
513
|
+
*
|
|
514
|
+
* @description
|
|
515
|
+
* Processes the "have" SHAs from the client to find common ancestors.
|
|
516
|
+
* This determines which objects need to be sent vs which the client
|
|
517
|
+
* already has.
|
|
247
518
|
*
|
|
248
519
|
* @param session - Current session state
|
|
249
|
-
* @param haves - Array of have SHAs
|
|
520
|
+
* @param haves - Array of have SHAs from the client
|
|
250
521
|
* @param store - Object store to check for common objects
|
|
251
522
|
* @param done - Whether client is done sending haves
|
|
252
|
-
* @returns Negotiation result
|
|
523
|
+
* @returns Negotiation result with ACKs/NAKs and objects to send
|
|
524
|
+
*
|
|
525
|
+
* @example
|
|
526
|
+
* ```typescript
|
|
527
|
+
* const result = await processHaves(session, ['abc123...'], store, true)
|
|
528
|
+
* if (result.nak) {
|
|
529
|
+
* // No common objects, will send full pack
|
|
530
|
+
* } else {
|
|
531
|
+
* // Can send incremental pack
|
|
532
|
+
* }
|
|
533
|
+
* ```
|
|
253
534
|
*/
|
|
254
535
|
export declare function processHaves(session: UploadPackSession, haves: string[], store: ObjectStore, done: boolean): Promise<WantHaveNegotiation>;
|
|
255
536
|
/**
|
|
256
|
-
* Calculate objects needed by client
|
|
537
|
+
* Calculate objects needed by client.
|
|
257
538
|
*
|
|
258
|
-
*
|
|
539
|
+
* @description
|
|
540
|
+
* Given the client's wants and haves, determines the minimal set of
|
|
541
|
+
* objects that need to be sent. Walks the object graph from wants,
|
|
542
|
+
* stopping at objects the client already has.
|
|
259
543
|
*
|
|
260
544
|
* @param store - Object store
|
|
261
545
|
* @param wants - Objects client wants
|
|
262
546
|
* @param haves - Objects client has
|
|
263
547
|
* @returns Set of object SHAs to include in packfile
|
|
548
|
+
*
|
|
549
|
+
* @example
|
|
550
|
+
* ```typescript
|
|
551
|
+
* const missing = await calculateMissingObjects(
|
|
552
|
+
* store,
|
|
553
|
+
* ['new-commit-sha'],
|
|
554
|
+
* ['old-commit-sha']
|
|
555
|
+
* )
|
|
556
|
+
* // missing contains only objects reachable from new-commit
|
|
557
|
+
* // but not reachable from old-commit
|
|
558
|
+
* ```
|
|
264
559
|
*/
|
|
265
560
|
export declare function calculateMissingObjects(store: ObjectStore, wants: string[], haves: string[]): Promise<Set<string>>;
|
|
266
561
|
/**
|
|
267
|
-
* Process shallow/deepen commands
|
|
562
|
+
* Process shallow/deepen commands.
|
|
563
|
+
*
|
|
564
|
+
* @description
|
|
565
|
+
* Handles shallow clone requests by processing depth limits, deepen-since
|
|
566
|
+
* timestamps, and deepen-not refs. Updates the session with shallow
|
|
567
|
+
* boundary information.
|
|
268
568
|
*
|
|
269
569
|
* @param session - Current session
|
|
270
570
|
* @param shallowLines - Shallow commit lines from client
|
|
271
|
-
* @param depth - Requested depth
|
|
571
|
+
* @param depth - Requested commit depth
|
|
272
572
|
* @param deepenSince - Timestamp to deepen since
|
|
273
573
|
* @param deepenNot - Refs to not deepen past
|
|
274
574
|
* @param store - Object store
|
|
275
575
|
* @returns Shallow info with boundary commits
|
|
576
|
+
*
|
|
577
|
+
* @example
|
|
578
|
+
* ```typescript
|
|
579
|
+
* const shallowInfo = await processShallow(
|
|
580
|
+
* session,
|
|
581
|
+
* [], // No previous shallow commits
|
|
582
|
+
* 3, // Depth of 3 commits
|
|
583
|
+
* undefined,
|
|
584
|
+
* undefined,
|
|
585
|
+
* store
|
|
586
|
+
* )
|
|
587
|
+
* // shallowInfo.shallowCommits contains boundary commits
|
|
588
|
+
* ```
|
|
276
589
|
*/
|
|
277
590
|
export declare function processShallow(session: UploadPackSession, shallowLines: string[], depth?: number, deepenSince?: number, deepenNot?: string[], store?: ObjectStore): Promise<ShallowInfo>;
|
|
278
591
|
/**
|
|
279
|
-
* Format shallow/unshallow lines for response
|
|
592
|
+
* Format shallow/unshallow lines for response.
|
|
593
|
+
*
|
|
594
|
+
* @description
|
|
595
|
+
* Creates pkt-line formatted shallow/unshallow responses to send
|
|
596
|
+
* to the client before the packfile.
|
|
280
597
|
*
|
|
281
598
|
* @param shallowInfo - Shallow info to format
|
|
282
599
|
* @returns Pkt-line formatted shallow response
|
|
600
|
+
*
|
|
601
|
+
* @example
|
|
602
|
+
* ```typescript
|
|
603
|
+
* const response = formatShallowResponse({
|
|
604
|
+
* shallowCommits: ['abc123...'],
|
|
605
|
+
* unshallowCommits: []
|
|
606
|
+
* })
|
|
607
|
+
* // '001cshallow abc123...\n'
|
|
608
|
+
* ```
|
|
283
609
|
*/
|
|
284
610
|
export declare function formatShallowResponse(shallowInfo: ShallowInfo): string;
|
|
285
611
|
/**
|
|
286
|
-
* Wrap data in side-band format
|
|
612
|
+
* Wrap data in side-band format.
|
|
613
|
+
*
|
|
614
|
+
* @description
|
|
615
|
+
* Wraps data in side-band format for multiplexed transmission.
|
|
616
|
+
* The format is: pkt-line length + channel byte + data
|
|
287
617
|
*
|
|
288
618
|
* @param channel - Side-band channel (1=data, 2=progress, 3=error)
|
|
289
619
|
* @param data - Data to wrap
|
|
290
620
|
* @returns Pkt-line formatted side-band data
|
|
621
|
+
*
|
|
622
|
+
* @example
|
|
623
|
+
* ```typescript
|
|
624
|
+
* // Wrap packfile data for channel 1
|
|
625
|
+
* const wrapped = wrapSideBand(SideBandChannel.PACK_DATA, packfile)
|
|
626
|
+
*
|
|
627
|
+
* // Wrap progress message for channel 2
|
|
628
|
+
* const progress = wrapSideBand(
|
|
629
|
+
* SideBandChannel.PROGRESS,
|
|
630
|
+
* encoder.encode('Counting objects: 100%\n')
|
|
631
|
+
* )
|
|
632
|
+
* ```
|
|
291
633
|
*/
|
|
292
634
|
export declare function wrapSideBand(channel: SideBandChannel, data: Uint8Array): Uint8Array;
|
|
293
635
|
/**
|
|
294
|
-
* Send progress message via side-band
|
|
636
|
+
* Send progress message via side-band.
|
|
295
637
|
*
|
|
296
|
-
* @
|
|
638
|
+
* @description
|
|
639
|
+
* Creates a side-band channel 2 message for progress reporting.
|
|
640
|
+
* Messages are displayed to the user during fetch operations.
|
|
641
|
+
*
|
|
642
|
+
* @param message - Progress message (newline added if not present)
|
|
297
643
|
* @returns Pkt-line formatted progress message
|
|
644
|
+
*
|
|
645
|
+
* @example
|
|
646
|
+
* ```typescript
|
|
647
|
+
* const progress = formatProgress('Counting objects: 42')
|
|
648
|
+
* // Side-band channel 2 packet with the message
|
|
649
|
+
* ```
|
|
298
650
|
*/
|
|
299
651
|
export declare function formatProgress(message: string): Uint8Array;
|
|
300
652
|
/**
|
|
301
|
-
* Generate a packfile containing the requested objects
|
|
653
|
+
* Generate a packfile containing the requested objects.
|
|
654
|
+
*
|
|
655
|
+
* @description
|
|
656
|
+
* Creates a Git packfile containing all objects needed by the client.
|
|
657
|
+
* The packfile format includes:
|
|
658
|
+
* - 12-byte header (PACK + version + object count)
|
|
659
|
+
* - Compressed objects with type/size headers
|
|
660
|
+
* - 20-byte SHA-1 checksum
|
|
302
661
|
*
|
|
303
662
|
* @param store - Object store to get objects from
|
|
304
663
|
* @param wants - Objects the client wants
|
|
305
664
|
* @param haves - Objects the client already has
|
|
306
665
|
* @param options - Packfile generation options
|
|
307
|
-
* @returns Packfile result
|
|
666
|
+
* @returns Packfile result with binary data and metadata
|
|
667
|
+
*
|
|
668
|
+
* @example
|
|
669
|
+
* ```typescript
|
|
670
|
+
* const result = await generatePackfile(
|
|
671
|
+
* store,
|
|
672
|
+
* ['commit-sha-1', 'commit-sha-2'],
|
|
673
|
+
* ['base-commit-sha'],
|
|
674
|
+
* { thinPack: true, onProgress: console.log }
|
|
675
|
+
* )
|
|
676
|
+
* // result.packfile contains the binary packfile
|
|
677
|
+
* // result.objectCount is the number of objects
|
|
678
|
+
* ```
|
|
308
679
|
*/
|
|
309
680
|
export declare function generatePackfile(store: ObjectStore, wants: string[], haves: string[], options?: PackfileOptions): Promise<PackfileResult>;
|
|
310
681
|
/**
|
|
311
|
-
* Generate thin pack with deltas against client's objects
|
|
682
|
+
* Generate thin pack with deltas against client's objects.
|
|
683
|
+
*
|
|
684
|
+
* @description
|
|
685
|
+
* Creates a thin pack that can use objects the client already has
|
|
686
|
+
* as delta bases, resulting in smaller transfer sizes.
|
|
312
687
|
*
|
|
313
688
|
* @param store - Object store
|
|
314
689
|
* @param objects - Objects to include
|
|
315
690
|
* @param clientHasObjects - Objects client already has (for delta bases)
|
|
316
691
|
* @returns Thin packfile
|
|
692
|
+
*
|
|
693
|
+
* @example
|
|
694
|
+
* ```typescript
|
|
695
|
+
* const result = await generateThinPack(
|
|
696
|
+
* store,
|
|
697
|
+
* ['new-blob-sha'],
|
|
698
|
+
* ['similar-blob-sha'] // Client has this, can be delta base
|
|
699
|
+
* )
|
|
700
|
+
* ```
|
|
317
701
|
*/
|
|
318
702
|
export declare function generateThinPack(store: ObjectStore, objects: string[], clientHasObjects: string[]): Promise<PackfileResult>;
|
|
319
703
|
/**
|
|
320
|
-
* Handle a complete fetch request
|
|
704
|
+
* Handle a complete fetch request.
|
|
321
705
|
*
|
|
322
|
-
*
|
|
323
|
-
*
|
|
324
|
-
*
|
|
325
|
-
*
|
|
706
|
+
* @description
|
|
707
|
+
* This is the main entry point that handles the full upload-pack protocol flow:
|
|
708
|
+
* 1. Parse client request (wants, haves, capabilities, shallow commands)
|
|
709
|
+
* 2. Negotiate common ancestors via ACK/NAK
|
|
710
|
+
* 3. Generate and return packfile with requested objects
|
|
326
711
|
*
|
|
327
712
|
* @param session - Upload pack session
|
|
328
|
-
* @param request - Raw request data
|
|
713
|
+
* @param request - Raw request data (pkt-line formatted)
|
|
329
714
|
* @param store - Object store
|
|
330
715
|
* @returns Response data (ACKs/NAKs + packfile)
|
|
716
|
+
*
|
|
717
|
+
* @example
|
|
718
|
+
* ```typescript
|
|
719
|
+
* const session = createSession('repo', refs)
|
|
720
|
+
* const requestBody = '0032want abc123... side-band-64k\n00000009done\n'
|
|
721
|
+
*
|
|
722
|
+
* const response = await handleFetch(session, requestBody, store)
|
|
723
|
+
* // response contains NAK + packfile data
|
|
724
|
+
* ```
|
|
331
725
|
*/
|
|
332
726
|
export declare function handleFetch(session: UploadPackSession, request: string, store: ObjectStore): Promise<Uint8Array>;
|
|
333
727
|
//# sourceMappingURL=upload-pack.d.ts.map
|