gitx.do 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +40 -353
- package/dist/do/logger.d.ts +50 -0
- package/dist/do/logger.d.ts.map +1 -0
- package/dist/do/logger.js +122 -0
- package/dist/do/logger.js.map +1 -0
- package/dist/{durable-object → do}/schema.d.ts +3 -3
- package/dist/do/schema.d.ts.map +1 -0
- package/dist/{durable-object → do}/schema.js +4 -3
- package/dist/do/schema.js.map +1 -0
- package/dist/do/types.d.ts +267 -0
- package/dist/do/types.d.ts.map +1 -0
- package/dist/do/types.js +62 -0
- package/dist/do/types.js.map +1 -0
- package/dist/index.d.ts +14 -469
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +31 -483
- package/dist/index.js.map +1 -1
- package/package.json +13 -21
- package/dist/cli/commands/add.d.ts +0 -176
- package/dist/cli/commands/add.d.ts.map +0 -1
- package/dist/cli/commands/add.js +0 -979
- package/dist/cli/commands/add.js.map +0 -1
- package/dist/cli/commands/blame.d.ts +0 -259
- package/dist/cli/commands/blame.d.ts.map +0 -1
- package/dist/cli/commands/blame.js +0 -609
- package/dist/cli/commands/blame.js.map +0 -1
- package/dist/cli/commands/branch.d.ts +0 -249
- package/dist/cli/commands/branch.d.ts.map +0 -1
- package/dist/cli/commands/branch.js +0 -693
- package/dist/cli/commands/branch.js.map +0 -1
- package/dist/cli/commands/checkout.d.ts +0 -73
- package/dist/cli/commands/checkout.d.ts.map +0 -1
- package/dist/cli/commands/checkout.js +0 -725
- package/dist/cli/commands/checkout.js.map +0 -1
- package/dist/cli/commands/commit.d.ts +0 -182
- package/dist/cli/commands/commit.d.ts.map +0 -1
- package/dist/cli/commands/commit.js +0 -457
- package/dist/cli/commands/commit.js.map +0 -1
- package/dist/cli/commands/diff.d.ts +0 -464
- package/dist/cli/commands/diff.d.ts.map +0 -1
- package/dist/cli/commands/diff.js +0 -959
- package/dist/cli/commands/diff.js.map +0 -1
- package/dist/cli/commands/log.d.ts +0 -239
- package/dist/cli/commands/log.d.ts.map +0 -1
- package/dist/cli/commands/log.js +0 -535
- package/dist/cli/commands/log.js.map +0 -1
- package/dist/cli/commands/merge.d.ts +0 -106
- package/dist/cli/commands/merge.d.ts.map +0 -1
- package/dist/cli/commands/merge.js +0 -852
- package/dist/cli/commands/merge.js.map +0 -1
- package/dist/cli/commands/review.d.ts +0 -457
- package/dist/cli/commands/review.d.ts.map +0 -1
- package/dist/cli/commands/review.js +0 -558
- package/dist/cli/commands/review.js.map +0 -1
- package/dist/cli/commands/stash.d.ts +0 -157
- package/dist/cli/commands/stash.d.ts.map +0 -1
- package/dist/cli/commands/stash.js +0 -655
- package/dist/cli/commands/stash.js.map +0 -1
- package/dist/cli/commands/status.d.ts +0 -269
- package/dist/cli/commands/status.d.ts.map +0 -1
- package/dist/cli/commands/status.js +0 -492
- package/dist/cli/commands/status.js.map +0 -1
- package/dist/cli/commands/web.d.ts +0 -199
- package/dist/cli/commands/web.d.ts.map +0 -1
- package/dist/cli/commands/web.js +0 -697
- package/dist/cli/commands/web.js.map +0 -1
- package/dist/cli/fs-adapter.d.ts +0 -656
- package/dist/cli/fs-adapter.d.ts.map +0 -1
- package/dist/cli/fs-adapter.js +0 -1177
- package/dist/cli/fs-adapter.js.map +0 -1
- package/dist/cli/fsx-cli-adapter.d.ts +0 -359
- package/dist/cli/fsx-cli-adapter.d.ts.map +0 -1
- package/dist/cli/fsx-cli-adapter.js +0 -619
- package/dist/cli/fsx-cli-adapter.js.map +0 -1
- package/dist/cli/index.d.ts +0 -387
- package/dist/cli/index.d.ts.map +0 -1
- package/dist/cli/index.js +0 -579
- package/dist/cli/index.js.map +0 -1
- package/dist/cli/ui/components/DiffView.d.ts +0 -12
- package/dist/cli/ui/components/DiffView.d.ts.map +0 -1
- package/dist/cli/ui/components/DiffView.js +0 -11
- package/dist/cli/ui/components/DiffView.js.map +0 -1
- package/dist/cli/ui/components/ErrorDisplay.d.ts +0 -10
- package/dist/cli/ui/components/ErrorDisplay.d.ts.map +0 -1
- package/dist/cli/ui/components/ErrorDisplay.js +0 -11
- package/dist/cli/ui/components/ErrorDisplay.js.map +0 -1
- package/dist/cli/ui/components/FuzzySearch.d.ts +0 -15
- package/dist/cli/ui/components/FuzzySearch.d.ts.map +0 -1
- package/dist/cli/ui/components/FuzzySearch.js +0 -12
- package/dist/cli/ui/components/FuzzySearch.js.map +0 -1
- package/dist/cli/ui/components/LoadingSpinner.d.ts +0 -10
- package/dist/cli/ui/components/LoadingSpinner.d.ts.map +0 -1
- package/dist/cli/ui/components/LoadingSpinner.js +0 -10
- package/dist/cli/ui/components/LoadingSpinner.js.map +0 -1
- package/dist/cli/ui/components/NavigationList.d.ts +0 -14
- package/dist/cli/ui/components/NavigationList.d.ts.map +0 -1
- package/dist/cli/ui/components/NavigationList.js +0 -11
- package/dist/cli/ui/components/NavigationList.js.map +0 -1
- package/dist/cli/ui/components/ScrollableContent.d.ts +0 -13
- package/dist/cli/ui/components/ScrollableContent.d.ts.map +0 -1
- package/dist/cli/ui/components/ScrollableContent.js +0 -11
- package/dist/cli/ui/components/ScrollableContent.js.map +0 -1
- package/dist/cli/ui/components/index.d.ts +0 -7
- package/dist/cli/ui/components/index.d.ts.map +0 -1
- package/dist/cli/ui/components/index.js +0 -9
- package/dist/cli/ui/components/index.js.map +0 -1
- package/dist/cli/ui/terminal-ui.d.ts +0 -85
- package/dist/cli/ui/terminal-ui.d.ts.map +0 -1
- package/dist/cli/ui/terminal-ui.js +0 -121
- package/dist/cli/ui/terminal-ui.js.map +0 -1
- package/dist/do/BashModule.d.ts +0 -871
- package/dist/do/BashModule.d.ts.map +0 -1
- package/dist/do/BashModule.js +0 -1143
- package/dist/do/BashModule.js.map +0 -1
- package/dist/do/FsModule.d.ts +0 -612
- package/dist/do/FsModule.d.ts.map +0 -1
- package/dist/do/FsModule.js +0 -1120
- package/dist/do/FsModule.js.map +0 -1
- package/dist/do/GitModule.d.ts +0 -635
- package/dist/do/GitModule.d.ts.map +0 -1
- package/dist/do/GitModule.js +0 -784
- package/dist/do/GitModule.js.map +0 -1
- package/dist/do/GitRepoDO.d.ts +0 -281
- package/dist/do/GitRepoDO.d.ts.map +0 -1
- package/dist/do/GitRepoDO.js +0 -479
- package/dist/do/GitRepoDO.js.map +0 -1
- package/dist/do/bash-ast.d.ts +0 -246
- package/dist/do/bash-ast.d.ts.map +0 -1
- package/dist/do/bash-ast.js +0 -888
- package/dist/do/bash-ast.js.map +0 -1
- package/dist/do/container-executor.d.ts +0 -491
- package/dist/do/container-executor.d.ts.map +0 -1
- package/dist/do/container-executor.js +0 -731
- package/dist/do/container-executor.js.map +0 -1
- package/dist/do/index.d.ts +0 -53
- package/dist/do/index.d.ts.map +0 -1
- package/dist/do/index.js +0 -91
- package/dist/do/index.js.map +0 -1
- package/dist/do/tiered-storage.d.ts +0 -403
- package/dist/do/tiered-storage.d.ts.map +0 -1
- package/dist/do/tiered-storage.js +0 -689
- package/dist/do/tiered-storage.js.map +0 -1
- package/dist/do/withBash.d.ts +0 -231
- package/dist/do/withBash.d.ts.map +0 -1
- package/dist/do/withBash.js +0 -244
- package/dist/do/withBash.js.map +0 -1
- package/dist/do/withFs.d.ts +0 -237
- package/dist/do/withFs.d.ts.map +0 -1
- package/dist/do/withFs.js +0 -387
- package/dist/do/withFs.js.map +0 -1
- package/dist/do/withGit.d.ts +0 -180
- package/dist/do/withGit.d.ts.map +0 -1
- package/dist/do/withGit.js +0 -271
- package/dist/do/withGit.js.map +0 -1
- package/dist/durable-object/object-store.d.ts +0 -633
- package/dist/durable-object/object-store.d.ts.map +0 -1
- package/dist/durable-object/object-store.js +0 -1164
- package/dist/durable-object/object-store.js.map +0 -1
- package/dist/durable-object/schema.d.ts.map +0 -1
- package/dist/durable-object/schema.js.map +0 -1
- package/dist/durable-object/wal.d.ts +0 -416
- package/dist/durable-object/wal.d.ts.map +0 -1
- package/dist/durable-object/wal.js +0 -445
- package/dist/durable-object/wal.js.map +0 -1
- package/dist/mcp/adapter.d.ts +0 -772
- package/dist/mcp/adapter.d.ts.map +0 -1
- package/dist/mcp/adapter.js +0 -895
- package/dist/mcp/adapter.js.map +0 -1
- package/dist/mcp/sandbox/miniflare-evaluator.d.ts +0 -22
- package/dist/mcp/sandbox/miniflare-evaluator.d.ts.map +0 -1
- package/dist/mcp/sandbox/miniflare-evaluator.js +0 -140
- package/dist/mcp/sandbox/miniflare-evaluator.js.map +0 -1
- package/dist/mcp/sandbox/object-store-proxy.d.ts +0 -32
- package/dist/mcp/sandbox/object-store-proxy.d.ts.map +0 -1
- package/dist/mcp/sandbox/object-store-proxy.js +0 -30
- package/dist/mcp/sandbox/object-store-proxy.js.map +0 -1
- package/dist/mcp/sandbox/template.d.ts +0 -17
- package/dist/mcp/sandbox/template.d.ts.map +0 -1
- package/dist/mcp/sandbox/template.js +0 -71
- package/dist/mcp/sandbox/template.js.map +0 -1
- package/dist/mcp/sandbox.d.ts +0 -764
- package/dist/mcp/sandbox.d.ts.map +0 -1
- package/dist/mcp/sandbox.js +0 -1362
- package/dist/mcp/sandbox.js.map +0 -1
- package/dist/mcp/sdk-adapter.d.ts +0 -835
- package/dist/mcp/sdk-adapter.d.ts.map +0 -1
- package/dist/mcp/sdk-adapter.js +0 -974
- package/dist/mcp/sdk-adapter.js.map +0 -1
- package/dist/mcp/tools/do.d.ts +0 -32
- package/dist/mcp/tools/do.d.ts.map +0 -1
- package/dist/mcp/tools/do.js +0 -117
- package/dist/mcp/tools/do.js.map +0 -1
- package/dist/mcp/tools.d.ts +0 -548
- package/dist/mcp/tools.d.ts.map +0 -1
- package/dist/mcp/tools.js +0 -3170
- package/dist/mcp/tools.js.map +0 -1
- package/dist/ops/blame.d.ts +0 -551
- package/dist/ops/blame.d.ts.map +0 -1
- package/dist/ops/blame.js +0 -1037
- package/dist/ops/blame.js.map +0 -1
- package/dist/ops/branch.d.ts +0 -766
- package/dist/ops/branch.d.ts.map +0 -1
- package/dist/ops/branch.js +0 -950
- package/dist/ops/branch.js.map +0 -1
- package/dist/ops/commit-traversal.d.ts +0 -349
- package/dist/ops/commit-traversal.d.ts.map +0 -1
- package/dist/ops/commit-traversal.js +0 -821
- package/dist/ops/commit-traversal.js.map +0 -1
- package/dist/ops/commit.d.ts +0 -555
- package/dist/ops/commit.d.ts.map +0 -1
- package/dist/ops/commit.js +0 -826
- package/dist/ops/commit.js.map +0 -1
- package/dist/ops/merge-base.d.ts +0 -397
- package/dist/ops/merge-base.d.ts.map +0 -1
- package/dist/ops/merge-base.js +0 -691
- package/dist/ops/merge-base.js.map +0 -1
- package/dist/ops/merge.d.ts +0 -855
- package/dist/ops/merge.d.ts.map +0 -1
- package/dist/ops/merge.js +0 -1551
- package/dist/ops/merge.js.map +0 -1
- package/dist/ops/tag.d.ts +0 -247
- package/dist/ops/tag.d.ts.map +0 -1
- package/dist/ops/tag.js +0 -649
- package/dist/ops/tag.js.map +0 -1
- package/dist/ops/tree-builder.d.ts +0 -178
- package/dist/ops/tree-builder.d.ts.map +0 -1
- package/dist/ops/tree-builder.js +0 -271
- package/dist/ops/tree-builder.js.map +0 -1
- package/dist/ops/tree-diff.d.ts +0 -291
- package/dist/ops/tree-diff.d.ts.map +0 -1
- package/dist/ops/tree-diff.js +0 -705
- package/dist/ops/tree-diff.js.map +0 -1
- package/dist/pack/delta.d.ts +0 -248
- package/dist/pack/delta.d.ts.map +0 -1
- package/dist/pack/delta.js +0 -740
- package/dist/pack/delta.js.map +0 -1
- package/dist/pack/format.d.ts +0 -446
- package/dist/pack/format.d.ts.map +0 -1
- package/dist/pack/format.js +0 -572
- package/dist/pack/format.js.map +0 -1
- package/dist/pack/full-generation.d.ts +0 -612
- package/dist/pack/full-generation.d.ts.map +0 -1
- package/dist/pack/full-generation.js +0 -1378
- package/dist/pack/full-generation.js.map +0 -1
- package/dist/pack/generation.d.ts +0 -441
- package/dist/pack/generation.d.ts.map +0 -1
- package/dist/pack/generation.js +0 -707
- package/dist/pack/generation.js.map +0 -1
- package/dist/pack/index.d.ts +0 -502
- package/dist/pack/index.d.ts.map +0 -1
- package/dist/pack/index.js +0 -833
- package/dist/pack/index.js.map +0 -1
- package/dist/refs/branch.d.ts +0 -683
- package/dist/refs/branch.d.ts.map +0 -1
- package/dist/refs/branch.js +0 -881
- package/dist/refs/branch.js.map +0 -1
- package/dist/refs/storage.d.ts +0 -833
- package/dist/refs/storage.d.ts.map +0 -1
- package/dist/refs/storage.js +0 -1023
- package/dist/refs/storage.js.map +0 -1
- package/dist/refs/tag.d.ts +0 -860
- package/dist/refs/tag.d.ts.map +0 -1
- package/dist/refs/tag.js +0 -996
- package/dist/refs/tag.js.map +0 -1
- package/dist/storage/backend.d.ts +0 -425
- package/dist/storage/backend.d.ts.map +0 -1
- package/dist/storage/backend.js +0 -41
- package/dist/storage/backend.js.map +0 -1
- package/dist/storage/fsx-adapter.d.ts +0 -204
- package/dist/storage/fsx-adapter.d.ts.map +0 -1
- package/dist/storage/fsx-adapter.js +0 -518
- package/dist/storage/fsx-adapter.js.map +0 -1
- package/dist/storage/lru-cache.d.ts +0 -691
- package/dist/storage/lru-cache.d.ts.map +0 -1
- package/dist/storage/lru-cache.js +0 -813
- package/dist/storage/lru-cache.js.map +0 -1
- package/dist/storage/object-index.d.ts +0 -585
- package/dist/storage/object-index.d.ts.map +0 -1
- package/dist/storage/object-index.js +0 -532
- package/dist/storage/object-index.js.map +0 -1
- package/dist/storage/r2-pack.d.ts +0 -1257
- package/dist/storage/r2-pack.d.ts.map +0 -1
- package/dist/storage/r2-pack.js +0 -1773
- package/dist/storage/r2-pack.js.map +0 -1
- package/dist/tiered/cdc-pipeline.d.ts +0 -1888
- package/dist/tiered/cdc-pipeline.d.ts.map +0 -1
- package/dist/tiered/cdc-pipeline.js +0 -1880
- package/dist/tiered/cdc-pipeline.js.map +0 -1
- package/dist/tiered/migration.d.ts +0 -1104
- package/dist/tiered/migration.d.ts.map +0 -1
- package/dist/tiered/migration.js +0 -1217
- package/dist/tiered/migration.js.map +0 -1
- package/dist/tiered/parquet-writer.d.ts +0 -1145
- package/dist/tiered/parquet-writer.d.ts.map +0 -1
- package/dist/tiered/parquet-writer.js +0 -1183
- package/dist/tiered/parquet-writer.js.map +0 -1
- package/dist/tiered/read-path.d.ts +0 -835
- package/dist/tiered/read-path.d.ts.map +0 -1
- package/dist/tiered/read-path.js +0 -487
- package/dist/tiered/read-path.js.map +0 -1
- package/dist/types/capability.d.ts +0 -1385
- package/dist/types/capability.d.ts.map +0 -1
- package/dist/types/capability.js +0 -36
- package/dist/types/capability.js.map +0 -1
- package/dist/types/index.d.ts +0 -13
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js +0 -18
- package/dist/types/index.js.map +0 -1
- package/dist/types/interfaces.d.ts +0 -673
- package/dist/types/interfaces.d.ts.map +0 -1
- package/dist/types/interfaces.js +0 -26
- package/dist/types/interfaces.js.map +0 -1
- package/dist/types/objects.d.ts +0 -692
- package/dist/types/objects.d.ts.map +0 -1
- package/dist/types/objects.js +0 -837
- package/dist/types/objects.js.map +0 -1
- package/dist/types/storage.d.ts +0 -603
- package/dist/types/storage.d.ts.map +0 -1
- package/dist/types/storage.js +0 -191
- package/dist/types/storage.js.map +0 -1
- package/dist/types/worker-loader.d.ts +0 -60
- package/dist/types/worker-loader.d.ts.map +0 -1
- package/dist/types/worker-loader.js +0 -62
- package/dist/types/worker-loader.js.map +0 -1
- package/dist/utils/hash.d.ts +0 -198
- package/dist/utils/hash.d.ts.map +0 -1
- package/dist/utils/hash.js +0 -272
- package/dist/utils/hash.js.map +0 -1
- package/dist/utils/sha1.d.ts +0 -325
- package/dist/utils/sha1.d.ts.map +0 -1
- package/dist/utils/sha1.js +0 -635
- package/dist/utils/sha1.js.map +0 -1
- package/dist/wire/capabilities.d.ts +0 -1044
- package/dist/wire/capabilities.d.ts.map +0 -1
- package/dist/wire/capabilities.js +0 -941
- package/dist/wire/capabilities.js.map +0 -1
- package/dist/wire/path-security.d.ts +0 -157
- package/dist/wire/path-security.d.ts.map +0 -1
- package/dist/wire/path-security.js +0 -307
- package/dist/wire/path-security.js.map +0 -1
- package/dist/wire/pkt-line.d.ts +0 -345
- package/dist/wire/pkt-line.d.ts.map +0 -1
- package/dist/wire/pkt-line.js +0 -381
- package/dist/wire/pkt-line.js.map +0 -1
- package/dist/wire/receive-pack.d.ts +0 -1059
- package/dist/wire/receive-pack.d.ts.map +0 -1
- package/dist/wire/receive-pack.js +0 -1414
- package/dist/wire/receive-pack.js.map +0 -1
- package/dist/wire/smart-http.d.ts +0 -799
- package/dist/wire/smart-http.d.ts.map +0 -1
- package/dist/wire/smart-http.js +0 -945
- package/dist/wire/smart-http.js.map +0 -1
- package/dist/wire/upload-pack.d.ts +0 -727
- package/dist/wire/upload-pack.d.ts.map +0 -1
- package/dist/wire/upload-pack.js +0 -1141
- package/dist/wire/upload-pack.js.map +0 -1
package/dist/refs/storage.d.ts
DELETED
|
@@ -1,833 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Git Reference Storage System
|
|
3
|
-
*
|
|
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
|
-
* **Backend Support**:
|
|
15
|
-
* - `RefStorageBackend`: Full-featured backend with locking and packed refs
|
|
16
|
-
* - `StorageBackend`: Simpler backend interface (optional, from storage/backend.ts)
|
|
17
|
-
*
|
|
18
|
-
* @module refs/storage
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* ```typescript
|
|
22
|
-
* import { RefStorage, isValidRefName, isValidSha } from './refs/storage'
|
|
23
|
-
*
|
|
24
|
-
* // Create storage with RefStorageBackend (full features)
|
|
25
|
-
* const storage = new RefStorage(backend)
|
|
26
|
-
*
|
|
27
|
-
* // Or create with StorageBackend (simpler, optional)
|
|
28
|
-
* const storage = new RefStorage({ storageBackend: myStorageBackend })
|
|
29
|
-
*
|
|
30
|
-
* // Resolve HEAD to get current commit
|
|
31
|
-
* const resolved = await storage.resolveRef('HEAD')
|
|
32
|
-
* console.log(`Current commit: ${resolved.sha}`)
|
|
33
|
-
*
|
|
34
|
-
* // Update a branch
|
|
35
|
-
* await storage.updateRef('refs/heads/feature', newCommitSha, { create: true })
|
|
36
|
-
*
|
|
37
|
-
* // List all branches
|
|
38
|
-
* const branches = await storage.listBranches()
|
|
39
|
-
* ```
|
|
40
|
-
*/
|
|
41
|
-
import type { StorageBackend } from '../storage/backend';
|
|
42
|
-
/**
|
|
43
|
-
* Type discriminator for reference types.
|
|
44
|
-
*
|
|
45
|
-
* @description
|
|
46
|
-
* - `direct`: Points directly to a SHA-1 hash
|
|
47
|
-
* - `symbolic`: Points to another ref name (follows chain on resolution)
|
|
48
|
-
*/
|
|
49
|
-
export type RefType = 'direct' | 'symbolic';
|
|
50
|
-
/**
|
|
51
|
-
* Represents a Git reference (branch, tag, HEAD, etc.).
|
|
52
|
-
*
|
|
53
|
-
* @description
|
|
54
|
-
* References are named pointers in Git. They can point directly to objects
|
|
55
|
-
* (like commits) or symbolically to other refs.
|
|
56
|
-
*
|
|
57
|
-
* @example
|
|
58
|
-
* ```typescript
|
|
59
|
-
* // Direct ref (branch pointing to commit)
|
|
60
|
-
* const branch: Ref = {
|
|
61
|
-
* name: 'refs/heads/main',
|
|
62
|
-
* target: 'abc123def456...',
|
|
63
|
-
* type: 'direct'
|
|
64
|
-
* }
|
|
65
|
-
*
|
|
66
|
-
* // Symbolic ref (HEAD pointing to branch)
|
|
67
|
-
* const head: Ref = {
|
|
68
|
-
* name: 'HEAD',
|
|
69
|
-
* target: 'refs/heads/main',
|
|
70
|
-
* type: 'symbolic'
|
|
71
|
-
* }
|
|
72
|
-
* ```
|
|
73
|
-
*/
|
|
74
|
-
export interface Ref {
|
|
75
|
-
/** Full ref name (e.g., 'refs/heads/main', 'HEAD') */
|
|
76
|
-
name: string;
|
|
77
|
-
/** Target - SHA-1 hash for direct refs, ref name for symbolic refs */
|
|
78
|
-
target: string;
|
|
79
|
-
/** Whether this is a direct or symbolic reference */
|
|
80
|
-
type: RefType;
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Options for updating a reference.
|
|
84
|
-
*
|
|
85
|
-
* @description
|
|
86
|
-
* Provides control over ref update behavior including atomic operations
|
|
87
|
-
* (compare-and-swap), creation, and force updates.
|
|
88
|
-
*/
|
|
89
|
-
export interface UpdateRefOptions {
|
|
90
|
-
/** If true, create the ref if it doesn't exist (default: false) */
|
|
91
|
-
create?: boolean;
|
|
92
|
-
/**
|
|
93
|
-
* Expected old value for compare-and-swap (CAS) operation.
|
|
94
|
-
* - `null`: Expect ref to NOT exist (atomic create)
|
|
95
|
-
* - SHA string: Expect ref to have this exact value
|
|
96
|
-
* - undefined: No CAS check
|
|
97
|
-
*/
|
|
98
|
-
oldValue?: string | null;
|
|
99
|
-
/** Force update even if not a fast-forward (for branch updates) */
|
|
100
|
-
force?: boolean;
|
|
101
|
-
/** Reason for the update (stored in reflog if implemented) */
|
|
102
|
-
reason?: string;
|
|
103
|
-
/** Use an existing lock instead of acquiring a new one */
|
|
104
|
-
lock?: RefLock;
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Options for listing references.
|
|
108
|
-
*
|
|
109
|
-
* @description
|
|
110
|
-
* Controls which refs are included in listing operations.
|
|
111
|
-
*/
|
|
112
|
-
export interface ListRefsOptions {
|
|
113
|
-
/** Glob pattern to filter refs (e.g., 'refs/heads/*', 'refs/tags/v*') */
|
|
114
|
-
pattern?: string;
|
|
115
|
-
/** Include HEAD in the listing (default: false) */
|
|
116
|
-
includeHead?: boolean;
|
|
117
|
-
/** Include symbolic refs in the listing (default: false) */
|
|
118
|
-
includeSymbolic?: boolean;
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Options for resolving references.
|
|
122
|
-
*/
|
|
123
|
-
export interface ResolveRefOptions {
|
|
124
|
-
/**
|
|
125
|
-
* Maximum depth for following symbolic refs (default: 10).
|
|
126
|
-
* Prevents infinite loops from circular refs.
|
|
127
|
-
*/
|
|
128
|
-
maxDepth?: number;
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* Result of resolving a reference.
|
|
132
|
-
*
|
|
133
|
-
* @description
|
|
134
|
-
* Contains the resolved SHA and the chain of refs followed during resolution.
|
|
135
|
-
* Useful for understanding ref structure and debugging.
|
|
136
|
-
*/
|
|
137
|
-
export interface ResolvedRef {
|
|
138
|
-
/** The original ref that was resolved */
|
|
139
|
-
ref: Ref;
|
|
140
|
-
/** The final SHA-1 target after following all symbolic refs */
|
|
141
|
-
sha: string;
|
|
142
|
-
/** Chain of refs followed during resolution (for debugging/display) */
|
|
143
|
-
chain: Ref[];
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* Error thrown when a ref operation fails.
|
|
147
|
-
*
|
|
148
|
-
* @description
|
|
149
|
-
* Provides structured error information including error code
|
|
150
|
-
* and the ref name that caused the error.
|
|
151
|
-
*
|
|
152
|
-
* @example
|
|
153
|
-
* ```typescript
|
|
154
|
-
* try {
|
|
155
|
-
* await storage.updateRef('refs/heads/main', sha)
|
|
156
|
-
* } catch (e) {
|
|
157
|
-
* if (e instanceof RefError) {
|
|
158
|
-
* switch (e.code) {
|
|
159
|
-
* case 'NOT_FOUND': // Ref doesn't exist
|
|
160
|
-
* case 'CONFLICT': // CAS failed
|
|
161
|
-
* case 'LOCKED': // Ref is locked
|
|
162
|
-
* }
|
|
163
|
-
* }
|
|
164
|
-
* }
|
|
165
|
-
* ```
|
|
166
|
-
*/
|
|
167
|
-
export declare class RefError extends Error {
|
|
168
|
-
readonly code: RefErrorCode;
|
|
169
|
-
readonly refName?: string | undefined;
|
|
170
|
-
/**
|
|
171
|
-
* Create a new RefError.
|
|
172
|
-
*
|
|
173
|
-
* @param message - Human-readable error message
|
|
174
|
-
* @param code - Error code for programmatic handling
|
|
175
|
-
* @param refName - The ref that caused the error (optional)
|
|
176
|
-
*/
|
|
177
|
-
constructor(message: string, code: RefErrorCode, refName?: string | undefined);
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* Error codes for ref operations.
|
|
181
|
-
*
|
|
182
|
-
* @description
|
|
183
|
-
* - `NOT_FOUND`: Ref doesn't exist
|
|
184
|
-
* - `ALREADY_EXISTS`: Ref already exists (when creating)
|
|
185
|
-
* - `INVALID_NAME`: Ref name fails validation
|
|
186
|
-
* - `LOCKED`: Another process holds the ref lock
|
|
187
|
-
* - `CONFLICT`: CAS operation failed (value changed)
|
|
188
|
-
* - `CIRCULAR_REF`: Symbolic ref chain loops back on itself
|
|
189
|
-
* - `MAX_DEPTH_EXCEEDED`: Too many symbolic ref redirects
|
|
190
|
-
* - `INVALID_SHA`: SHA format is invalid
|
|
191
|
-
*/
|
|
192
|
-
export type RefErrorCode = 'NOT_FOUND' | 'ALREADY_EXISTS' | 'INVALID_NAME' | 'LOCKED' | 'CONFLICT' | 'CIRCULAR_REF' | 'MAX_DEPTH_EXCEEDED' | 'INVALID_SHA';
|
|
193
|
-
/**
|
|
194
|
-
* Lock handle for atomic ref updates.
|
|
195
|
-
*
|
|
196
|
-
* @description
|
|
197
|
-
* Ref locks prevent concurrent modifications to the same ref.
|
|
198
|
-
* Always release locks when done, preferably in a finally block.
|
|
199
|
-
*
|
|
200
|
-
* @example
|
|
201
|
-
* ```typescript
|
|
202
|
-
* const lock = await storage.acquireLock('refs/heads/main')
|
|
203
|
-
* try {
|
|
204
|
-
* const ref = await storage.getRef('refs/heads/main')
|
|
205
|
-
* // ... modify and write ref ...
|
|
206
|
-
* } finally {
|
|
207
|
-
* await lock.release()
|
|
208
|
-
* }
|
|
209
|
-
* ```
|
|
210
|
-
*/
|
|
211
|
-
export interface RefLock {
|
|
212
|
-
/** The ref being locked */
|
|
213
|
-
refName: string;
|
|
214
|
-
/** Release the lock - should be idempotent */
|
|
215
|
-
release(): Promise<void>;
|
|
216
|
-
/** Check if this lock is still held by us */
|
|
217
|
-
isHeld(): boolean;
|
|
218
|
-
}
|
|
219
|
-
/**
|
|
220
|
-
* Storage backend interface for refs.
|
|
221
|
-
*
|
|
222
|
-
* @description
|
|
223
|
-
* Implement this interface to provide ref storage.
|
|
224
|
-
* The backend is responsible for persistence, locking, and packed refs.
|
|
225
|
-
*/
|
|
226
|
-
export interface RefStorageBackend {
|
|
227
|
-
/**
|
|
228
|
-
* Read a single ref from storage.
|
|
229
|
-
*
|
|
230
|
-
* @param name - Full ref name
|
|
231
|
-
* @returns The ref or null if not found
|
|
232
|
-
*/
|
|
233
|
-
readRef(name: string): Promise<Ref | null>;
|
|
234
|
-
/**
|
|
235
|
-
* Write a ref to storage.
|
|
236
|
-
*
|
|
237
|
-
* @param ref - The ref to write
|
|
238
|
-
*/
|
|
239
|
-
writeRef(ref: Ref): Promise<void>;
|
|
240
|
-
/**
|
|
241
|
-
* Delete a ref from storage.
|
|
242
|
-
*
|
|
243
|
-
* @param name - Full ref name
|
|
244
|
-
* @returns True if deleted, false if not found
|
|
245
|
-
*/
|
|
246
|
-
deleteRef(name: string): Promise<boolean>;
|
|
247
|
-
/**
|
|
248
|
-
* List all refs matching a pattern.
|
|
249
|
-
*
|
|
250
|
-
* @param pattern - Optional glob pattern
|
|
251
|
-
* @returns Array of matching refs
|
|
252
|
-
*/
|
|
253
|
-
listRefs(pattern?: string): Promise<Ref[]>;
|
|
254
|
-
/**
|
|
255
|
-
* Acquire an exclusive lock on a ref.
|
|
256
|
-
*
|
|
257
|
-
* @param name - Full ref name
|
|
258
|
-
* @param timeout - Lock acquisition timeout in ms
|
|
259
|
-
* @returns Lock handle
|
|
260
|
-
* @throws RefError with code 'LOCKED' if lock cannot be acquired
|
|
261
|
-
*/
|
|
262
|
-
acquireLock(name: string, timeout?: number): Promise<RefLock>;
|
|
263
|
-
/**
|
|
264
|
-
* Read packed refs file.
|
|
265
|
-
*
|
|
266
|
-
* @returns Map of ref names to SHA values
|
|
267
|
-
*/
|
|
268
|
-
readPackedRefs(): Promise<Map<string, string>>;
|
|
269
|
-
/**
|
|
270
|
-
* Write packed refs file.
|
|
271
|
-
*
|
|
272
|
-
* @param refs - Map of ref names to SHA values
|
|
273
|
-
*/
|
|
274
|
-
writePackedRefs(refs: Map<string, string>): Promise<void>;
|
|
275
|
-
}
|
|
276
|
-
/**
|
|
277
|
-
* Options for creating a RefStorage instance.
|
|
278
|
-
*
|
|
279
|
-
* @description
|
|
280
|
-
* Supports two modes of operation:
|
|
281
|
-
* 1. Pass a RefStorageBackend directly for full features (locking, packed refs)
|
|
282
|
-
* 2. Pass options object with storageBackend for simpler StorageBackend integration
|
|
283
|
-
*
|
|
284
|
-
* When using StorageBackend:
|
|
285
|
-
* - Locking operations become no-ops (always succeed)
|
|
286
|
-
* - Packed refs operations are not available
|
|
287
|
-
* - Basic ref operations delegate to StorageBackend methods
|
|
288
|
-
*/
|
|
289
|
-
export interface RefStorageOptions {
|
|
290
|
-
/**
|
|
291
|
-
* Optional StorageBackend for simpler ref operations.
|
|
292
|
-
* When provided, ref operations delegate to this backend.
|
|
293
|
-
*/
|
|
294
|
-
storageBackend?: StorageBackend;
|
|
295
|
-
}
|
|
296
|
-
/**
|
|
297
|
-
* Validate a ref name according to Git rules.
|
|
298
|
-
*
|
|
299
|
-
* @description
|
|
300
|
-
* Git has specific rules for valid ref names. This function implements
|
|
301
|
-
* the validation from `git check-ref-format`.
|
|
302
|
-
*
|
|
303
|
-
* **Rules**:
|
|
304
|
-
* - Cannot be empty or just '@'
|
|
305
|
-
* - Cannot end with '/' or '.lock'
|
|
306
|
-
* - Cannot contain '..', '@{', control chars, space, ~, ^, :, ?, *, [, \
|
|
307
|
-
* - Components cannot start or end with '.'
|
|
308
|
-
* - HEAD is always valid
|
|
309
|
-
*
|
|
310
|
-
* @param name - Ref name to validate
|
|
311
|
-
* @returns True if the name is valid
|
|
312
|
-
*
|
|
313
|
-
* @see https://git-scm.com/docs/git-check-ref-format
|
|
314
|
-
*
|
|
315
|
-
* @example
|
|
316
|
-
* ```typescript
|
|
317
|
-
* isValidRefName('refs/heads/main') // true
|
|
318
|
-
* isValidRefName('refs/heads/feature/x') // true
|
|
319
|
-
* isValidRefName('HEAD') // true
|
|
320
|
-
* isValidRefName('refs/heads/../main') // false (contains ..)
|
|
321
|
-
* isValidRefName('refs/heads/.hidden') // false (component starts with .)
|
|
322
|
-
* isValidRefName('refs/heads/foo.lock') // false (ends with .lock)
|
|
323
|
-
* ```
|
|
324
|
-
*/
|
|
325
|
-
export declare function isValidRefName(name: string): boolean;
|
|
326
|
-
/**
|
|
327
|
-
* Validate a SHA-1 hash string.
|
|
328
|
-
*
|
|
329
|
-
* @description
|
|
330
|
-
* SHA-1 hashes must be exactly 40 hexadecimal characters.
|
|
331
|
-
* This validates the format, not whether the object exists.
|
|
332
|
-
*
|
|
333
|
-
* @param sha - SHA string to validate
|
|
334
|
-
* @returns True if the string is a valid SHA-1 format
|
|
335
|
-
*
|
|
336
|
-
* @example
|
|
337
|
-
* ```typescript
|
|
338
|
-
* isValidSha('abc123def456789...') // true (if 40 hex chars)
|
|
339
|
-
* isValidSha('abc123') // false (too short)
|
|
340
|
-
* isValidSha('xyz...') // false (invalid hex)
|
|
341
|
-
* isValidSha(null) // false
|
|
342
|
-
* ```
|
|
343
|
-
*/
|
|
344
|
-
export declare function isValidSha(sha: string): boolean;
|
|
345
|
-
/**
|
|
346
|
-
* Parse ref file content into type and target.
|
|
347
|
-
*
|
|
348
|
-
* @description
|
|
349
|
-
* Ref files either contain a SHA directly or "ref: <target>" for symbolic refs.
|
|
350
|
-
*
|
|
351
|
-
* @param content - Raw ref file content
|
|
352
|
-
* @returns Parsed type and target
|
|
353
|
-
*
|
|
354
|
-
* @example
|
|
355
|
-
* ```typescript
|
|
356
|
-
* // Direct ref
|
|
357
|
-
* parseRefContent('abc123def456...\n')
|
|
358
|
-
* // => { type: 'direct', target: 'abc123def456...' }
|
|
359
|
-
*
|
|
360
|
-
* // Symbolic ref
|
|
361
|
-
* parseRefContent('ref: refs/heads/main\n')
|
|
362
|
-
* // => { type: 'symbolic', target: 'refs/heads/main' }
|
|
363
|
-
* ```
|
|
364
|
-
*/
|
|
365
|
-
export declare function parseRefContent(content: string): {
|
|
366
|
-
type: RefType;
|
|
367
|
-
target: string;
|
|
368
|
-
};
|
|
369
|
-
/**
|
|
370
|
-
* Serialize a ref to file content format.
|
|
371
|
-
*
|
|
372
|
-
* @description
|
|
373
|
-
* Converts a Ref object to the string format stored in ref files.
|
|
374
|
-
*
|
|
375
|
-
* @param ref - Ref to serialize
|
|
376
|
-
* @returns File content string (with trailing newline)
|
|
377
|
-
*
|
|
378
|
-
* @example
|
|
379
|
-
* ```typescript
|
|
380
|
-
* serializeRefContent({ name: 'HEAD', target: 'refs/heads/main', type: 'symbolic' })
|
|
381
|
-
* // => 'ref: refs/heads/main\n'
|
|
382
|
-
*
|
|
383
|
-
* serializeRefContent({ name: 'refs/heads/main', target: 'abc123...', type: 'direct' })
|
|
384
|
-
* // => 'abc123...\n'
|
|
385
|
-
* ```
|
|
386
|
-
*/
|
|
387
|
-
export declare function serializeRefContent(ref: Ref): string;
|
|
388
|
-
/**
|
|
389
|
-
* Parse packed-refs file content.
|
|
390
|
-
*
|
|
391
|
-
* @description
|
|
392
|
-
* The packed-refs file contains multiple refs in a space-efficient format.
|
|
393
|
-
* Format: "<sha> <refname>" on each line, with optional comments (#) and
|
|
394
|
-
* peeled entries (^sha for annotated tags).
|
|
395
|
-
*
|
|
396
|
-
* @param content - Raw packed-refs file content
|
|
397
|
-
* @returns Map of ref names to SHA values
|
|
398
|
-
*
|
|
399
|
-
* @example
|
|
400
|
-
* ```typescript
|
|
401
|
-
* const content = `# pack-refs with: peeled fully-peeled sorted
|
|
402
|
-
* abc123 refs/heads/main
|
|
403
|
-
* def456 refs/tags/v1.0.0
|
|
404
|
-
* ^aaa111
|
|
405
|
-
* `
|
|
406
|
-
* const refs = parsePackedRefs(content)
|
|
407
|
-
* // Map { 'refs/heads/main' => 'abc123', 'refs/tags/v1.0.0' => 'def456' }
|
|
408
|
-
* ```
|
|
409
|
-
*/
|
|
410
|
-
export declare function parsePackedRefs(content: string): Map<string, string>;
|
|
411
|
-
/**
|
|
412
|
-
* Serialize refs to packed-refs file format.
|
|
413
|
-
*
|
|
414
|
-
* @description
|
|
415
|
-
* Creates the content for a packed-refs file from a map of refs.
|
|
416
|
-
* Refs are sorted alphabetically for consistency.
|
|
417
|
-
*
|
|
418
|
-
* @param refs - Map of ref names to SHA values
|
|
419
|
-
* @returns Packed-refs file content
|
|
420
|
-
*
|
|
421
|
-
* @example
|
|
422
|
-
* ```typescript
|
|
423
|
-
* const refs = new Map([
|
|
424
|
-
* ['refs/heads/main', 'abc123...'],
|
|
425
|
-
* ['refs/tags/v1.0.0', 'def456...']
|
|
426
|
-
* ])
|
|
427
|
-
* const content = serializePackedRefs(refs)
|
|
428
|
-
* // '# pack-refs with: peeled fully-peeled sorted\nabc123... refs/heads/main\n...'
|
|
429
|
-
* ```
|
|
430
|
-
*/
|
|
431
|
-
export declare function serializePackedRefs(refs: Map<string, string>): string;
|
|
432
|
-
/**
|
|
433
|
-
* Reference storage manager.
|
|
434
|
-
*
|
|
435
|
-
* @description
|
|
436
|
-
* Provides a high-level API for managing Git references. Handles ref
|
|
437
|
-
* resolution, updates with locking, symbolic refs, and packed refs.
|
|
438
|
-
*
|
|
439
|
-
* Supports two backend modes:
|
|
440
|
-
* 1. RefStorageBackend - Full features including locking and packed refs
|
|
441
|
-
* 2. StorageBackend - Simpler interface with basic ref operations
|
|
442
|
-
*
|
|
443
|
-
* @example
|
|
444
|
-
* ```typescript
|
|
445
|
-
* // With RefStorageBackend (full features)
|
|
446
|
-
* const storage = new RefStorage(myBackend)
|
|
447
|
-
*
|
|
448
|
-
* // With StorageBackend (simpler)
|
|
449
|
-
* const storage = new RefStorage({ storageBackend: myStorageBackend })
|
|
450
|
-
*
|
|
451
|
-
* // Get current branch
|
|
452
|
-
* const head = await storage.getHead()
|
|
453
|
-
* if (head.type === 'symbolic') {
|
|
454
|
-
* console.log(`On branch: ${head.target}`)
|
|
455
|
-
* }
|
|
456
|
-
*
|
|
457
|
-
* // Resolve to SHA
|
|
458
|
-
* const resolved = await storage.resolveRef('HEAD')
|
|
459
|
-
* console.log(`Current commit: ${resolved.sha}`)
|
|
460
|
-
*
|
|
461
|
-
* // Create a branch
|
|
462
|
-
* await storage.updateRef('refs/heads/feature', commitSha, { create: true })
|
|
463
|
-
* ```
|
|
464
|
-
*/
|
|
465
|
-
export declare class RefStorage {
|
|
466
|
-
private backend?;
|
|
467
|
-
private storageBackend?;
|
|
468
|
-
/**
|
|
469
|
-
* Create a new RefStorage instance.
|
|
470
|
-
*
|
|
471
|
-
* @param backendOrOptions - Either a RefStorageBackend directly, or options with storageBackend
|
|
472
|
-
*
|
|
473
|
-
* @example
|
|
474
|
-
* ```typescript
|
|
475
|
-
* // Direct backend
|
|
476
|
-
* const storage = new RefStorage(myRefStorageBackend)
|
|
477
|
-
*
|
|
478
|
-
* // Options with StorageBackend
|
|
479
|
-
* const storage = new RefStorage({ storageBackend: myStorageBackend })
|
|
480
|
-
* ```
|
|
481
|
-
*/
|
|
482
|
-
constructor(backendOrOptions: RefStorageBackend | RefStorageOptions);
|
|
483
|
-
/**
|
|
484
|
-
* Internal helper to get a lock (or no-op lock for StorageBackend).
|
|
485
|
-
*
|
|
486
|
-
* @description
|
|
487
|
-
* When using StorageBackend, returns a no-op lock since StorageBackend
|
|
488
|
-
* doesn't support locking. Callers should still use try/finally to release.
|
|
489
|
-
*/
|
|
490
|
-
private getLock;
|
|
491
|
-
/**
|
|
492
|
-
* Internal helper to write a ref.
|
|
493
|
-
*/
|
|
494
|
-
private writeRef;
|
|
495
|
-
/**
|
|
496
|
-
* Internal helper to delete a ref.
|
|
497
|
-
*/
|
|
498
|
-
private removeRef;
|
|
499
|
-
/**
|
|
500
|
-
* Internal helper to list refs.
|
|
501
|
-
*/
|
|
502
|
-
private getAllRefs;
|
|
503
|
-
/**
|
|
504
|
-
* Get a ref by name.
|
|
505
|
-
*
|
|
506
|
-
* @description
|
|
507
|
-
* Retrieves a ref without resolving symbolic refs.
|
|
508
|
-
* Use `resolveRef` to follow symbolic refs to their final target.
|
|
509
|
-
*
|
|
510
|
-
* @param name - Full ref name
|
|
511
|
-
* @returns The ref or null if not found
|
|
512
|
-
* @throws Error if no backend is configured
|
|
513
|
-
*
|
|
514
|
-
* @example
|
|
515
|
-
* ```typescript
|
|
516
|
-
* const head = await storage.getRef('HEAD')
|
|
517
|
-
* if (head && head.type === 'symbolic') {
|
|
518
|
-
* console.log(`HEAD points to ${head.target}`)
|
|
519
|
-
* }
|
|
520
|
-
* ```
|
|
521
|
-
*/
|
|
522
|
-
getRef(name: string): Promise<Ref | null>;
|
|
523
|
-
/**
|
|
524
|
-
* Resolve a ref to its final SHA target.
|
|
525
|
-
*
|
|
526
|
-
* @description
|
|
527
|
-
* Follows symbolic refs until reaching a direct ref, then returns
|
|
528
|
-
* the SHA and the chain of refs followed.
|
|
529
|
-
*
|
|
530
|
-
* @param name - Ref name to resolve
|
|
531
|
-
* @param options - Resolution options (maxDepth)
|
|
532
|
-
* @returns Resolved ref with SHA and chain
|
|
533
|
-
* @throws RefError with code 'NOT_FOUND' if ref doesn't exist
|
|
534
|
-
* @throws RefError with code 'CIRCULAR_REF' if circular reference detected
|
|
535
|
-
* @throws RefError with code 'MAX_DEPTH_EXCEEDED' if too many redirects
|
|
536
|
-
*
|
|
537
|
-
* @example
|
|
538
|
-
* ```typescript
|
|
539
|
-
* const resolved = await storage.resolveRef('HEAD')
|
|
540
|
-
* console.log(`SHA: ${resolved.sha}`)
|
|
541
|
-
* console.log(`Chain: ${resolved.chain.map(r => r.name).join(' -> ')}`)
|
|
542
|
-
* // Chain: HEAD -> refs/heads/main
|
|
543
|
-
* ```
|
|
544
|
-
*/
|
|
545
|
-
resolveRef(name: string, options?: ResolveRefOptions): Promise<ResolvedRef>;
|
|
546
|
-
/**
|
|
547
|
-
* Update or create a ref.
|
|
548
|
-
*
|
|
549
|
-
* @description
|
|
550
|
-
* Creates a new ref or updates an existing one. Supports atomic
|
|
551
|
-
* compare-and-swap operations via oldValue option.
|
|
552
|
-
*
|
|
553
|
-
* Note: For atomic operations, callers can acquire a lock via acquireLock()
|
|
554
|
-
* and pass it via options.lock to avoid double-locking.
|
|
555
|
-
*
|
|
556
|
-
* @param name - Full ref name
|
|
557
|
-
* @param target - SHA-1 hash to point to
|
|
558
|
-
* @param options - Update options (create, oldValue, force, lock)
|
|
559
|
-
* @returns The updated/created ref
|
|
560
|
-
* @throws RefError with code 'INVALID_NAME' if ref name is invalid
|
|
561
|
-
* @throws RefError with code 'INVALID_SHA' if SHA format is invalid
|
|
562
|
-
* @throws RefError with code 'ALREADY_EXISTS' if creating and ref exists
|
|
563
|
-
* @throws RefError with code 'CONFLICT' if oldValue doesn't match
|
|
564
|
-
* @throws RefError with code 'NOT_FOUND' if ref doesn't exist and not creating
|
|
565
|
-
*
|
|
566
|
-
* @example
|
|
567
|
-
* ```typescript
|
|
568
|
-
* // Create a new branch
|
|
569
|
-
* await storage.updateRef('refs/heads/feature', sha, { create: true })
|
|
570
|
-
*
|
|
571
|
-
* // Atomic update (fails if someone else modified)
|
|
572
|
-
* await storage.updateRef('refs/heads/main', newSha, { oldValue: currentSha })
|
|
573
|
-
*
|
|
574
|
-
* // Force update (skips fast-forward check)
|
|
575
|
-
* await storage.updateRef('refs/heads/main', sha, { force: true })
|
|
576
|
-
* ```
|
|
577
|
-
*/
|
|
578
|
-
updateRef(name: string, target: string, options?: UpdateRefOptions): Promise<Ref>;
|
|
579
|
-
/**
|
|
580
|
-
* Delete a ref.
|
|
581
|
-
*
|
|
582
|
-
* @description
|
|
583
|
-
* Removes a ref from storage. HEAD cannot be deleted.
|
|
584
|
-
* Uses locking for atomic compare-and-swap operations when oldValue is specified.
|
|
585
|
-
*
|
|
586
|
-
* @param name - Full ref name to delete
|
|
587
|
-
* @param options - Delete options (oldValue for CAS)
|
|
588
|
-
* @returns True if deleted, false if ref didn't exist
|
|
589
|
-
* @throws RefError with code 'INVALID_NAME' for HEAD or invalid names
|
|
590
|
-
* @throws RefError with code 'CONFLICT' if oldValue doesn't match
|
|
591
|
-
*
|
|
592
|
-
* @example
|
|
593
|
-
* ```typescript
|
|
594
|
-
* // Simple delete
|
|
595
|
-
* const deleted = await storage.deleteRef('refs/heads/old-branch')
|
|
596
|
-
*
|
|
597
|
-
* // Atomic delete (only if value matches)
|
|
598
|
-
* await storage.deleteRef('refs/heads/feature', { oldValue: expectedSha })
|
|
599
|
-
* ```
|
|
600
|
-
*/
|
|
601
|
-
deleteRef(name: string, options?: UpdateRefOptions): Promise<boolean>;
|
|
602
|
-
/**
|
|
603
|
-
* List refs matching a pattern.
|
|
604
|
-
*
|
|
605
|
-
* @description
|
|
606
|
-
* Returns refs filtered by pattern and options.
|
|
607
|
-
* By default, excludes HEAD and symbolic refs.
|
|
608
|
-
*
|
|
609
|
-
* @param options - Listing options (pattern, includeHead, includeSymbolic)
|
|
610
|
-
* @returns Array of matching refs
|
|
611
|
-
*
|
|
612
|
-
* @example
|
|
613
|
-
* ```typescript
|
|
614
|
-
* // List all refs
|
|
615
|
-
* const all = await storage.listRefs()
|
|
616
|
-
*
|
|
617
|
-
* // List branches only
|
|
618
|
-
* const branches = await storage.listRefs({ pattern: 'refs/heads/*' })
|
|
619
|
-
*
|
|
620
|
-
* // Include HEAD
|
|
621
|
-
* const withHead = await storage.listRefs({ includeHead: true })
|
|
622
|
-
* ```
|
|
623
|
-
*/
|
|
624
|
-
listRefs(options?: ListRefsOptions): Promise<Ref[]>;
|
|
625
|
-
/**
|
|
626
|
-
* List all branches.
|
|
627
|
-
*
|
|
628
|
-
* @description
|
|
629
|
-
* Convenience method to list refs under refs/heads/.
|
|
630
|
-
*
|
|
631
|
-
* @returns Array of branch refs
|
|
632
|
-
*
|
|
633
|
-
* @example
|
|
634
|
-
* ```typescript
|
|
635
|
-
* const branches = await storage.listBranches()
|
|
636
|
-
* for (const branch of branches) {
|
|
637
|
-
* console.log(branch.name.replace('refs/heads/', ''))
|
|
638
|
-
* }
|
|
639
|
-
* ```
|
|
640
|
-
*/
|
|
641
|
-
listBranches(): Promise<Ref[]>;
|
|
642
|
-
/**
|
|
643
|
-
* List all tags.
|
|
644
|
-
*
|
|
645
|
-
* @description
|
|
646
|
-
* Convenience method to list refs under refs/tags/.
|
|
647
|
-
*
|
|
648
|
-
* @returns Array of tag refs
|
|
649
|
-
*
|
|
650
|
-
* @example
|
|
651
|
-
* ```typescript
|
|
652
|
-
* const tags = await storage.listTags()
|
|
653
|
-
* for (const tag of tags) {
|
|
654
|
-
* console.log(tag.name.replace('refs/tags/', ''))
|
|
655
|
-
* }
|
|
656
|
-
* ```
|
|
657
|
-
*/
|
|
658
|
-
listTags(): Promise<Ref[]>;
|
|
659
|
-
/**
|
|
660
|
-
* Get HEAD ref.
|
|
661
|
-
*
|
|
662
|
-
* @description
|
|
663
|
-
* Returns the HEAD ref. Every repository should have HEAD.
|
|
664
|
-
*
|
|
665
|
-
* @returns The HEAD ref
|
|
666
|
-
* @throws RefError with code 'NOT_FOUND' if HEAD doesn't exist
|
|
667
|
-
*
|
|
668
|
-
* @example
|
|
669
|
-
* ```typescript
|
|
670
|
-
* const head = await storage.getHead()
|
|
671
|
-
* if (head.type === 'symbolic') {
|
|
672
|
-
* console.log(`On branch: ${head.target}`)
|
|
673
|
-
* } else {
|
|
674
|
-
* console.log(`Detached at: ${head.target}`)
|
|
675
|
-
* }
|
|
676
|
-
* ```
|
|
677
|
-
*/
|
|
678
|
-
getHead(): Promise<Ref>;
|
|
679
|
-
/**
|
|
680
|
-
* Update HEAD (can be symbolic or detached).
|
|
681
|
-
*
|
|
682
|
-
* @description
|
|
683
|
-
* Sets HEAD to point to a branch (symbolic) or commit (detached).
|
|
684
|
-
* Uses locking to ensure atomic updates to HEAD.
|
|
685
|
-
*
|
|
686
|
-
* @param target - Branch ref name (symbolic) or SHA (detached)
|
|
687
|
-
* @param symbolic - If true, create symbolic ref; if false, direct ref
|
|
688
|
-
* @returns The updated HEAD ref
|
|
689
|
-
*
|
|
690
|
-
* @example
|
|
691
|
-
* ```typescript
|
|
692
|
-
* // Switch to branch
|
|
693
|
-
* await storage.updateHead('refs/heads/main', true)
|
|
694
|
-
*
|
|
695
|
-
* // Detach HEAD at commit
|
|
696
|
-
* await storage.updateHead(commitSha, false)
|
|
697
|
-
* ```
|
|
698
|
-
*/
|
|
699
|
-
updateHead(target: string, symbolic?: boolean): Promise<Ref>;
|
|
700
|
-
/**
|
|
701
|
-
* Check if HEAD is detached.
|
|
702
|
-
*
|
|
703
|
-
* @description
|
|
704
|
-
* HEAD is detached when it points directly to a commit SHA
|
|
705
|
-
* rather than symbolically to a branch.
|
|
706
|
-
*
|
|
707
|
-
* @returns True if HEAD is detached (points to SHA directly)
|
|
708
|
-
*
|
|
709
|
-
* @example
|
|
710
|
-
* ```typescript
|
|
711
|
-
* if (await storage.isHeadDetached()) {
|
|
712
|
-
* console.log('You are in detached HEAD state')
|
|
713
|
-
* }
|
|
714
|
-
* ```
|
|
715
|
-
*/
|
|
716
|
-
isHeadDetached(): Promise<boolean>;
|
|
717
|
-
/**
|
|
718
|
-
* Create a symbolic ref.
|
|
719
|
-
*
|
|
720
|
-
* @description
|
|
721
|
-
* Creates a ref that points to another ref name (not a SHA).
|
|
722
|
-
* Used primarily for HEAD pointing to a branch.
|
|
723
|
-
* Uses locking to ensure atomic creation.
|
|
724
|
-
*
|
|
725
|
-
* @param name - Name for the new symbolic ref
|
|
726
|
-
* @param target - Target ref name (not SHA)
|
|
727
|
-
* @returns The created symbolic ref
|
|
728
|
-
* @throws RefError with code 'INVALID_NAME' if name is invalid
|
|
729
|
-
* @throws RefError with code 'CIRCULAR_REF' if name equals target
|
|
730
|
-
*
|
|
731
|
-
* @example
|
|
732
|
-
* ```typescript
|
|
733
|
-
* // Make HEAD point to main branch
|
|
734
|
-
* await storage.createSymbolicRef('HEAD', 'refs/heads/main')
|
|
735
|
-
* ```
|
|
736
|
-
*/
|
|
737
|
-
createSymbolicRef(name: string, target: string): Promise<Ref>;
|
|
738
|
-
/**
|
|
739
|
-
* Acquire a lock for updating a ref.
|
|
740
|
-
*
|
|
741
|
-
* @description
|
|
742
|
-
* Acquires an exclusive lock on a ref. Use this for complex operations
|
|
743
|
-
* that need to read-modify-write atomically.
|
|
744
|
-
*
|
|
745
|
-
* @param name - Full ref name to lock
|
|
746
|
-
* @param timeout - Lock acquisition timeout in milliseconds
|
|
747
|
-
* @returns Lock handle - must be released when done
|
|
748
|
-
*
|
|
749
|
-
* @example
|
|
750
|
-
* ```typescript
|
|
751
|
-
* const lock = await storage.acquireLock('refs/heads/main', 5000)
|
|
752
|
-
* try {
|
|
753
|
-
* // Perform atomic operations
|
|
754
|
-
* await storage.updateRef('refs/heads/main', sha, { lock })
|
|
755
|
-
* } finally {
|
|
756
|
-
* await lock.release()
|
|
757
|
-
* }
|
|
758
|
-
* ```
|
|
759
|
-
*/
|
|
760
|
-
acquireLock(name: string, timeout?: number): Promise<RefLock>;
|
|
761
|
-
/**
|
|
762
|
-
* Pack loose refs into packed-refs file.
|
|
763
|
-
*
|
|
764
|
-
* @description
|
|
765
|
-
* Consolidates loose ref files into a single packed-refs file.
|
|
766
|
-
* This improves performance for repositories with many refs.
|
|
767
|
-
* HEAD and symbolic refs are not packed.
|
|
768
|
-
*
|
|
769
|
-
* Uses a transactional approach by acquiring locks on all refs being packed
|
|
770
|
-
* to ensure consistency during the packing operation.
|
|
771
|
-
*
|
|
772
|
-
* @example
|
|
773
|
-
* ```typescript
|
|
774
|
-
* // After creating many branches/tags
|
|
775
|
-
* await storage.packRefs()
|
|
776
|
-
* ```
|
|
777
|
-
*/
|
|
778
|
-
packRefs(): Promise<void>;
|
|
779
|
-
}
|
|
780
|
-
/**
|
|
781
|
-
* Resolve a ref to its final SHA target.
|
|
782
|
-
*
|
|
783
|
-
* @description
|
|
784
|
-
* Convenience function that wraps RefStorage.resolveRef.
|
|
785
|
-
*
|
|
786
|
-
* @param storage - RefStorage instance
|
|
787
|
-
* @param name - Ref name to resolve
|
|
788
|
-
* @param options - Resolution options
|
|
789
|
-
* @returns The final SHA target
|
|
790
|
-
*
|
|
791
|
-
* @example
|
|
792
|
-
* ```typescript
|
|
793
|
-
* const sha = await resolveRef(storage, 'HEAD')
|
|
794
|
-
* ```
|
|
795
|
-
*/
|
|
796
|
-
export declare function resolveRef(storage: RefStorage, name: string, options?: ResolveRefOptions): Promise<string>;
|
|
797
|
-
/**
|
|
798
|
-
* Update a ref.
|
|
799
|
-
*
|
|
800
|
-
* @description
|
|
801
|
-
* Convenience function that wraps RefStorage.updateRef.
|
|
802
|
-
*
|
|
803
|
-
* @param storage - RefStorage instance
|
|
804
|
-
* @param name - Full ref name
|
|
805
|
-
* @param target - SHA target
|
|
806
|
-
* @param options - Update options
|
|
807
|
-
* @returns The updated ref
|
|
808
|
-
*/
|
|
809
|
-
export declare function updateRef(storage: RefStorage, name: string, target: string, options?: UpdateRefOptions): Promise<Ref>;
|
|
810
|
-
/**
|
|
811
|
-
* Delete a ref.
|
|
812
|
-
*
|
|
813
|
-
* @description
|
|
814
|
-
* Convenience function that wraps RefStorage.deleteRef.
|
|
815
|
-
*
|
|
816
|
-
* @param storage - RefStorage instance
|
|
817
|
-
* @param name - Full ref name to delete
|
|
818
|
-
* @param options - Delete options
|
|
819
|
-
* @returns True if deleted
|
|
820
|
-
*/
|
|
821
|
-
export declare function deleteRef(storage: RefStorage, name: string, options?: UpdateRefOptions): Promise<boolean>;
|
|
822
|
-
/**
|
|
823
|
-
* List refs.
|
|
824
|
-
*
|
|
825
|
-
* @description
|
|
826
|
-
* Convenience function that wraps RefStorage.listRefs.
|
|
827
|
-
*
|
|
828
|
-
* @param storage - RefStorage instance
|
|
829
|
-
* @param options - Listing options
|
|
830
|
-
* @returns Array of refs
|
|
831
|
-
*/
|
|
832
|
-
export declare function listRefs(storage: RefStorage, options?: ListRefsOptions): Promise<Ref[]>;
|
|
833
|
-
//# sourceMappingURL=storage.d.ts.map
|