gitx.do 0.0.1 → 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 +10 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/refs/storage.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/refs/storage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAMH;;;;;;GAMG;AACH,MAAM,MAAM,OAAO,GAAG,QAAQ,GAAG,UAAU,CAAA;AAE3C;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,WAAW,GAAG;IAClB,sDAAsD;IACtD,IAAI,EAAE,MAAM,CAAA;IACZ,sEAAsE;I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AAE,UAAU,EACnB,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,gBAAgB,GACzB,OAAO,CAAC,OAAO,CAAC,CAElB;AAED;;;;;;;;;GASG;AACH,wBAAsB,QAAQ,CAC5B,OAAO,EAAE,UAAU,EACnB,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,GAAG,EAAE,CAAC,CAEhB"}
|
package/dist/refs/storage.js
CHANGED
|
@@ -1,15 +1,68 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Git Reference Storage
|
|
2
|
+
* @fileoverview Git Reference Storage System
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* This module provides a complete implementation of Git reference management,
|
|
5
|
+
* including branches, tags, HEAD, and symbolic refs. It supports both loose refs
|
|
6
|
+
* (individual files) and packed refs (consolidated file).
|
|
7
|
+
*
|
|
8
|
+
* **Key Concepts**:
|
|
9
|
+
* - **Direct refs**: Point directly to a SHA-1 hash (e.g., branch pointing to commit)
|
|
10
|
+
* - **Symbolic refs**: Point to another ref (e.g., HEAD -> refs/heads/main)
|
|
11
|
+
* - **Loose refs**: Individual ref files in .git/refs/
|
|
12
|
+
* - **Packed refs**: Consolidated refs in .git/packed-refs for efficiency
|
|
13
|
+
*
|
|
14
|
+
* @module refs/storage
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* import { RefStorage, isValidRefName, isValidSha } from './refs/storage'
|
|
19
|
+
*
|
|
20
|
+
* // Create storage with backend
|
|
21
|
+
* const storage = new RefStorage(backend)
|
|
22
|
+
*
|
|
23
|
+
* // Resolve HEAD to get current commit
|
|
24
|
+
* const resolved = await storage.resolveRef('HEAD')
|
|
25
|
+
* console.log(`Current commit: ${resolved.sha}`)
|
|
26
|
+
*
|
|
27
|
+
* // Update a branch
|
|
28
|
+
* await storage.updateRef('refs/heads/feature', newCommitSha, { create: true })
|
|
29
|
+
*
|
|
30
|
+
* // List all branches
|
|
31
|
+
* const branches = await storage.listBranches()
|
|
32
|
+
* ```
|
|
6
33
|
*/
|
|
7
34
|
/**
|
|
8
|
-
* Error thrown when a ref operation fails
|
|
35
|
+
* Error thrown when a ref operation fails.
|
|
36
|
+
*
|
|
37
|
+
* @description
|
|
38
|
+
* Provides structured error information including error code
|
|
39
|
+
* and the ref name that caused the error.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* try {
|
|
44
|
+
* await storage.updateRef('refs/heads/main', sha)
|
|
45
|
+
* } catch (e) {
|
|
46
|
+
* if (e instanceof RefError) {
|
|
47
|
+
* switch (e.code) {
|
|
48
|
+
* case 'NOT_FOUND': // Ref doesn't exist
|
|
49
|
+
* case 'CONFLICT': // CAS failed
|
|
50
|
+
* case 'LOCKED': // Ref is locked
|
|
51
|
+
* }
|
|
52
|
+
* }
|
|
53
|
+
* }
|
|
54
|
+
* ```
|
|
9
55
|
*/
|
|
10
56
|
export class RefError extends Error {
|
|
11
57
|
code;
|
|
12
58
|
refName;
|
|
59
|
+
/**
|
|
60
|
+
* Create a new RefError.
|
|
61
|
+
*
|
|
62
|
+
* @param message - Human-readable error message
|
|
63
|
+
* @param code - Error code for programmatic handling
|
|
64
|
+
* @param refName - The ref that caused the error (optional)
|
|
65
|
+
*/
|
|
13
66
|
constructor(message, code, refName) {
|
|
14
67
|
super(message);
|
|
15
68
|
this.code = code;
|
|
@@ -17,9 +70,37 @@ export class RefError extends Error {
|
|
|
17
70
|
this.name = 'RefError';
|
|
18
71
|
}
|
|
19
72
|
}
|
|
73
|
+
// ============================================================================
|
|
74
|
+
// Validation Functions
|
|
75
|
+
// ============================================================================
|
|
20
76
|
/**
|
|
21
|
-
* Validate a ref name according to Git rules
|
|
22
|
-
*
|
|
77
|
+
* Validate a ref name according to Git rules.
|
|
78
|
+
*
|
|
79
|
+
* @description
|
|
80
|
+
* Git has specific rules for valid ref names. This function implements
|
|
81
|
+
* the validation from `git check-ref-format`.
|
|
82
|
+
*
|
|
83
|
+
* **Rules**:
|
|
84
|
+
* - Cannot be empty or just '@'
|
|
85
|
+
* - Cannot end with '/' or '.lock'
|
|
86
|
+
* - Cannot contain '..', '@{', control chars, space, ~, ^, :, ?, *, [, \
|
|
87
|
+
* - Components cannot start or end with '.'
|
|
88
|
+
* - HEAD is always valid
|
|
89
|
+
*
|
|
90
|
+
* @param name - Ref name to validate
|
|
91
|
+
* @returns True if the name is valid
|
|
92
|
+
*
|
|
93
|
+
* @see https://git-scm.com/docs/git-check-ref-format
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* ```typescript
|
|
97
|
+
* isValidRefName('refs/heads/main') // true
|
|
98
|
+
* isValidRefName('refs/heads/feature/x') // true
|
|
99
|
+
* isValidRefName('HEAD') // true
|
|
100
|
+
* isValidRefName('refs/heads/../main') // false (contains ..)
|
|
101
|
+
* isValidRefName('refs/heads/.hidden') // false (component starts with .)
|
|
102
|
+
* isValidRefName('refs/heads/foo.lock') // false (ends with .lock)
|
|
103
|
+
* ```
|
|
23
104
|
*/
|
|
24
105
|
export function isValidRefName(name) {
|
|
25
106
|
// HEAD is always valid
|
|
@@ -74,7 +155,22 @@ export function isValidRefName(name) {
|
|
|
74
155
|
return true;
|
|
75
156
|
}
|
|
76
157
|
/**
|
|
77
|
-
* Validate a SHA-1 hash
|
|
158
|
+
* Validate a SHA-1 hash string.
|
|
159
|
+
*
|
|
160
|
+
* @description
|
|
161
|
+
* SHA-1 hashes must be exactly 40 hexadecimal characters.
|
|
162
|
+
* This validates the format, not whether the object exists.
|
|
163
|
+
*
|
|
164
|
+
* @param sha - SHA string to validate
|
|
165
|
+
* @returns True if the string is a valid SHA-1 format
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* ```typescript
|
|
169
|
+
* isValidSha('abc123def456789...') // true (if 40 hex chars)
|
|
170
|
+
* isValidSha('abc123') // false (too short)
|
|
171
|
+
* isValidSha('xyz...') // false (invalid hex)
|
|
172
|
+
* isValidSha(null) // false
|
|
173
|
+
* ```
|
|
78
174
|
*/
|
|
79
175
|
export function isValidSha(sha) {
|
|
80
176
|
// Must be exactly 40 characters
|
|
@@ -84,8 +180,28 @@ export function isValidSha(sha) {
|
|
|
84
180
|
// Must be valid hex
|
|
85
181
|
return /^[0-9a-fA-F]{40}$/.test(sha);
|
|
86
182
|
}
|
|
183
|
+
// ============================================================================
|
|
184
|
+
// Parsing and Serialization Functions
|
|
185
|
+
// ============================================================================
|
|
87
186
|
/**
|
|
88
|
-
* Parse
|
|
187
|
+
* Parse ref file content into type and target.
|
|
188
|
+
*
|
|
189
|
+
* @description
|
|
190
|
+
* Ref files either contain a SHA directly or "ref: <target>" for symbolic refs.
|
|
191
|
+
*
|
|
192
|
+
* @param content - Raw ref file content
|
|
193
|
+
* @returns Parsed type and target
|
|
194
|
+
*
|
|
195
|
+
* @example
|
|
196
|
+
* ```typescript
|
|
197
|
+
* // Direct ref
|
|
198
|
+
* parseRefContent('abc123def456...\n')
|
|
199
|
+
* // => { type: 'direct', target: 'abc123def456...' }
|
|
200
|
+
*
|
|
201
|
+
* // Symbolic ref
|
|
202
|
+
* parseRefContent('ref: refs/heads/main\n')
|
|
203
|
+
* // => { type: 'symbolic', target: 'refs/heads/main' }
|
|
204
|
+
* ```
|
|
89
205
|
*/
|
|
90
206
|
export function parseRefContent(content) {
|
|
91
207
|
const trimmed = content.trim();
|
|
@@ -98,7 +214,22 @@ export function parseRefContent(content) {
|
|
|
98
214
|
return { type: 'direct', target: trimmed };
|
|
99
215
|
}
|
|
100
216
|
/**
|
|
101
|
-
* Serialize a ref to file content
|
|
217
|
+
* Serialize a ref to file content format.
|
|
218
|
+
*
|
|
219
|
+
* @description
|
|
220
|
+
* Converts a Ref object to the string format stored in ref files.
|
|
221
|
+
*
|
|
222
|
+
* @param ref - Ref to serialize
|
|
223
|
+
* @returns File content string (with trailing newline)
|
|
224
|
+
*
|
|
225
|
+
* @example
|
|
226
|
+
* ```typescript
|
|
227
|
+
* serializeRefContent({ name: 'HEAD', target: 'refs/heads/main', type: 'symbolic' })
|
|
228
|
+
* // => 'ref: refs/heads/main\n'
|
|
229
|
+
*
|
|
230
|
+
* serializeRefContent({ name: 'refs/heads/main', target: 'abc123...', type: 'direct' })
|
|
231
|
+
* // => 'abc123...\n'
|
|
232
|
+
* ```
|
|
102
233
|
*/
|
|
103
234
|
export function serializeRefContent(ref) {
|
|
104
235
|
if (ref.type === 'symbolic') {
|
|
@@ -107,7 +238,26 @@ export function serializeRefContent(ref) {
|
|
|
107
238
|
return `${ref.target}\n`;
|
|
108
239
|
}
|
|
109
240
|
/**
|
|
110
|
-
* Parse packed-refs file content
|
|
241
|
+
* Parse packed-refs file content.
|
|
242
|
+
*
|
|
243
|
+
* @description
|
|
244
|
+
* The packed-refs file contains multiple refs in a space-efficient format.
|
|
245
|
+
* Format: "<sha> <refname>" on each line, with optional comments (#) and
|
|
246
|
+
* peeled entries (^sha for annotated tags).
|
|
247
|
+
*
|
|
248
|
+
* @param content - Raw packed-refs file content
|
|
249
|
+
* @returns Map of ref names to SHA values
|
|
250
|
+
*
|
|
251
|
+
* @example
|
|
252
|
+
* ```typescript
|
|
253
|
+
* const content = `# pack-refs with: peeled fully-peeled sorted
|
|
254
|
+
* abc123 refs/heads/main
|
|
255
|
+
* def456 refs/tags/v1.0.0
|
|
256
|
+
* ^aaa111
|
|
257
|
+
* `
|
|
258
|
+
* const refs = parsePackedRefs(content)
|
|
259
|
+
* // Map { 'refs/heads/main' => 'abc123', 'refs/tags/v1.0.0' => 'def456' }
|
|
260
|
+
* ```
|
|
111
261
|
*/
|
|
112
262
|
export function parsePackedRefs(content) {
|
|
113
263
|
const refs = new Map();
|
|
@@ -140,7 +290,24 @@ export function parsePackedRefs(content) {
|
|
|
140
290
|
return refs;
|
|
141
291
|
}
|
|
142
292
|
/**
|
|
143
|
-
* Serialize refs to packed-refs format
|
|
293
|
+
* Serialize refs to packed-refs file format.
|
|
294
|
+
*
|
|
295
|
+
* @description
|
|
296
|
+
* Creates the content for a packed-refs file from a map of refs.
|
|
297
|
+
* Refs are sorted alphabetically for consistency.
|
|
298
|
+
*
|
|
299
|
+
* @param refs - Map of ref names to SHA values
|
|
300
|
+
* @returns Packed-refs file content
|
|
301
|
+
*
|
|
302
|
+
* @example
|
|
303
|
+
* ```typescript
|
|
304
|
+
* const refs = new Map([
|
|
305
|
+
* ['refs/heads/main', 'abc123...'],
|
|
306
|
+
* ['refs/tags/v1.0.0', 'def456...']
|
|
307
|
+
* ])
|
|
308
|
+
* const content = serializePackedRefs(refs)
|
|
309
|
+
* // '# pack-refs with: peeled fully-peeled sorted\nabc123... refs/heads/main\n...'
|
|
310
|
+
* ```
|
|
144
311
|
*/
|
|
145
312
|
export function serializePackedRefs(refs) {
|
|
146
313
|
const lines = ['# pack-refs with: peeled fully-peeled sorted'];
|
|
@@ -151,16 +318,62 @@ export function serializePackedRefs(refs) {
|
|
|
151
318
|
}
|
|
152
319
|
return lines.join('\n') + '\n';
|
|
153
320
|
}
|
|
321
|
+
// ============================================================================
|
|
322
|
+
// RefStorage Class
|
|
323
|
+
// ============================================================================
|
|
154
324
|
/**
|
|
155
|
-
*
|
|
325
|
+
* Reference storage manager.
|
|
326
|
+
*
|
|
327
|
+
* @description
|
|
328
|
+
* Provides a high-level API for managing Git references. Handles ref
|
|
329
|
+
* resolution, updates with locking, symbolic refs, and packed refs.
|
|
330
|
+
*
|
|
331
|
+
* @example
|
|
332
|
+
* ```typescript
|
|
333
|
+
* const storage = new RefStorage(myBackend)
|
|
334
|
+
*
|
|
335
|
+
* // Get current branch
|
|
336
|
+
* const head = await storage.getHead()
|
|
337
|
+
* if (head.type === 'symbolic') {
|
|
338
|
+
* console.log(`On branch: ${head.target}`)
|
|
339
|
+
* }
|
|
340
|
+
*
|
|
341
|
+
* // Resolve to SHA
|
|
342
|
+
* const resolved = await storage.resolveRef('HEAD')
|
|
343
|
+
* console.log(`Current commit: ${resolved.sha}`)
|
|
344
|
+
*
|
|
345
|
+
* // Create a branch
|
|
346
|
+
* await storage.updateRef('refs/heads/feature', commitSha, { create: true })
|
|
347
|
+
* ```
|
|
156
348
|
*/
|
|
157
349
|
export class RefStorage {
|
|
158
350
|
backend;
|
|
351
|
+
/**
|
|
352
|
+
* Create a new RefStorage instance.
|
|
353
|
+
*
|
|
354
|
+
* @param backend - Storage backend for persistence
|
|
355
|
+
*/
|
|
159
356
|
constructor(backend) {
|
|
160
357
|
this.backend = backend;
|
|
161
358
|
}
|
|
162
359
|
/**
|
|
163
|
-
* Get a ref by name
|
|
360
|
+
* Get a ref by name.
|
|
361
|
+
*
|
|
362
|
+
* @description
|
|
363
|
+
* Retrieves a ref without resolving symbolic refs.
|
|
364
|
+
* Use `resolveRef` to follow symbolic refs to their final target.
|
|
365
|
+
*
|
|
366
|
+
* @param name - Full ref name
|
|
367
|
+
* @returns The ref or null if not found
|
|
368
|
+
* @throws Error if backend doesn't support readRef
|
|
369
|
+
*
|
|
370
|
+
* @example
|
|
371
|
+
* ```typescript
|
|
372
|
+
* const head = await storage.getRef('HEAD')
|
|
373
|
+
* if (head && head.type === 'symbolic') {
|
|
374
|
+
* console.log(`HEAD points to ${head.target}`)
|
|
375
|
+
* }
|
|
376
|
+
* ```
|
|
164
377
|
*/
|
|
165
378
|
async getRef(name) {
|
|
166
379
|
if (!this.backend.readRef) {
|
|
@@ -169,7 +382,26 @@ export class RefStorage {
|
|
|
169
382
|
return this.backend.readRef(name);
|
|
170
383
|
}
|
|
171
384
|
/**
|
|
172
|
-
* Resolve a ref to its final SHA target
|
|
385
|
+
* Resolve a ref to its final SHA target.
|
|
386
|
+
*
|
|
387
|
+
* @description
|
|
388
|
+
* Follows symbolic refs until reaching a direct ref, then returns
|
|
389
|
+
* the SHA and the chain of refs followed.
|
|
390
|
+
*
|
|
391
|
+
* @param name - Ref name to resolve
|
|
392
|
+
* @param options - Resolution options (maxDepth)
|
|
393
|
+
* @returns Resolved ref with SHA and chain
|
|
394
|
+
* @throws RefError with code 'NOT_FOUND' if ref doesn't exist
|
|
395
|
+
* @throws RefError with code 'CIRCULAR_REF' if circular reference detected
|
|
396
|
+
* @throws RefError with code 'MAX_DEPTH_EXCEEDED' if too many redirects
|
|
397
|
+
*
|
|
398
|
+
* @example
|
|
399
|
+
* ```typescript
|
|
400
|
+
* const resolved = await storage.resolveRef('HEAD')
|
|
401
|
+
* console.log(`SHA: ${resolved.sha}`)
|
|
402
|
+
* console.log(`Chain: ${resolved.chain.map(r => r.name).join(' -> ')}`)
|
|
403
|
+
* // Chain: HEAD -> refs/heads/main
|
|
404
|
+
* ```
|
|
173
405
|
*/
|
|
174
406
|
async resolveRef(name, options) {
|
|
175
407
|
const maxDepth = options?.maxDepth ?? 10;
|
|
@@ -203,10 +435,36 @@ export class RefStorage {
|
|
|
203
435
|
throw new RefError(`Max ref resolution depth exceeded: ${maxDepth}`, 'MAX_DEPTH_EXCEEDED', name);
|
|
204
436
|
}
|
|
205
437
|
/**
|
|
206
|
-
* Update or create a ref
|
|
438
|
+
* Update or create a ref.
|
|
439
|
+
*
|
|
440
|
+
* @description
|
|
441
|
+
* Creates a new ref or updates an existing one. Supports atomic
|
|
442
|
+
* compare-and-swap operations via oldValue option.
|
|
207
443
|
*
|
|
208
444
|
* Note: For atomic operations, callers can acquire a lock via acquireLock()
|
|
209
445
|
* and pass it via options.lock to avoid double-locking.
|
|
446
|
+
*
|
|
447
|
+
* @param name - Full ref name
|
|
448
|
+
* @param target - SHA-1 hash to point to
|
|
449
|
+
* @param options - Update options (create, oldValue, force, lock)
|
|
450
|
+
* @returns The updated/created ref
|
|
451
|
+
* @throws RefError with code 'INVALID_NAME' if ref name is invalid
|
|
452
|
+
* @throws RefError with code 'INVALID_SHA' if SHA format is invalid
|
|
453
|
+
* @throws RefError with code 'ALREADY_EXISTS' if creating and ref exists
|
|
454
|
+
* @throws RefError with code 'CONFLICT' if oldValue doesn't match
|
|
455
|
+
* @throws RefError with code 'NOT_FOUND' if ref doesn't exist and not creating
|
|
456
|
+
*
|
|
457
|
+
* @example
|
|
458
|
+
* ```typescript
|
|
459
|
+
* // Create a new branch
|
|
460
|
+
* await storage.updateRef('refs/heads/feature', sha, { create: true })
|
|
461
|
+
*
|
|
462
|
+
* // Atomic update (fails if someone else modified)
|
|
463
|
+
* await storage.updateRef('refs/heads/main', newSha, { oldValue: currentSha })
|
|
464
|
+
*
|
|
465
|
+
* // Force update (skips fast-forward check)
|
|
466
|
+
* await storage.updateRef('refs/heads/main', sha, { force: true })
|
|
467
|
+
* ```
|
|
210
468
|
*/
|
|
211
469
|
async updateRef(name, target, options) {
|
|
212
470
|
// Validate ref name
|
|
@@ -257,7 +515,25 @@ export class RefStorage {
|
|
|
257
515
|
}
|
|
258
516
|
}
|
|
259
517
|
/**
|
|
260
|
-
* Delete a ref
|
|
518
|
+
* Delete a ref.
|
|
519
|
+
*
|
|
520
|
+
* @description
|
|
521
|
+
* Removes a ref from storage. HEAD cannot be deleted.
|
|
522
|
+
*
|
|
523
|
+
* @param name - Full ref name to delete
|
|
524
|
+
* @param options - Delete options (oldValue for CAS)
|
|
525
|
+
* @returns True if deleted, false if ref didn't exist
|
|
526
|
+
* @throws RefError with code 'INVALID_NAME' for HEAD or invalid names
|
|
527
|
+
* @throws RefError with code 'CONFLICT' if oldValue doesn't match
|
|
528
|
+
*
|
|
529
|
+
* @example
|
|
530
|
+
* ```typescript
|
|
531
|
+
* // Simple delete
|
|
532
|
+
* const deleted = await storage.deleteRef('refs/heads/old-branch')
|
|
533
|
+
*
|
|
534
|
+
* // Atomic delete (only if value matches)
|
|
535
|
+
* await storage.deleteRef('refs/heads/feature', { oldValue: expectedSha })
|
|
536
|
+
* ```
|
|
261
537
|
*/
|
|
262
538
|
async deleteRef(name, options) {
|
|
263
539
|
// Cannot delete HEAD
|
|
@@ -281,7 +557,26 @@ export class RefStorage {
|
|
|
281
557
|
return this.backend.deleteRef(name);
|
|
282
558
|
}
|
|
283
559
|
/**
|
|
284
|
-
* List refs matching a pattern
|
|
560
|
+
* List refs matching a pattern.
|
|
561
|
+
*
|
|
562
|
+
* @description
|
|
563
|
+
* Returns refs filtered by pattern and options.
|
|
564
|
+
* By default, excludes HEAD and symbolic refs.
|
|
565
|
+
*
|
|
566
|
+
* @param options - Listing options (pattern, includeHead, includeSymbolic)
|
|
567
|
+
* @returns Array of matching refs
|
|
568
|
+
*
|
|
569
|
+
* @example
|
|
570
|
+
* ```typescript
|
|
571
|
+
* // List all refs
|
|
572
|
+
* const all = await storage.listRefs()
|
|
573
|
+
*
|
|
574
|
+
* // List branches only
|
|
575
|
+
* const branches = await storage.listRefs({ pattern: 'refs/heads/*' })
|
|
576
|
+
*
|
|
577
|
+
* // Include HEAD
|
|
578
|
+
* const withHead = await storage.listRefs({ includeHead: true })
|
|
579
|
+
* ```
|
|
285
580
|
*/
|
|
286
581
|
async listRefs(options) {
|
|
287
582
|
let refs = await this.backend.listRefs(options?.pattern);
|
|
@@ -307,19 +602,61 @@ export class RefStorage {
|
|
|
307
602
|
return refs;
|
|
308
603
|
}
|
|
309
604
|
/**
|
|
310
|
-
* List all branches
|
|
605
|
+
* List all branches.
|
|
606
|
+
*
|
|
607
|
+
* @description
|
|
608
|
+
* Convenience method to list refs under refs/heads/.
|
|
609
|
+
*
|
|
610
|
+
* @returns Array of branch refs
|
|
611
|
+
*
|
|
612
|
+
* @example
|
|
613
|
+
* ```typescript
|
|
614
|
+
* const branches = await storage.listBranches()
|
|
615
|
+
* for (const branch of branches) {
|
|
616
|
+
* console.log(branch.name.replace('refs/heads/', ''))
|
|
617
|
+
* }
|
|
618
|
+
* ```
|
|
311
619
|
*/
|
|
312
620
|
async listBranches() {
|
|
313
621
|
return this.listRefs({ pattern: 'refs/heads/*' });
|
|
314
622
|
}
|
|
315
623
|
/**
|
|
316
|
-
* List all tags
|
|
624
|
+
* List all tags.
|
|
625
|
+
*
|
|
626
|
+
* @description
|
|
627
|
+
* Convenience method to list refs under refs/tags/.
|
|
628
|
+
*
|
|
629
|
+
* @returns Array of tag refs
|
|
630
|
+
*
|
|
631
|
+
* @example
|
|
632
|
+
* ```typescript
|
|
633
|
+
* const tags = await storage.listTags()
|
|
634
|
+
* for (const tag of tags) {
|
|
635
|
+
* console.log(tag.name.replace('refs/tags/', ''))
|
|
636
|
+
* }
|
|
637
|
+
* ```
|
|
317
638
|
*/
|
|
318
639
|
async listTags() {
|
|
319
640
|
return this.listRefs({ pattern: 'refs/tags/*' });
|
|
320
641
|
}
|
|
321
642
|
/**
|
|
322
|
-
* Get HEAD ref
|
|
643
|
+
* Get HEAD ref.
|
|
644
|
+
*
|
|
645
|
+
* @description
|
|
646
|
+
* Returns the HEAD ref. Every repository should have HEAD.
|
|
647
|
+
*
|
|
648
|
+
* @returns The HEAD ref
|
|
649
|
+
* @throws RefError with code 'NOT_FOUND' if HEAD doesn't exist
|
|
650
|
+
*
|
|
651
|
+
* @example
|
|
652
|
+
* ```typescript
|
|
653
|
+
* const head = await storage.getHead()
|
|
654
|
+
* if (head.type === 'symbolic') {
|
|
655
|
+
* console.log(`On branch: ${head.target}`)
|
|
656
|
+
* } else {
|
|
657
|
+
* console.log(`Detached at: ${head.target}`)
|
|
658
|
+
* }
|
|
659
|
+
* ```
|
|
323
660
|
*/
|
|
324
661
|
async getHead() {
|
|
325
662
|
const head = await this.getRef('HEAD');
|
|
@@ -329,7 +666,23 @@ export class RefStorage {
|
|
|
329
666
|
return head;
|
|
330
667
|
}
|
|
331
668
|
/**
|
|
332
|
-
* Update HEAD (can be symbolic or detached)
|
|
669
|
+
* Update HEAD (can be symbolic or detached).
|
|
670
|
+
*
|
|
671
|
+
* @description
|
|
672
|
+
* Sets HEAD to point to a branch (symbolic) or commit (detached).
|
|
673
|
+
*
|
|
674
|
+
* @param target - Branch ref name (symbolic) or SHA (detached)
|
|
675
|
+
* @param symbolic - If true, create symbolic ref; if false, direct ref
|
|
676
|
+
* @returns The updated HEAD ref
|
|
677
|
+
*
|
|
678
|
+
* @example
|
|
679
|
+
* ```typescript
|
|
680
|
+
* // Switch to branch
|
|
681
|
+
* await storage.updateHead('refs/heads/main', true)
|
|
682
|
+
*
|
|
683
|
+
* // Detach HEAD at commit
|
|
684
|
+
* await storage.updateHead(commitSha, false)
|
|
685
|
+
* ```
|
|
333
686
|
*/
|
|
334
687
|
async updateHead(target, symbolic) {
|
|
335
688
|
const ref = {
|
|
@@ -341,14 +694,43 @@ export class RefStorage {
|
|
|
341
694
|
return ref;
|
|
342
695
|
}
|
|
343
696
|
/**
|
|
344
|
-
* Check if HEAD is detached
|
|
697
|
+
* Check if HEAD is detached.
|
|
698
|
+
*
|
|
699
|
+
* @description
|
|
700
|
+
* HEAD is detached when it points directly to a commit SHA
|
|
701
|
+
* rather than symbolically to a branch.
|
|
702
|
+
*
|
|
703
|
+
* @returns True if HEAD is detached (points to SHA directly)
|
|
704
|
+
*
|
|
705
|
+
* @example
|
|
706
|
+
* ```typescript
|
|
707
|
+
* if (await storage.isHeadDetached()) {
|
|
708
|
+
* console.log('You are in detached HEAD state')
|
|
709
|
+
* }
|
|
710
|
+
* ```
|
|
345
711
|
*/
|
|
346
712
|
async isHeadDetached() {
|
|
347
713
|
const head = await this.getHead();
|
|
348
714
|
return head.type === 'direct';
|
|
349
715
|
}
|
|
350
716
|
/**
|
|
351
|
-
* Create a symbolic ref
|
|
717
|
+
* Create a symbolic ref.
|
|
718
|
+
*
|
|
719
|
+
* @description
|
|
720
|
+
* Creates a ref that points to another ref name (not a SHA).
|
|
721
|
+
* Used primarily for HEAD pointing to a branch.
|
|
722
|
+
*
|
|
723
|
+
* @param name - Name for the new symbolic ref
|
|
724
|
+
* @param target - Target ref name (not SHA)
|
|
725
|
+
* @returns The created symbolic ref
|
|
726
|
+
* @throws RefError with code 'INVALID_NAME' if name is invalid
|
|
727
|
+
* @throws RefError with code 'CIRCULAR_REF' if name equals target
|
|
728
|
+
*
|
|
729
|
+
* @example
|
|
730
|
+
* ```typescript
|
|
731
|
+
* // Make HEAD point to main branch
|
|
732
|
+
* await storage.createSymbolicRef('HEAD', 'refs/heads/main')
|
|
733
|
+
* ```
|
|
352
734
|
*/
|
|
353
735
|
async createSymbolicRef(name, target) {
|
|
354
736
|
// Validate ref name
|
|
@@ -368,13 +750,43 @@ export class RefStorage {
|
|
|
368
750
|
return ref;
|
|
369
751
|
}
|
|
370
752
|
/**
|
|
371
|
-
* Acquire a lock for updating a ref
|
|
753
|
+
* Acquire a lock for updating a ref.
|
|
754
|
+
*
|
|
755
|
+
* @description
|
|
756
|
+
* Acquires an exclusive lock on a ref. Use this for complex operations
|
|
757
|
+
* that need to read-modify-write atomically.
|
|
758
|
+
*
|
|
759
|
+
* @param name - Full ref name to lock
|
|
760
|
+
* @param timeout - Lock acquisition timeout in milliseconds
|
|
761
|
+
* @returns Lock handle - must be released when done
|
|
762
|
+
*
|
|
763
|
+
* @example
|
|
764
|
+
* ```typescript
|
|
765
|
+
* const lock = await storage.acquireLock('refs/heads/main', 5000)
|
|
766
|
+
* try {
|
|
767
|
+
* // Perform atomic operations
|
|
768
|
+
* await storage.updateRef('refs/heads/main', sha, { lock })
|
|
769
|
+
* } finally {
|
|
770
|
+
* await lock.release()
|
|
771
|
+
* }
|
|
772
|
+
* ```
|
|
372
773
|
*/
|
|
373
774
|
async acquireLock(name, timeout) {
|
|
374
775
|
return this.backend.acquireLock(name, timeout);
|
|
375
776
|
}
|
|
376
777
|
/**
|
|
377
|
-
* Pack loose refs into packed-refs file
|
|
778
|
+
* Pack loose refs into packed-refs file.
|
|
779
|
+
*
|
|
780
|
+
* @description
|
|
781
|
+
* Consolidates loose ref files into a single packed-refs file.
|
|
782
|
+
* This improves performance for repositories with many refs.
|
|
783
|
+
* HEAD and symbolic refs are not packed.
|
|
784
|
+
*
|
|
785
|
+
* @example
|
|
786
|
+
* ```typescript
|
|
787
|
+
* // After creating many branches/tags
|
|
788
|
+
* await storage.packRefs()
|
|
789
|
+
* ```
|
|
378
790
|
*/
|
|
379
791
|
async packRefs() {
|
|
380
792
|
const allRefs = await this.backend.listRefs();
|
|
@@ -393,27 +805,67 @@ export class RefStorage {
|
|
|
393
805
|
await this.backend.writePackedRefs(packed);
|
|
394
806
|
}
|
|
395
807
|
}
|
|
808
|
+
// ============================================================================
|
|
809
|
+
// Convenience Functions
|
|
810
|
+
// ============================================================================
|
|
396
811
|
/**
|
|
397
|
-
* Resolve a ref to its final SHA target
|
|
812
|
+
* Resolve a ref to its final SHA target.
|
|
813
|
+
*
|
|
814
|
+
* @description
|
|
815
|
+
* Convenience function that wraps RefStorage.resolveRef.
|
|
816
|
+
*
|
|
817
|
+
* @param storage - RefStorage instance
|
|
818
|
+
* @param name - Ref name to resolve
|
|
819
|
+
* @param options - Resolution options
|
|
820
|
+
* @returns The final SHA target
|
|
821
|
+
*
|
|
822
|
+
* @example
|
|
823
|
+
* ```typescript
|
|
824
|
+
* const sha = await resolveRef(storage, 'HEAD')
|
|
825
|
+
* ```
|
|
398
826
|
*/
|
|
399
827
|
export async function resolveRef(storage, name, options) {
|
|
400
828
|
const resolved = await storage.resolveRef(name, options);
|
|
401
829
|
return resolved.sha;
|
|
402
830
|
}
|
|
403
831
|
/**
|
|
404
|
-
* Update a ref
|
|
832
|
+
* Update a ref.
|
|
833
|
+
*
|
|
834
|
+
* @description
|
|
835
|
+
* Convenience function that wraps RefStorage.updateRef.
|
|
836
|
+
*
|
|
837
|
+
* @param storage - RefStorage instance
|
|
838
|
+
* @param name - Full ref name
|
|
839
|
+
* @param target - SHA target
|
|
840
|
+
* @param options - Update options
|
|
841
|
+
* @returns The updated ref
|
|
405
842
|
*/
|
|
406
843
|
export async function updateRef(storage, name, target, options) {
|
|
407
844
|
return storage.updateRef(name, target, options);
|
|
408
845
|
}
|
|
409
846
|
/**
|
|
410
|
-
* Delete a ref
|
|
847
|
+
* Delete a ref.
|
|
848
|
+
*
|
|
849
|
+
* @description
|
|
850
|
+
* Convenience function that wraps RefStorage.deleteRef.
|
|
851
|
+
*
|
|
852
|
+
* @param storage - RefStorage instance
|
|
853
|
+
* @param name - Full ref name to delete
|
|
854
|
+
* @param options - Delete options
|
|
855
|
+
* @returns True if deleted
|
|
411
856
|
*/
|
|
412
857
|
export async function deleteRef(storage, name, options) {
|
|
413
858
|
return storage.deleteRef(name, options);
|
|
414
859
|
}
|
|
415
860
|
/**
|
|
416
|
-
* List refs
|
|
861
|
+
* List refs.
|
|
862
|
+
*
|
|
863
|
+
* @description
|
|
864
|
+
* Convenience function that wraps RefStorage.listRefs.
|
|
865
|
+
*
|
|
866
|
+
* @param storage - RefStorage instance
|
|
867
|
+
* @param options - Listing options
|
|
868
|
+
* @returns Array of refs
|
|
417
869
|
*/
|
|
418
870
|
export async function listRefs(storage, options) {
|
|
419
871
|
return storage.listRefs(options);
|