@nimbus-sh/worker 0.9.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (286) hide show
  1. package/NOTICE.md +5 -0
  2. package/README.md +10 -0
  3. package/dist/_shared/session-router.d.ts +7 -0
  4. package/dist/_shared/session-router.d.ts.map +1 -1
  5. package/dist/_shared/session-router.js +7 -0
  6. package/dist/bindings/body.d.ts +6 -0
  7. package/dist/bindings/body.d.ts.map +1 -0
  8. package/dist/bindings/body.js +37 -0
  9. package/dist/bindings/kv.d.ts +0 -2
  10. package/dist/bindings/kv.d.ts.map +1 -1
  11. package/dist/bindings/kv.js +3 -42
  12. package/dist/bindings/r2.d.ts +0 -2
  13. package/dist/bindings/r2.d.ts.map +1 -1
  14. package/dist/bindings/r2.js +4 -44
  15. package/dist/esbuild-cli-artifact.generated.d.ts +18 -0
  16. package/dist/esbuild-cli-artifact.generated.d.ts.map +1 -0
  17. package/dist/esbuild-cli-artifact.generated.js +17 -0
  18. package/dist/esbuild-wasm-bundle.generated.d.ts +24 -24
  19. package/dist/esbuild-wasm-bundle.generated.d.ts.map +1 -1
  20. package/dist/esbuild-wasm-bundle.generated.js +24 -24
  21. package/dist/facets/cirrus-real.d.ts.map +1 -1
  22. package/dist/facets/cirrus-real.js +11 -6
  23. package/dist/facets/compose.d.ts +11 -7
  24. package/dist/facets/compose.d.ts.map +1 -1
  25. package/dist/facets/compose.js +8 -31
  26. package/dist/facets/data-plan.d.ts +79 -0
  27. package/dist/facets/data-plan.d.ts.map +1 -0
  28. package/dist/facets/data-plan.js +477 -0
  29. package/dist/facets/esbuild-bundle-pool.d.ts +1 -1
  30. package/dist/facets/esbuild-bundle-pool.js +3 -3
  31. package/dist/facets/esbuild-transform.d.ts +38 -8
  32. package/dist/facets/esbuild-transform.d.ts.map +1 -1
  33. package/dist/facets/esbuild-transform.js +219 -19
  34. package/dist/facets/exec-telemetry.d.ts +7 -3
  35. package/dist/facets/exec-telemetry.d.ts.map +1 -1
  36. package/dist/facets/manager.d.ts +198 -69
  37. package/dist/facets/manager.d.ts.map +1 -1
  38. package/dist/facets/manager.js +1276 -652
  39. package/dist/facets/opencode-staging.d.ts +0 -2
  40. package/dist/facets/opencode-staging.d.ts.map +1 -1
  41. package/dist/facets/opencode-staging.js +5 -11
  42. package/dist/facets/process.d.ts +4 -0
  43. package/dist/facets/process.d.ts.map +1 -1
  44. package/dist/facets/process.js +3 -0
  45. package/dist/facets/read-profile.d.ts +149 -0
  46. package/dist/facets/read-profile.d.ts.map +1 -0
  47. package/dist/facets/read-profile.js +483 -0
  48. package/dist/facets/real-vite-hmr.d.ts +2 -0
  49. package/dist/facets/real-vite-hmr.d.ts.map +1 -1
  50. package/dist/facets/real-vite-hmr.js +3 -2
  51. package/dist/facets/resident-identity.d.ts +0 -1
  52. package/dist/facets/resident-identity.d.ts.map +1 -1
  53. package/dist/facets/resident-identity.js +0 -3
  54. package/dist/facets/wasm-swap-registry.d.ts +34 -25
  55. package/dist/facets/wasm-swap-registry.d.ts.map +1 -1
  56. package/dist/facets/wasm-swap-registry.js +62 -56
  57. package/dist/facets/ws-terminal.d.ts +4 -4
  58. package/dist/facets/ws-terminal.d.ts.map +1 -1
  59. package/dist/facets/ws-terminal.js +4 -5
  60. package/dist/git/commands.d.ts +33 -10
  61. package/dist/git/commands.d.ts.map +1 -1
  62. package/dist/git/commands.js +1891 -197
  63. package/dist/git/network-facet.d.ts +12 -2
  64. package/dist/git/network-facet.d.ts.map +1 -1
  65. package/dist/git/network-facet.js +69 -18
  66. package/dist/git/unified-diff.d.ts +74 -0
  67. package/dist/git/unified-diff.d.ts.map +1 -0
  68. package/dist/git/unified-diff.js +676 -0
  69. package/dist/git-bundle.generated.d.ts +7 -11
  70. package/dist/git-bundle.generated.d.ts.map +1 -1
  71. package/dist/git-bundle.generated.js +7 -11
  72. package/dist/hosted/commands.d.ts.map +1 -1
  73. package/dist/hosted/commands.js +64 -245
  74. package/dist/hosted/runtime.d.ts +22 -15
  75. package/dist/hosted/runtime.d.ts.map +1 -1
  76. package/dist/hosted/runtime.js +72 -14
  77. package/dist/hosted/services.d.ts +8 -1
  78. package/dist/hosted/services.d.ts.map +1 -1
  79. package/dist/hosted/services.js +12 -13
  80. package/dist/hosted/session.d.ts +165 -0
  81. package/dist/hosted/session.d.ts.map +1 -0
  82. package/dist/hosted/session.js +132 -0
  83. package/dist/loaders/generated-workers.d.ts +6 -3
  84. package/dist/loaders/generated-workers.d.ts.map +1 -1
  85. package/dist/loaders/generated-workers.js +8 -5
  86. package/dist/loaders/npm-resolve-preamble.d.ts.map +1 -1
  87. package/dist/loaders/npm-resolve-preamble.js +0 -27
  88. package/dist/loaders/pre-bundle-preamble.d.ts +6 -3
  89. package/dist/loaders/pre-bundle-preamble.d.ts.map +1 -1
  90. package/dist/loaders/pre-bundle-preamble.js +13 -8
  91. package/dist/node-shims-artifact.generated.d.ts +13 -4
  92. package/dist/node-shims-artifact.generated.d.ts.map +1 -1
  93. package/dist/node-shims-artifact.generated.js +16 -7
  94. package/dist/npm/bin-links.d.ts +3 -1
  95. package/dist/npm/bin-links.d.ts.map +1 -1
  96. package/dist/npm/bin-links.js +32 -8
  97. package/dist/npm/cache.d.ts +11 -1
  98. package/dist/npm/cache.d.ts.map +1 -1
  99. package/dist/npm/cache.js +21 -7
  100. package/dist/npm/install-batch-facet.d.ts +4 -2
  101. package/dist/npm/install-batch-facet.d.ts.map +1 -1
  102. package/dist/npm/install-batch-facet.js +32 -18
  103. package/dist/npm/installer.d.ts +23 -3
  104. package/dist/npm/installer.d.ts.map +1 -1
  105. package/dist/npm/installer.js +330 -131
  106. package/dist/npm/npx-install.d.ts +3 -1
  107. package/dist/npm/npx-install.d.ts.map +1 -1
  108. package/dist/npm/npx-install.js +4 -1
  109. package/dist/npm/package-lock.d.ts +32 -0
  110. package/dist/npm/package-lock.d.ts.map +1 -0
  111. package/dist/npm/package-lock.js +65 -0
  112. package/dist/npm/placement.d.ts +16 -0
  113. package/dist/npm/placement.d.ts.map +1 -0
  114. package/dist/npm/placement.js +33 -0
  115. package/dist/npm/pre-bundle-facet.d.ts +1 -30
  116. package/dist/npm/pre-bundle-facet.d.ts.map +1 -1
  117. package/dist/npm/pre-bundle-facet.js +3 -5
  118. package/dist/npm/r2-cache.d.ts +12 -6
  119. package/dist/npm/r2-cache.d.ts.map +1 -1
  120. package/dist/npm/r2-cache.js +34 -16
  121. package/dist/npm/resolve-one-facet.d.ts +3 -0
  122. package/dist/npm/resolve-one-facet.d.ts.map +1 -1
  123. package/dist/npm/resolve-one-facet.js +15 -3
  124. package/dist/npm/resolver.d.ts +11 -13
  125. package/dist/npm/resolver.d.ts.map +1 -1
  126. package/dist/npm/resolver.js +12 -25
  127. package/dist/opencode-artifact.generated.js +2 -2
  128. package/dist/replica/routing.d.ts +2 -38
  129. package/dist/replica/routing.d.ts.map +1 -1
  130. package/dist/replica/routing.js +3 -55
  131. package/dist/router/index.d.ts.map +1 -1
  132. package/dist/router/index.js +15 -2
  133. package/dist/router/public-directory.d.ts +18 -0
  134. package/dist/router/public-directory.d.ts.map +1 -1
  135. package/dist/router/public-directory.js +1 -1
  136. package/dist/router/remote-api.d.ts +3 -1
  137. package/dist/router/remote-api.d.ts.map +1 -1
  138. package/dist/router/remote-api.js +42 -79
  139. package/dist/runtime/bash-repl.js +2 -2
  140. package/dist/runtime/bun-repl.d.ts.map +1 -1
  141. package/dist/runtime/bun-repl.js +2 -13
  142. package/dist/runtime/cpython-resident.d.ts.map +1 -1
  143. package/dist/runtime/cpython-resident.js +2 -10
  144. package/dist/runtime/esbuild-wasm-bytes.d.ts +37 -18
  145. package/dist/runtime/esbuild-wasm-bytes.d.ts.map +1 -1
  146. package/dist/runtime/esbuild-wasm-bytes.js +66 -92
  147. package/dist/runtime/facet-loader-host.d.ts.map +1 -1
  148. package/dist/runtime/facet-loader-host.js +0 -7
  149. package/dist/runtime/git-bundle-artifact.d.ts +17 -0
  150. package/dist/runtime/git-bundle-artifact.d.ts.map +1 -0
  151. package/dist/runtime/git-bundle-artifact.js +25 -0
  152. package/dist/runtime/node-repl.d.ts.map +1 -1
  153. package/dist/runtime/node-repl.js +2 -13
  154. package/dist/runtime/node-shims-artifact.d.ts +22 -23
  155. package/dist/runtime/node-shims-artifact.d.ts.map +1 -1
  156. package/dist/runtime/node-shims-artifact.js +48 -78
  157. package/dist/runtime/node-shims.d.ts.map +1 -1
  158. package/dist/runtime/node-shims.js +2358 -996
  159. package/dist/runtime/opencode-artifact.d.ts.map +1 -1
  160. package/dist/runtime/opencode-artifact.js +17 -53
  161. package/dist/runtime/opencode-facet-runner.d.ts +3 -6
  162. package/dist/runtime/opencode-facet-runner.d.ts.map +1 -1
  163. package/dist/runtime/opencode-facet-runner.js +45 -10
  164. package/dist/runtime/opentui-wasm-bytes.d.ts.map +1 -1
  165. package/dist/runtime/opentui-wasm-bytes.js +16 -49
  166. package/dist/runtime/package-manager.d.ts +0 -2
  167. package/dist/runtime/package-manager.d.ts.map +1 -1
  168. package/dist/runtime/package-manager.js +0 -3
  169. package/dist/runtime/python-repl.d.ts.map +1 -1
  170. package/dist/runtime/python-repl.js +4 -35
  171. package/dist/runtime/repl-session.d.ts +10 -0
  172. package/dist/runtime/repl-session.d.ts.map +1 -1
  173. package/dist/runtime/repl-session.js +7 -0
  174. package/dist/runtime/ruby-repl.d.ts.map +1 -1
  175. package/dist/runtime/ruby-repl.js +2 -2
  176. package/dist/runtime/ruby-resident.d.ts.map +1 -1
  177. package/dist/runtime/ruby-resident.js +41 -51
  178. package/dist/runtime/runtime-catalog.d.ts +10 -3
  179. package/dist/runtime/runtime-catalog.d.ts.map +1 -1
  180. package/dist/runtime/runtime-catalog.js +125 -15
  181. package/dist/runtime/sqlite-wasm-bytes.d.ts +4 -4
  182. package/dist/runtime/sqlite-wasm-bytes.d.ts.map +1 -1
  183. package/dist/runtime/sqlite-wasm-bytes.js +21 -57
  184. package/dist/runtime/staged-source.d.ts +67 -0
  185. package/dist/runtime/staged-source.d.ts.map +1 -0
  186. package/dist/runtime/staged-source.js +113 -0
  187. package/dist/runtime/wasi/preamble.d.ts +0 -22
  188. package/dist/runtime/wasi/preamble.d.ts.map +1 -1
  189. package/dist/runtime/wasi/preamble.js +98 -1425
  190. package/dist/runtime-catalog.generated.js +1 -1
  191. package/dist/session/agent.d.ts +14 -2
  192. package/dist/session/agent.d.ts.map +1 -1
  193. package/dist/session/agent.js +57 -19
  194. package/dist/session/ai.d.ts +0 -11
  195. package/dist/session/ai.d.ts.map +1 -1
  196. package/dist/session/ai.js +0 -4
  197. package/dist/session/fs-watch.d.ts +0 -11
  198. package/dist/session/fs-watch.d.ts.map +1 -1
  199. package/dist/session/fs-watch.js +0 -21
  200. package/dist/session/hibernation.d.ts +68 -2
  201. package/dist/session/hibernation.d.ts.map +1 -1
  202. package/dist/session/hibernation.js +95 -1
  203. package/dist/session/init-phases.d.ts +1 -2
  204. package/dist/session/init-phases.d.ts.map +1 -1
  205. package/dist/session/init-phases.js +1 -2
  206. package/dist/session/init.d.ts.map +1 -1
  207. package/dist/session/init.js +7 -20
  208. package/dist/session/keys.d.ts +0 -3
  209. package/dist/session/keys.d.ts.map +1 -1
  210. package/dist/session/keys.js +0 -3
  211. package/dist/session/legacy-reset.d.ts +11 -0
  212. package/dist/session/legacy-reset.d.ts.map +1 -0
  213. package/dist/session/legacy-reset.js +16 -0
  214. package/dist/session/nimbus-session.d.ts +50 -16
  215. package/dist/session/nimbus-session.d.ts.map +1 -1
  216. package/dist/session/nimbus-session.js +77 -71
  217. package/dist/session/npm-install-port.d.ts.map +1 -1
  218. package/dist/session/npm-install-port.js +2 -0
  219. package/dist/session/programmatic.d.ts +13 -18
  220. package/dist/session/programmatic.d.ts.map +1 -1
  221. package/dist/session/programmatic.js +53 -39
  222. package/dist/session/replica-routes.d.ts +2 -3
  223. package/dist/session/replica-routes.d.ts.map +1 -1
  224. package/dist/session/replica-routes.js +3 -10
  225. package/dist/session/routes.d.ts.map +1 -1
  226. package/dist/session/routes.js +11 -12
  227. package/dist/session/rpc.d.ts +108 -21
  228. package/dist/session/rpc.d.ts.map +1 -1
  229. package/dist/session/rpc.js +194 -39
  230. package/dist/session/start-real-vite.js +2 -2
  231. package/dist/session/state-store.d.ts +1 -17
  232. package/dist/session/state-store.d.ts.map +1 -1
  233. package/dist/session/state-store.js +3 -53
  234. package/dist/session/supervisor-op.d.ts +7 -0
  235. package/dist/session/supervisor-op.d.ts.map +1 -1
  236. package/dist/session/supervisor-op.js +6 -1
  237. package/dist/session/supervisor-rpc.d.ts +116 -19
  238. package/dist/session/supervisor-rpc.d.ts.map +1 -1
  239. package/dist/session/supervisor-rpc.js +194 -84
  240. package/dist/session/vite-command.d.ts.map +1 -1
  241. package/dist/session/vite-command.js +17 -14
  242. package/dist/session/ws.d.ts.map +1 -1
  243. package/dist/session/ws.js +20 -8
  244. package/dist/shell/npm-bin-entrypoints.d.ts.map +1 -1
  245. package/dist/shell/npm-bin-entrypoints.js +30 -5
  246. package/dist/vfs/facet-resident-limits.d.ts +33 -0
  247. package/dist/vfs/facet-resident-limits.d.ts.map +1 -0
  248. package/dist/vfs/facet-resident-limits.js +33 -0
  249. package/dist/vfs/facet-resident-store.d.ts +2 -10
  250. package/dist/vfs/facet-resident-store.d.ts.map +1 -1
  251. package/dist/vfs/facet-resident-store.js +1594 -219
  252. package/dist/workspace-host.d.ts +3 -1
  253. package/dist/workspace-host.d.ts.map +1 -1
  254. package/dist/workspace-host.js +2 -0
  255. package/dist/wrangler/nimbus-wrangler.d.ts +0 -2
  256. package/dist/wrangler/nimbus-wrangler.d.ts.map +1 -1
  257. package/dist/wrangler/nimbus-wrangler.js +8 -22
  258. package/package.json +34 -7
  259. package/public/_assets/esbuild-0.24.2.js +2380 -0
  260. package/public/_assets/opencode/1.16.2/index-attach.js +2 -2
  261. package/public/_assets/runtime/esbuild-cli-c4fda380d52befc1.js +6892 -0
  262. package/public/_assets/runtime/git-de3e60c9f3ff006a.js +103 -0
  263. package/public/_assets/runtime/{node-shims-acaa037e6d26ec0d.js → node-shims-06565b121555c194.js} +2879 -992
  264. package/public/_assets/runtime/resident-store-6ffb1939c53d982f.js +2264 -0
  265. package/public/_assets/runtime/vfs-write-ledger-e501e8fc793bc2c1.js +889 -0
  266. package/scripts/build-opencode-attach-entry.mjs +51 -1
  267. package/scripts/bundle-esbuild-wasm.mjs +55 -39
  268. package/scripts/bundle-facet-workers.mjs +159 -10
  269. package/scripts/bundle-git.mjs +88 -27
  270. package/scripts/bundle-node-shims.mjs +72 -46
  271. package/scripts/bundle-runtime.mjs +18 -421
  272. package/scripts/cf-git-patch.mjs +137 -0
  273. package/scripts/patch-install-deps.mjs +49 -96
  274. package/scripts/runtime-specs.mjs +435 -0
  275. package/vendor/git-http.generated.d.ts +82 -0
  276. package/vendor/git-upstream.generated.d.ts +4378 -0
  277. package/vendor/git.LICENSE +7 -0
  278. package/vendor/git.generated.d.mts +21 -0
  279. package/vendor/git.generated.mjs +103 -0
  280. package/dist/replica/suspension.d.ts +0 -36
  281. package/dist/replica/suspension.d.ts.map +0 -1
  282. package/dist/replica/suspension.js +0 -49
  283. package/dist/runtime/static-server.d.ts +0 -3
  284. package/dist/runtime/static-server.d.ts.map +0 -1
  285. package/dist/runtime/static-server.js +0 -133
  286. package/scripts/clean-dist.mjs +0 -7
@@ -0,0 +1,4378 @@
1
+ // Generated by scripts/bundle-git.mjs from the pinned cf-git declarations.
2
+ export default index;
3
+ export type TreeEntry = {
4
+ /**
5
+ * - the 6 digit hexadecimal mode
6
+ */
7
+ mode: string;
8
+ /**
9
+ * - the name of the file or directory
10
+ */
11
+ path: string;
12
+ /**
13
+ * - the SHA-1 object id of the blob or tree
14
+ */
15
+ oid: string;
16
+ /**
17
+ * - the type of object
18
+ */
19
+ type: "commit" | "blob" | "tree";
20
+ };
21
+ /**
22
+ * - The object returned has the following schema:
23
+ */
24
+ export type ReadTreeResult = {
25
+ /**
26
+ * - SHA-1 object id of this tree
27
+ */
28
+ oid: string;
29
+ /**
30
+ * - the parsed tree object
31
+ */
32
+ tree: TreeObject;
33
+ };
34
+ /**
35
+ * - The object returned has the following schema:
36
+ */
37
+ export type FetchResult = {
38
+ /**
39
+ * - The branch that is cloned if no branch is specified
40
+ */
41
+ defaultBranch: string | null;
42
+ /**
43
+ * - The SHA-1 object id of the fetched head commit
44
+ */
45
+ fetchHead: string | null;
46
+ /**
47
+ * - a textual description of the branch that was fetched
48
+ */
49
+ fetchHeadDescription: string | null;
50
+ /**
51
+ * - The HTTP response headers returned by the git server
52
+ */
53
+ headers?: {
54
+ [x: string]: string;
55
+ } | undefined;
56
+ /**
57
+ * - A list of branches that were pruned, if you provided the `prune` parameter
58
+ */
59
+ pruned?: string[] | undefined;
60
+ };
61
+ /**
62
+ * - Returns an object with a schema like this:
63
+ */
64
+ export type MergeResult = {
65
+ /**
66
+ * - The SHA-1 object id that is now at the head of the branch. Absent only if `dryRun` was specified and `mergeCommit` is true.
67
+ */
68
+ oid?: string | undefined;
69
+ /**
70
+ * - True if the branch was already merged so no changes were made
71
+ */
72
+ alreadyMerged?: boolean | undefined;
73
+ /**
74
+ * - True if it was a fast-forward merge
75
+ */
76
+ fastForward?: boolean | undefined;
77
+ /**
78
+ * - True if merge resulted in a merge commit
79
+ */
80
+ mergeCommit?: boolean | undefined;
81
+ /**
82
+ * - The SHA-1 object id of the tree resulting from a merge commit
83
+ */
84
+ tree?: string | undefined;
85
+ };
86
+ /**
87
+ * - The object returned has the following schema:
88
+ */
89
+ export type GetRemoteInfoResult = {
90
+ /**
91
+ * - The list of capabilities returned by the server (part of the Git protocol)
92
+ */
93
+ capabilities: string[];
94
+ refs?: any;
95
+ /**
96
+ * - The default branch of the remote
97
+ */
98
+ HEAD?: string | undefined;
99
+ /**
100
+ * - The branches on the remote
101
+ */
102
+ heads?: {
103
+ [x: string]: string;
104
+ } | undefined;
105
+ /**
106
+ * - The special branches representing pull requests (non-standard)
107
+ */
108
+ pull?: {
109
+ [x: string]: string;
110
+ } | undefined;
111
+ /**
112
+ * - The tags on the remote
113
+ */
114
+ tags?: {
115
+ [x: string]: string;
116
+ } | undefined;
117
+ };
118
+ /**
119
+ * - This object has the following schema:
120
+ */
121
+ export type GetRemoteInfo2Result = {
122
+ /**
123
+ * - Git protocol version the server supports
124
+ */
125
+ protocolVersion: 1 | 2;
126
+ /**
127
+ * - An object of capabilities represented as keys and values
128
+ */
129
+ capabilities: {
130
+ [x: string]: string | true;
131
+ };
132
+ /**
133
+ * - Server refs (they get returned by protocol version 1 whether you want them or not)
134
+ */
135
+ refs?: ServerRef[] | undefined;
136
+ };
137
+ /**
138
+ * - The object returned has the following schema:
139
+ */
140
+ export type HashBlobResult = {
141
+ /**
142
+ * - The SHA-1 object id
143
+ */
144
+ oid: string;
145
+ /**
146
+ * - The type of the object
147
+ */
148
+ type: "blob";
149
+ /**
150
+ * - The wrapped git object (the thing that is hashed)
151
+ */
152
+ object: Uint8Array;
153
+ /**
154
+ * - The format of the object
155
+ */
156
+ format: "wrapped";
157
+ };
158
+ /**
159
+ * - This object has the following schema:
160
+ */
161
+ export type ServerRef = {
162
+ /**
163
+ * - The name of the ref
164
+ */
165
+ ref: string;
166
+ /**
167
+ * - The SHA-1 object id the ref points to
168
+ */
169
+ oid: string;
170
+ /**
171
+ * - The target ref pointed to by a symbolic ref
172
+ */
173
+ target?: string | undefined;
174
+ /**
175
+ * - If the oid is the SHA-1 object id of an annotated tag, this is the SHA-1 object id that the annotated tag points to
176
+ */
177
+ peeled?: string | undefined;
178
+ };
179
+ /**
180
+ * The packObjects command returns an object with two properties:
181
+ */
182
+ export type PackObjectsResult = {
183
+ /**
184
+ * - The suggested filename for the packfile if you want to save it to disk somewhere. It includes the packfile SHA.
185
+ */
186
+ filename: string;
187
+ /**
188
+ * - The packfile contents. Not present if `write` parameter was true, in which case the packfile was written straight to disk.
189
+ */
190
+ packfile?: Uint8Array<ArrayBuffer> | undefined;
191
+ };
192
+ /**
193
+ * - The object returned has the following schema:
194
+ */
195
+ export type ReadBlobResult = {
196
+ oid: string;
197
+ blob: Uint8Array;
198
+ };
199
+ export type DeflatedObject = {
200
+ oid: string;
201
+ type: "deflated";
202
+ format: "deflated";
203
+ object: Uint8Array;
204
+ source?: string | undefined;
205
+ };
206
+ export type WrappedObject = {
207
+ oid: string;
208
+ type: "wrapped";
209
+ format: "wrapped";
210
+ object: Uint8Array;
211
+ source?: string | undefined;
212
+ };
213
+ export type RawObject = {
214
+ oid: string;
215
+ type: "blob" | "commit" | "tree" | "tag";
216
+ format: "content";
217
+ object: Uint8Array;
218
+ source?: string | undefined;
219
+ };
220
+ export type ParsedBlobObject = {
221
+ oid: string;
222
+ type: "blob";
223
+ format: "parsed";
224
+ object: string;
225
+ source?: string | undefined;
226
+ };
227
+ export type ParsedCommitObject = {
228
+ oid: string;
229
+ type: "commit";
230
+ format: "parsed";
231
+ object: CommitObject;
232
+ source?: string | undefined;
233
+ };
234
+ export type ParsedTreeObject = {
235
+ oid: string;
236
+ type: "tree";
237
+ format: "parsed";
238
+ object: TreeObject;
239
+ source?: string | undefined;
240
+ };
241
+ export type ParsedTagObject = {
242
+ oid: string;
243
+ type: "tag";
244
+ format: "parsed";
245
+ object: TagObject;
246
+ source?: string | undefined;
247
+ };
248
+ export type ParsedObject = ParsedBlobObject | ParsedCommitObject | ParsedTreeObject | ParsedTagObject;
249
+ export type ReadObjectResult = DeflatedObject | WrappedObject | RawObject | ParsedObject;
250
+ /**
251
+ * - The object returned has the following schema:
252
+ */
253
+ export type ReadTagResult = {
254
+ /**
255
+ * - SHA-1 object id of this tag
256
+ */
257
+ oid: string;
258
+ /**
259
+ * - the parsed tag object
260
+ */
261
+ tag: TagObject;
262
+ /**
263
+ * - PGP signing payload
264
+ */
265
+ payload: string;
266
+ };
267
+ export type WalkerMap = (filename: string, entries: Array<WalkerEntry | null>) => Promise<any>;
268
+ export type WalkerReduce = (parent: any, children: any[]) => Promise<any>;
269
+ export type WalkerIterateCallback = (entries: WalkerEntry[]) => Promise<any[]>;
270
+ export type WalkerIterate = (walk: WalkerIterateCallback, children: IterableIterator<WalkerEntry[]>) => Promise<any[]>;
271
+ export type GitProgressEvent = {
272
+ phase: string;
273
+ loaded: number;
274
+ total: number;
275
+ };
276
+ export type ProgressCallback = (progress: GitProgressEvent) => void | Promise<void>;
277
+ export type GitHttpRequest = {
278
+ /**
279
+ * - The URL to request
280
+ */
281
+ url: string;
282
+ /**
283
+ * - The HTTP method to use
284
+ */
285
+ method?: string | undefined;
286
+ /**
287
+ * - Headers to include in the HTTP request
288
+ */
289
+ headers?: {
290
+ [x: string]: string;
291
+ } | undefined;
292
+ /**
293
+ * - An HTTP or HTTPS agent that manages connections for the HTTP client (Node.js only)
294
+ */
295
+ agent?: any;
296
+ /**
297
+ * - An async iterator of Uint8Arrays that make up the body of POST requests
298
+ */
299
+ body?: AsyncIterableIterator<Uint8Array>;
300
+ /**
301
+ * - Reserved for future use (emitting `GitProgressEvent`s)
302
+ */
303
+ onProgress?: ProgressCallback | undefined;
304
+ /**
305
+ * - Reserved for future use (canceling a request)
306
+ */
307
+ signal?: object;
308
+ };
309
+ export type GitHttpResponse = {
310
+ /**
311
+ * - The final URL that was fetched after any redirects
312
+ */
313
+ url: string;
314
+ /**
315
+ * - The HTTP method that was used
316
+ */
317
+ method?: string | undefined;
318
+ /**
319
+ * - HTTP response headers
320
+ */
321
+ headers?: {
322
+ [x: string]: string;
323
+ } | undefined;
324
+ /**
325
+ * - An async iterator of Uint8Arrays that make up the body of the response
326
+ */
327
+ body?: AsyncIterableIterator<Uint8Array>;
328
+ /**
329
+ * - The HTTP status code
330
+ */
331
+ statusCode: number;
332
+ /**
333
+ * - The HTTP status message
334
+ */
335
+ statusMessage: string;
336
+ };
337
+ export type HttpFetch = (request: GitHttpRequest) => Promise<GitHttpResponse>;
338
+ export type HttpClient = {
339
+ request: HttpFetch;
340
+ };
341
+ /**
342
+ * A git commit object.
343
+ */
344
+ export type CommitObject = {
345
+ /**
346
+ * Commit message
347
+ */
348
+ message: string;
349
+ /**
350
+ * SHA-1 object id of corresponding file tree
351
+ */
352
+ tree: string;
353
+ /**
354
+ * an array of zero or more SHA-1 object ids
355
+ */
356
+ parent: string[];
357
+ author: {
358
+ name: string;
359
+ email: string;
360
+ timestamp: number;
361
+ timezoneOffset: number;
362
+ };
363
+ committer: {
364
+ name: string;
365
+ email: string;
366
+ timestamp: number;
367
+ timezoneOffset: number;
368
+ };
369
+ /**
370
+ * PGP signature (if present)
371
+ */
372
+ gpgsig?: string | undefined;
373
+ };
374
+ /**
375
+ * A git tree object. Trees represent a directory snapshot.
376
+ */
377
+ export type TreeObject = TreeEntry[];
378
+ /**
379
+ * A git annotated tag object.
380
+ */
381
+ export type TagObject = {
382
+ /**
383
+ * SHA-1 object id of object being tagged
384
+ */
385
+ object: string;
386
+ /**
387
+ * the type of the object being tagged
388
+ */
389
+ type: "blob" | "tree" | "commit" | "tag";
390
+ /**
391
+ * the tag name
392
+ */
393
+ tag: string;
394
+ tagger: {
395
+ name: string;
396
+ email: string;
397
+ timestamp: number;
398
+ timezoneOffset: number;
399
+ };
400
+ /**
401
+ * tag message
402
+ */
403
+ message: string;
404
+ /**
405
+ * PGP signature (if present)
406
+ */
407
+ gpgsig?: string | undefined;
408
+ };
409
+ export type ReadCommitResult = {
410
+ /**
411
+ * - SHA-1 object id of this commit
412
+ */
413
+ oid: string;
414
+ /**
415
+ * - the parsed commit object
416
+ */
417
+ commit: CommitObject;
418
+ /**
419
+ * - PGP signing payload
420
+ */
421
+ payload: string;
422
+ };
423
+ export type Walker = {
424
+ /**
425
+ * ('GitWalkerSymbol')
426
+ */
427
+ Symbol: Symbol;
428
+ };
429
+ /**
430
+ * Normalized subset of filesystem `stat` data:
431
+ */
432
+ export type Stat = {
433
+ ctimeSeconds: number;
434
+ ctimeNanoseconds: number;
435
+ mtimeSeconds: number;
436
+ mtimeNanoseconds: number;
437
+ dev: number;
438
+ ino: number;
439
+ mode: number;
440
+ uid: number;
441
+ gid: number;
442
+ size: number;
443
+ };
444
+ /**
445
+ * The `WalkerEntry` is an interface that abstracts computing many common tree / blob stats.
446
+ */
447
+ export type WalkerEntry = {
448
+ type: () => Promise<"tree" | "blob" | "special" | "commit">;
449
+ mode: () => Promise<number>;
450
+ oid: () => Promise<string>;
451
+ content: () => Promise<Uint8Array | void>;
452
+ stat: () => Promise<Stat>;
453
+ };
454
+ export type CallbackFsClient = {
455
+ /**
456
+ * - https://nodejs.org/api/fs.html#fs_fs_readfile_path_options_callback
457
+ */
458
+ readFile: Function;
459
+ /**
460
+ * - https://nodejs.org/api/fs.html#fs_fs_writefile_file_data_options_callback
461
+ */
462
+ writeFile: Function;
463
+ /**
464
+ * - https://nodejs.org/api/fs.html#fs_fs_unlink_path_callback
465
+ */
466
+ unlink: Function;
467
+ /**
468
+ * - https://nodejs.org/api/fs.html#fs_fs_readdir_path_options_callback
469
+ */
470
+ readdir: Function;
471
+ /**
472
+ * - https://nodejs.org/api/fs.html#fs_fs_mkdir_path_mode_callback
473
+ */
474
+ mkdir: Function;
475
+ /**
476
+ * - https://nodejs.org/api/fs.html#fs_fs_rmdir_path_callback
477
+ */
478
+ rmdir: Function;
479
+ /**
480
+ * - https://nodejs.org/api/fs.html#fs_fs_stat_path_options_callback
481
+ */
482
+ stat: Function;
483
+ /**
484
+ * - https://nodejs.org/api/fs.html#fs_fs_lstat_path_options_callback
485
+ */
486
+ lstat: Function;
487
+ /**
488
+ * - https://nodejs.org/api/fs.html#fs_fs_readlink_path_options_callback
489
+ */
490
+ readlink?: Function | undefined;
491
+ /**
492
+ * - https://nodejs.org/api/fs.html#fs_fs_symlink_target_path_type_callback
493
+ */
494
+ symlink?: Function | undefined;
495
+ /**
496
+ * - https://nodejs.org/api/fs.html#fs_fs_chmod_path_mode_callback
497
+ */
498
+ chmod?: Function | undefined;
499
+ };
500
+ export type PromiseFsClient = {
501
+ promises: {
502
+ readFile: Function;
503
+ writeFile: Function;
504
+ unlink: Function;
505
+ readdir: Function;
506
+ mkdir: Function;
507
+ rmdir: Function;
508
+ stat: Function;
509
+ lstat: Function;
510
+ readlink?: Function | undefined;
511
+ symlink?: Function | undefined;
512
+ chmod?: Function | undefined;
513
+ };
514
+ };
515
+ export type FsClient = CallbackFsClient | PromiseFsClient;
516
+ export type MessageCallback = (message: string) => void | Promise<void>;
517
+ export type GitAuth = {
518
+ username?: string | undefined;
519
+ password?: string | undefined;
520
+ headers?: {
521
+ [x: string]: string;
522
+ } | undefined;
523
+ /**
524
+ * Tells git to throw a `UserCanceledError` (instead of an `HttpError`).
525
+ */
526
+ cancel?: boolean | undefined;
527
+ };
528
+ export type AuthCallback = (url: string, auth: GitAuth) => GitAuth | void | Promise<GitAuth | void>;
529
+ export type AuthFailureCallback = (url: string, auth: GitAuth) => GitAuth | void | Promise<GitAuth | void>;
530
+ export type AuthSuccessCallback = (url: string, auth: GitAuth) => void | Promise<void>;
531
+ export type SignParams = {
532
+ /**
533
+ * - a plaintext message
534
+ */
535
+ payload: string;
536
+ /**
537
+ * - an 'ASCII armor' encoded PGP key (technically can actually contain _multiple_ keys)
538
+ */
539
+ secretKey: string;
540
+ };
541
+ export type SignCallback = (args: SignParams) => {
542
+ signature: string;
543
+ } | Promise<{
544
+ signature: string;
545
+ }>;
546
+ export type MergeDriverParams = {
547
+ branches: Array<string>;
548
+ contents: Array<string>;
549
+ path: string;
550
+ };
551
+ export type MergeDriverCallback = (args: MergeDriverParams) => {
552
+ cleanMerge: boolean;
553
+ mergedText: string;
554
+ } | Promise<{
555
+ cleanMerge: boolean;
556
+ mergedText: string;
557
+ }>;
558
+ export type RefUpdateStatus = {
559
+ ok: boolean;
560
+ error: string;
561
+ };
562
+ export type PushResult = {
563
+ ok: boolean;
564
+ error: string | null;
565
+ refs: {
566
+ [x: string]: RefUpdateStatus;
567
+ };
568
+ headers?: {
569
+ [x: string]: string;
570
+ } | undefined;
571
+ };
572
+ export type HeadStatus = 0 | 1;
573
+ export type WorkdirStatus = 0 | 1 | 2;
574
+ export type StageStatus = 0 | 1 | 2 | 3;
575
+ export type StatusRow = [string, HeadStatus, WorkdirStatus, StageStatus];
576
+ /**
577
+ * the type of stash ops
578
+ */
579
+ export type StashOp = "push" | "pop" | "apply" | "drop" | "list" | "clear";
580
+ /**
581
+ * - when compare WORDIR to HEAD, 'remove' could mean 'untracked'
582
+ */
583
+ export type StashChangeType = "equal" | "modify" | "add" | "remove" | "unknown";
584
+ export type ClientRef = {
585
+ /**
586
+ * The name of the ref
587
+ */
588
+ ref: string;
589
+ /**
590
+ * The SHA-1 object id the ref points to
591
+ */
592
+ oid: string;
593
+ };
594
+ export type PrePushParams = {
595
+ /**
596
+ * The expanded name of target remote
597
+ */
598
+ remote: string;
599
+ /**
600
+ * The URL address of target remote
601
+ */
602
+ url: string;
603
+ /**
604
+ * The ref which the client wants to push to the remote
605
+ */
606
+ localRef: ClientRef;
607
+ /**
608
+ * The ref which is known by the remote
609
+ */
610
+ remoteRef: ClientRef;
611
+ };
612
+ export type PrePushCallback = (args: PrePushParams) => boolean | Promise<boolean>;
613
+ export type PostCheckoutParams = {
614
+ /**
615
+ * The SHA-1 object id of HEAD before checkout
616
+ */
617
+ previousHead: string;
618
+ /**
619
+ * The SHA-1 object id of HEAD after checkout
620
+ */
621
+ newHead: string;
622
+ /**
623
+ * flag determining whether a branch or a set of files was checked
624
+ */
625
+ type: "branch" | "file";
626
+ };
627
+ export type PostCheckoutCallback = (args: PostCheckoutParams) => void | Promise<void>;
628
+ declare namespace index {
629
+ export { Errors };
630
+ export { STAGE };
631
+ export { TREE };
632
+ export { WORKDIR };
633
+ export { add };
634
+ export { abortMerge };
635
+ export { addNote };
636
+ export { addRemote };
637
+ export { annotatedTag };
638
+ export { branch };
639
+ export { checkout };
640
+ export { clone };
641
+ export { commit };
642
+ export { getConfig };
643
+ export { getConfigAll };
644
+ export { setConfig };
645
+ export { currentBranch };
646
+ export { deleteBranch };
647
+ export { deleteRef };
648
+ export { deleteRemote };
649
+ export { deleteTag };
650
+ export { expandOid };
651
+ export { expandRef };
652
+ export { fastForward };
653
+ export { fetch };
654
+ export { findMergeBase };
655
+ export { findRoot };
656
+ export { getRemoteInfo };
657
+ export { getRemoteInfo2 };
658
+ export { hashBlob };
659
+ export { indexPack };
660
+ export { init };
661
+ export { isDescendent };
662
+ export { isIgnored };
663
+ export { listBranches };
664
+ export { listFiles };
665
+ export { listNotes };
666
+ export { listRefs };
667
+ export { listRemotes };
668
+ export { listServerRefs };
669
+ export { listTags };
670
+ export { log };
671
+ export { merge };
672
+ export { packObjects };
673
+ export { pull };
674
+ export { push };
675
+ export { readBlob };
676
+ export { readCommit };
677
+ export { readNote };
678
+ export { readObject };
679
+ export { readTag };
680
+ export { readTree };
681
+ export { remove };
682
+ export { removeNote };
683
+ export { renameBranch };
684
+ export { resetIndex };
685
+ export { updateIndex$1 as updateIndex };
686
+ export { resolveRef };
687
+ export { status };
688
+ export { statusMatrix };
689
+ export { tag };
690
+ export { version };
691
+ export { walk };
692
+ export { writeBlob };
693
+ export { writeCommit };
694
+ export { writeObject };
695
+ export { writeRef };
696
+ export { writeTag };
697
+ export { writeTree };
698
+ export { stash };
699
+ }
700
+ export var Errors: Readonly<{
701
+ __proto__: null;
702
+ AlreadyExistsError: typeof AlreadyExistsError;
703
+ AmbiguousError: typeof AmbiguousError;
704
+ CheckoutConflictError: typeof CheckoutConflictError;
705
+ CommitNotFetchedError: typeof CommitNotFetchedError;
706
+ EmptyServerResponseError: typeof EmptyServerResponseError;
707
+ FastForwardError: typeof FastForwardError;
708
+ GitPushError: typeof GitPushError;
709
+ HttpError: typeof HttpError;
710
+ InternalError: typeof InternalError;
711
+ InvalidFilepathError: typeof InvalidFilepathError;
712
+ InvalidOidError: typeof InvalidOidError;
713
+ InvalidRefNameError: typeof InvalidRefNameError;
714
+ MaxDepthError: typeof MaxDepthError;
715
+ MergeNotSupportedError: typeof MergeNotSupportedError;
716
+ MergeConflictError: typeof MergeConflictError;
717
+ MissingNameError: typeof MissingNameError;
718
+ MissingParameterError: typeof MissingParameterError;
719
+ MultipleGitError: typeof MultipleGitError;
720
+ NoRefspecError: typeof NoRefspecError;
721
+ NotFoundError: typeof NotFoundError;
722
+ ObjectTypeError: typeof ObjectTypeError;
723
+ ParseError: typeof ParseError;
724
+ PushRejectedError: typeof PushRejectedError;
725
+ RemoteCapabilityError: typeof RemoteCapabilityError;
726
+ SmartHttpError: typeof SmartHttpError;
727
+ UnknownTransportError: typeof UnknownTransportError;
728
+ UnsafeFilepathError: typeof UnsafeFilepathError;
729
+ UrlParseError: typeof UrlParseError;
730
+ UserCanceledError: typeof UserCanceledError;
731
+ UnmergedPathsError: typeof UnmergedPathsError;
732
+ IndexResetError: typeof IndexResetError;
733
+ NoCommitError: typeof NoCommitError;
734
+ }>;
735
+ /**
736
+ * @returns {Walker}
737
+ */
738
+ export function STAGE(): Walker;
739
+ /**
740
+ * @param {object} args
741
+ * @param {string} [args.ref='HEAD']
742
+ * @returns {Walker}
743
+ */
744
+ export function TREE({ ref }?: {
745
+ ref?: string | undefined;
746
+ }): Walker;
747
+ /**
748
+ * @returns {Walker}
749
+ */
750
+ export function WORKDIR(): Walker;
751
+ /**
752
+ * Abort a merge in progress.
753
+ *
754
+ * Based on the behavior of git reset --merge, i.e. "Resets the index and updates the files in the working tree that are different between <commit> and HEAD, but keeps those which are different between the index and working tree (i.e. which have changes which have not been added). If a file that is different between <commit> and the index has unstaged changes, reset is aborted."
755
+ *
756
+ * Essentially, abortMerge will reset any files affected by merge conflicts to their last known good version at HEAD.
757
+ * Any unstaged changes are saved and any staged changes are reset as well.
758
+ *
759
+ * NOTE: The behavior of this command differs slightly from canonical git in that an error will be thrown if a file exists in the index and nowhere else.
760
+ * Canonical git will reset the file and continue aborting the merge in this case.
761
+ *
762
+ * **WARNING:** Running git merge with non-trivial uncommitted changes is discouraged: while possible, it may leave you in a state that is hard to back out of in the case of a conflict.
763
+ * If there were uncommitted changes when the merge started (and especially if those changes were further modified after the merge was started), `git.abortMerge` will in some cases be unable to reconstruct the original (pre-merge) changes.
764
+ *
765
+ * @param {object} args
766
+ * @param {FsClient} args.fs - a file system implementation
767
+ * @param {string} args.dir - The [working tree](dir-vs-gitdir.md) directory path
768
+ * @param {string} [args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path
769
+ * @param {string} [args.commit='HEAD'] - commit to reset the index and worktree to, defaults to HEAD
770
+ * @param {object} [args.cache] - a [cache](cache.md) object
771
+ *
772
+ * @returns {Promise<void>} Resolves successfully once the git index has been updated
773
+ *
774
+ */
775
+ export function abortMerge({ fs: _fs, dir, gitdir, commit, cache, }: {
776
+ fs: FsClient;
777
+ dir: string;
778
+ gitdir?: string | undefined;
779
+ commit?: string | undefined;
780
+ cache?: object;
781
+ }): Promise<void>;
782
+ /**
783
+ * Add a file to the git index (aka staging area)
784
+ *
785
+ * @param {object} args
786
+ * @param {FsClient} args.fs - a file system implementation
787
+ * @param {string} args.dir - The [working tree](dir-vs-gitdir.md) directory path
788
+ * @param {string} [args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path
789
+ * @param {string|string[]} args.filepath - The path to the file to add to the index
790
+ * @param {object} [args.cache] - a [cache](cache.md) object
791
+ * @param {boolean} [args.force=false] - add to index even if matches gitignore. Think `git add --force`
792
+ * @param {boolean} [args.parallel=false] - process each input file in parallel. Parallel processing will result in more memory consumption but less process time
793
+ *
794
+ * @returns {Promise<void>} Resolves successfully once the git index has been updated
795
+ *
796
+ * @example
797
+ * await fs.promises.writeFile('/tutorial/README.md', `# TEST`)
798
+ * await git.add({ fs, dir: '/tutorial', filepath: 'README.md' })
799
+ * console.log('done')
800
+ *
801
+ */
802
+ export function add({ fs: _fs, dir, gitdir, filepath, cache, force, parallel, }: {
803
+ fs: FsClient;
804
+ dir: string;
805
+ gitdir?: string | undefined;
806
+ filepath: string | string[];
807
+ cache?: object;
808
+ force?: boolean | undefined;
809
+ parallel?: boolean | undefined;
810
+ }): Promise<void>;
811
+ /**
812
+ * Add or update an object note
813
+ *
814
+ * @param {object} args
815
+ * @param {FsClient} args.fs - a file system implementation
816
+ * @param {SignCallback} [args.onSign] - a PGP signing implementation
817
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
818
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
819
+ * @param {string} [args.ref] - The notes ref to look under
820
+ * @param {string} args.oid - The SHA-1 object id of the object to add the note to.
821
+ * @param {string|Uint8Array} args.note - The note to add
822
+ * @param {boolean} [args.force] - Over-write note if it already exists.
823
+ * @param {Object} [args.author] - The details about the author.
824
+ * @param {string} [args.author.name] - Default is `user.name` config.
825
+ * @param {string} [args.author.email] - Default is `user.email` config.
826
+ * @param {number} [args.author.timestamp=Math.floor(Date.now()/1000)] - Set the author timestamp field. This is the integer number of seconds since the Unix epoch (1970-01-01 00:00:00).
827
+ * @param {number} [args.author.timezoneOffset] - Set the author timezone offset field. This is the difference, in minutes, from the current timezone to UTC. Default is `(new Date()).getTimezoneOffset()`.
828
+ * @param {Object} [args.committer = author] - The details about the note committer, in the same format as the author parameter. If not specified, the author details are used.
829
+ * @param {string} [args.committer.name] - Default is `user.name` config.
830
+ * @param {string} [args.committer.email] - Default is `user.email` config.
831
+ * @param {number} [args.committer.timestamp=Math.floor(Date.now()/1000)] - Set the committer timestamp field. This is the integer number of seconds since the Unix epoch (1970-01-01 00:00:00).
832
+ * @param {number} [args.committer.timezoneOffset] - Set the committer timezone offset field. This is the difference, in minutes, from the current timezone to UTC. Default is `(new Date()).getTimezoneOffset()`.
833
+ * @param {string} [args.signingKey] - Sign the note commit using this private PGP key.
834
+ * @param {object} [args.cache] - a [cache](cache.md) object
835
+ *
836
+ * @returns {Promise<string>} Resolves successfully with the SHA-1 object id of the commit object for the added note.
837
+ */
838
+ export function addNote({ fs: _fs, onSign, dir, gitdir, ref, oid, note, force, author: _author, committer: _committer, signingKey, cache, }: {
839
+ fs: FsClient;
840
+ onSign?: SignCallback | undefined;
841
+ dir?: string | undefined;
842
+ gitdir?: string | undefined;
843
+ ref?: string | undefined;
844
+ oid: string;
845
+ note: string | Uint8Array;
846
+ force?: boolean | undefined;
847
+ author?: {
848
+ name?: string | undefined;
849
+ email?: string | undefined;
850
+ timestamp?: number | undefined;
851
+ timezoneOffset?: number | undefined;
852
+ } | undefined;
853
+ committer?: {
854
+ name?: string | undefined;
855
+ email?: string | undefined;
856
+ timestamp?: number | undefined;
857
+ timezoneOffset?: number | undefined;
858
+ } | undefined;
859
+ signingKey?: string | undefined;
860
+ cache?: object;
861
+ }): Promise<string>;
862
+ /**
863
+ * Add or update a remote
864
+ *
865
+ * @param {object} args
866
+ * @param {FsClient} args.fs - a file system implementation
867
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
868
+ * @param {string} [args.gitdir] - [required] The [git directory](dir-vs-gitdir.md) path
869
+ * @param {string} args.remote - The name of the remote
870
+ * @param {string} args.url - The URL of the remote
871
+ * @param {boolean} [args.force = false] - Instead of throwing an error if a remote named `remote` already exists, overwrite the existing remote.
872
+ *
873
+ * @returns {Promise<void>} Resolves successfully when filesystem operations are complete
874
+ *
875
+ * @example
876
+ * await git.addRemote({
877
+ * fs,
878
+ * dir: '/tutorial',
879
+ * remote: 'upstream',
880
+ * url: 'https://github.com/isomorphic-git/isomorphic-git'
881
+ * })
882
+ * console.log('done')
883
+ *
884
+ */
885
+ export function addRemote({ fs, dir, gitdir, remote, url, force, }: {
886
+ fs: FsClient;
887
+ dir?: string | undefined;
888
+ gitdir?: string | undefined;
889
+ remote: string;
890
+ url: string;
891
+ force?: boolean | undefined;
892
+ }): Promise<void>;
893
+ /**
894
+ * Create an annotated tag.
895
+ *
896
+ * @param {object} args
897
+ * @param {FsClient} args.fs - a file system implementation
898
+ * @param {SignCallback} [args.onSign] - a PGP signing implementation
899
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
900
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
901
+ * @param {string} args.ref - What to name the tag
902
+ * @param {string} [args.message = ref] - The tag message to use.
903
+ * @param {string} [args.object = 'HEAD'] - The SHA-1 object id the tag points to. (Will resolve to a SHA-1 object id if value is a ref.) By default, the commit object which is referred by the current `HEAD` is used.
904
+ * @param {object} [args.tagger] - The details about the tagger.
905
+ * @param {string} [args.tagger.name] - Default is `user.name` config.
906
+ * @param {string} [args.tagger.email] - Default is `user.email` config.
907
+ * @param {number} [args.tagger.timestamp=Math.floor(Date.now()/1000)] - Set the tagger timestamp field. This is the integer number of seconds since the Unix epoch (1970-01-01 00:00:00).
908
+ * @param {number} [args.tagger.timezoneOffset] - Set the tagger timezone offset field. This is the difference, in minutes, from the current timezone to UTC. Default is `(new Date()).getTimezoneOffset()`.
909
+ * @param {string} [args.gpgsig] - The gpgsig attached to the tag object. (Mutually exclusive with the `signingKey` option.)
910
+ * @param {string} [args.signingKey] - Sign the tag object using this private PGP key. (Mutually exclusive with the `gpgsig` option.)
911
+ * @param {boolean} [args.force = false] - Instead of throwing an error if a tag named `ref` already exists, overwrite the existing tag. Note that this option does not modify the original tag object itself.
912
+ * @param {object} [args.cache] - a [cache](cache.md) object
913
+ *
914
+ * @returns {Promise<void>} Resolves successfully when filesystem operations are complete
915
+ *
916
+ * @example
917
+ * await git.annotatedTag({
918
+ * fs,
919
+ * dir: '/tutorial',
920
+ * ref: 'test-tag',
921
+ * message: 'This commit is awesome',
922
+ * tagger: {
923
+ * name: 'Mr. Test',
924
+ * email: 'mrtest@example.com'
925
+ * }
926
+ * })
927
+ * console.log('done')
928
+ *
929
+ */
930
+ export function annotatedTag({ fs: _fs, onSign, dir, gitdir, ref, tagger: _tagger, message, gpgsig, object, signingKey, force, cache, }: {
931
+ fs: FsClient;
932
+ onSign?: SignCallback | undefined;
933
+ dir?: string | undefined;
934
+ gitdir?: string | undefined;
935
+ ref: string;
936
+ message?: string | undefined;
937
+ object?: string | undefined;
938
+ tagger?: {
939
+ name?: string | undefined;
940
+ email?: string | undefined;
941
+ timestamp?: number | undefined;
942
+ timezoneOffset?: number | undefined;
943
+ } | undefined;
944
+ gpgsig?: string | undefined;
945
+ signingKey?: string | undefined;
946
+ force?: boolean | undefined;
947
+ cache?: object;
948
+ }): Promise<void>;
949
+ /**
950
+ * Create a branch
951
+ *
952
+ * @param {object} args
953
+ * @param {FsClient} args.fs - a file system implementation
954
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
955
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
956
+ * @param {string} args.ref - What to name the branch
957
+ * @param {string} [args.object = 'HEAD'] - What oid to use as the start point. Accepts a symbolic ref.
958
+ * @param {boolean} [args.checkout = false] - Update `HEAD` to point at the newly created branch
959
+ * @param {boolean} [args.force = false] - Instead of throwing an error if a branched named `ref` already exists, overwrite the existing branch.
960
+ *
961
+ * @returns {Promise<void>} Resolves successfully when filesystem operations are complete
962
+ *
963
+ * @example
964
+ * await git.branch({ fs, dir: '/tutorial', ref: 'develop' })
965
+ * console.log('done')
966
+ *
967
+ */
968
+ export function branch({ fs, dir, gitdir, ref, object, checkout, force, }: {
969
+ fs: FsClient;
970
+ dir?: string | undefined;
971
+ gitdir?: string | undefined;
972
+ ref: string;
973
+ object?: string | undefined;
974
+ checkout?: boolean | undefined;
975
+ force?: boolean | undefined;
976
+ }): Promise<void>;
977
+ /**
978
+ * Checkout a branch
979
+ *
980
+ * If the branch already exists it will check out that branch. Otherwise, it will create a new remote tracking branch set to track the remote branch of that name.
981
+ *
982
+ * @param {object} args
983
+ * @param {FsClient} args.fs - a file system implementation
984
+ * @param {ProgressCallback} [args.onProgress] - optional progress event callback
985
+ * @param {PostCheckoutCallback} [args.onPostCheckout] - optional post-checkout hook callback
986
+ * @param {string} args.dir - The [working tree](dir-vs-gitdir.md) directory path
987
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
988
+ * @param {string} [args.ref = 'HEAD'] - Source to checkout files from
989
+ * @param {string[]} [args.filepaths] - Limit the checkout to the given files and directories
990
+ * @param {string} [args.remote = 'origin'] - Which remote repository to use
991
+ * @param {boolean} [args.noCheckout = false] - If true, will update HEAD but won't update the working directory
992
+ * @param {boolean} [args.noUpdateHead] - If true, will update the working directory but won't update HEAD. Defaults to `false` when `ref` is provided, and `true` if `ref` is not provided.
993
+ * @param {boolean} [args.dryRun = false] - If true, simulates a checkout so you can test whether it would succeed.
994
+ * @param {boolean} [args.force = false] - If true, conflicts will be ignored and files will be overwritten regardless of local changes.
995
+ * @param {boolean} [args.track = true] - If false, will not set the remote branch tracking information. Defaults to true.
996
+ * @param {object} [args.cache] - a [cache](cache.md) object
997
+ * @param {boolean} [args.nonBlocking = false] - If true, will use non-blocking file system operations to allow for better performance in certain environments (For example, in Browsers)
998
+ * @param {number} [args.batchSize = 100] - If args.nonBlocking is true, batchSize is the number of files to process at a time avoid blocking the executing thread. The default value of 100 is a good starting point.
999
+ *
1000
+ * @returns {Promise<void>} Resolves successfully when filesystem operations are complete
1001
+ *
1002
+ * @example
1003
+ * // switch to the main branch
1004
+ * await git.checkout({
1005
+ * fs,
1006
+ * dir: '/tutorial',
1007
+ * ref: 'main'
1008
+ * })
1009
+ * console.log('done')
1010
+ *
1011
+ * @example
1012
+ * // restore the 'docs' and 'src/docs' folders to the way they were, overwriting any changes
1013
+ * await git.checkout({
1014
+ * fs,
1015
+ * dir: '/tutorial',
1016
+ * force: true,
1017
+ * filepaths: ['docs', 'src/docs']
1018
+ * })
1019
+ * console.log('done')
1020
+ *
1021
+ * @example
1022
+ * // restore the 'docs' and 'src/docs' folders to the way they are in the 'develop' branch, overwriting any changes
1023
+ * await git.checkout({
1024
+ * fs,
1025
+ * dir: '/tutorial',
1026
+ * ref: 'develop',
1027
+ * noUpdateHead: true,
1028
+ * force: true,
1029
+ * filepaths: ['docs', 'src/docs']
1030
+ * })
1031
+ * console.log('done')
1032
+ */
1033
+ export function checkout({ fs, onProgress, onPostCheckout, dir, gitdir, remote, ref: _ref, filepaths, noCheckout, noUpdateHead, dryRun, force, track, cache, nonBlocking, batchSize, }: {
1034
+ fs: FsClient;
1035
+ onProgress?: ProgressCallback | undefined;
1036
+ onPostCheckout?: PostCheckoutCallback | undefined;
1037
+ dir: string;
1038
+ gitdir?: string | undefined;
1039
+ ref?: string | undefined;
1040
+ filepaths?: string[] | undefined;
1041
+ remote?: string | undefined;
1042
+ noCheckout?: boolean | undefined;
1043
+ noUpdateHead?: boolean | undefined;
1044
+ dryRun?: boolean | undefined;
1045
+ force?: boolean | undefined;
1046
+ track?: boolean | undefined;
1047
+ cache?: object;
1048
+ nonBlocking?: boolean | undefined;
1049
+ batchSize?: number | undefined;
1050
+ }): Promise<void>;
1051
+ /**
1052
+ * Clone a repository
1053
+ *
1054
+ * @param {object} args
1055
+ * @param {FsClient} args.fs - a file system implementation
1056
+ * @param {HttpClient} args.http - an HTTP client
1057
+ * @param {ProgressCallback} [args.onProgress] - optional progress event callback
1058
+ * @param {MessageCallback} [args.onMessage] - optional message event callback
1059
+ * @param {AuthCallback} [args.onAuth] - optional auth fill callback
1060
+ * @param {AuthFailureCallback} [args.onAuthFailure] - optional auth rejected callback
1061
+ * @param {AuthSuccessCallback} [args.onAuthSuccess] - optional auth approved callback
1062
+ * @param {PostCheckoutCallback} [args.onPostCheckout] - optional post-checkout hook callback
1063
+ * @param {string} args.dir - The [working tree](dir-vs-gitdir.md) directory path
1064
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
1065
+ * @param {string} args.url - The URL of the remote repository
1066
+ * @param {string} [args.corsProxy] - Optional [CORS proxy](https://www.npmjs.com/%40isomorphic-git/cors-proxy). Value is stored in the git config file for that repo.
1067
+ * @param {string} [args.ref] - Which branch to checkout. By default this is the designated "main branch" of the repository.
1068
+ * @param {boolean} [args.singleBranch = false] - Instead of the default behavior of fetching all the branches, only fetch a single branch.
1069
+ * @param {boolean} [args.noCheckout = false] - If true, clone will only fetch the repo, not check out a branch. Skipping checkout can save a lot of time normally spent writing files to disk.
1070
+ * @param {boolean} [args.noTags = false] - By default clone will fetch all tags. `noTags` disables that behavior.
1071
+ * @param {string} [args.remote = 'origin'] - What to name the remote that is created.
1072
+ * @param {number} [args.depth] - Integer. Determines how much of the git repository's history to retrieve
1073
+ * @param {Date} [args.since] - Only fetch commits created after the given date. Mutually exclusive with `depth`.
1074
+ * @param {string[]} [args.exclude = []] - A list of branches or tags. Instructs the remote server not to send us any commits reachable from these refs.
1075
+ * @param {boolean} [args.relative = false] - Changes the meaning of `depth` to be measured from the current shallow depth rather than from the branch tip.
1076
+ * @param {Object<string, string>} [args.headers = {}] - Additional headers to include in HTTP requests, similar to git's `extraHeader` config
1077
+ * @param {object} [args.cache] - a [cache](cache.md) object
1078
+ * @param {boolean} [args.nonBlocking = false] - if true, checkout will happen non-blockingly (useful for long-running operations blocking the thread in browser environments)
1079
+ * @param {number} [args.batchSize = 100] - If args.nonBlocking is true, batchSize is the number of files to process at a time avoid blocking the executing thread. The default value of 100 is a good starting point.
1080
+ *
1081
+ * @returns {Promise<void>} Resolves successfully when clone completes
1082
+ *
1083
+ * @example
1084
+ * await git.clone({
1085
+ * fs,
1086
+ * http,
1087
+ * dir: '/tutorial',
1088
+ * corsProxy: 'https://cors.isomorphic-git.org',
1089
+ * url: 'https://github.com/isomorphic-git/isomorphic-git',
1090
+ * singleBranch: true,
1091
+ * depth: 1
1092
+ * })
1093
+ * console.log('done')
1094
+ *
1095
+ */
1096
+ export function clone({ fs, http, onProgress, onMessage, onAuth, onAuthSuccess, onAuthFailure, onPostCheckout, dir, gitdir, url, corsProxy, ref, remote, depth, since, exclude, relative, singleBranch, noCheckout, noTags, headers, cache, nonBlocking, batchSize, }: {
1097
+ fs: FsClient;
1098
+ http: HttpClient;
1099
+ onProgress?: ProgressCallback | undefined;
1100
+ onMessage?: MessageCallback | undefined;
1101
+ onAuth?: AuthCallback | undefined;
1102
+ onAuthFailure?: AuthFailureCallback | undefined;
1103
+ onAuthSuccess?: AuthSuccessCallback | undefined;
1104
+ onPostCheckout?: PostCheckoutCallback | undefined;
1105
+ dir: string;
1106
+ gitdir?: string | undefined;
1107
+ url: string;
1108
+ corsProxy?: string | undefined;
1109
+ ref?: string | undefined;
1110
+ singleBranch?: boolean | undefined;
1111
+ noCheckout?: boolean | undefined;
1112
+ noTags?: boolean | undefined;
1113
+ remote?: string | undefined;
1114
+ depth?: number | undefined;
1115
+ since?: Date | undefined;
1116
+ exclude?: string[] | undefined;
1117
+ relative?: boolean | undefined;
1118
+ headers?: {
1119
+ [x: string]: string;
1120
+ } | undefined;
1121
+ cache?: object;
1122
+ nonBlocking?: boolean | undefined;
1123
+ batchSize?: number | undefined;
1124
+ }): Promise<void>;
1125
+ /**
1126
+ * Create a new commit
1127
+ *
1128
+ * @param {Object} args
1129
+ * @param {FsClient} args.fs - a file system implementation
1130
+ * @param {SignCallback} [args.onSign] - a PGP signing implementation
1131
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
1132
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
1133
+ * @param {string} [args.message] - The commit message to use. Required, unless `amend === true`
1134
+ * @param {Object} [args.author] - The details about the author.
1135
+ * @param {string} [args.author.name] - Default is `user.name` config.
1136
+ * @param {string} [args.author.email] - Default is `user.email` config.
1137
+ * @param {number} [args.author.timestamp=Math.floor(Date.now()/1000)] - Set the author timestamp field. This is the integer number of seconds since the Unix epoch (1970-01-01 00:00:00).
1138
+ * @param {number} [args.author.timezoneOffset] - Set the author timezone offset field. This is the difference, in minutes, from the current timezone to UTC. Default is `(new Date()).getTimezoneOffset()`.
1139
+ * @param {Object} [args.committer = author] - The details about the commit committer, in the same format as the author parameter. If not specified, the author details are used.
1140
+ * @param {string} [args.committer.name] - Default is `user.name` config.
1141
+ * @param {string} [args.committer.email] - Default is `user.email` config.
1142
+ * @param {number} [args.committer.timestamp=Math.floor(Date.now()/1000)] - Set the committer timestamp field. This is the integer number of seconds since the Unix epoch (1970-01-01 00:00:00).
1143
+ * @param {number} [args.committer.timezoneOffset] - Set the committer timezone offset field. This is the difference, in minutes, from the current timezone to UTC. Default is `(new Date()).getTimezoneOffset()`.
1144
+ * @param {string} [args.signingKey] - Sign the tag object using this private PGP key.
1145
+ * @param {boolean} [args.amend = false] - If true, replaces the last commit pointed to by `ref` with a new commit.
1146
+ * @param {boolean} [args.dryRun = false] - If true, simulates making a commit so you can test whether it would succeed. Implies `noUpdateBranch`.
1147
+ * @param {boolean} [args.noUpdateBranch = false] - If true, does not update the branch pointer after creating the commit.
1148
+ * @param {string} [args.ref] - The fully expanded name of the branch to commit to. Default is the current branch pointed to by HEAD. (TODO: fix it so it can expand branch names without throwing if the branch doesn't exist yet.)
1149
+ * @param {string[]} [args.parent] - The SHA-1 object ids of the commits to use as parents. If not specified, the commit pointed to by `ref` is used.
1150
+ * @param {string} [args.tree] - The SHA-1 object id of the tree to use. If not specified, a new tree object is created from the current git index.
1151
+ * @param {object} [args.cache] - a [cache](cache.md) object
1152
+ *
1153
+ * @returns {Promise<string>} Resolves successfully with the SHA-1 object id of the newly created commit.
1154
+ *
1155
+ * @example
1156
+ * let sha = await git.commit({
1157
+ * fs,
1158
+ * dir: '/tutorial',
1159
+ * author: {
1160
+ * name: 'Mr. Test',
1161
+ * email: 'mrtest@example.com',
1162
+ * },
1163
+ * message: 'Added the a.txt file'
1164
+ * })
1165
+ * console.log(sha)
1166
+ *
1167
+ */
1168
+ export function commit({ fs: _fs, onSign, dir, gitdir, message, author, committer, signingKey, amend, dryRun, noUpdateBranch, ref, parent, tree, cache, }: {
1169
+ fs: FsClient;
1170
+ onSign?: SignCallback | undefined;
1171
+ dir?: string | undefined;
1172
+ gitdir?: string | undefined;
1173
+ message?: string | undefined;
1174
+ author?: {
1175
+ name?: string | undefined;
1176
+ email?: string | undefined;
1177
+ timestamp?: number | undefined;
1178
+ timezoneOffset?: number | undefined;
1179
+ } | undefined;
1180
+ committer?: {
1181
+ name?: string | undefined;
1182
+ email?: string | undefined;
1183
+ timestamp?: number | undefined;
1184
+ timezoneOffset?: number | undefined;
1185
+ } | undefined;
1186
+ signingKey?: string | undefined;
1187
+ amend?: boolean | undefined;
1188
+ dryRun?: boolean | undefined;
1189
+ noUpdateBranch?: boolean | undefined;
1190
+ ref?: string | undefined;
1191
+ parent?: string[] | undefined;
1192
+ tree?: string | undefined;
1193
+ cache?: object;
1194
+ }): Promise<string>;
1195
+ /**
1196
+ * Get the name of the branch currently pointed to by .git/HEAD
1197
+ *
1198
+ * @param {Object} args
1199
+ * @param {FsClient} args.fs - a file system implementation
1200
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
1201
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
1202
+ * @param {boolean} [args.fullname = false] - Return the full path (e.g. "refs/heads/main") instead of the abbreviated form.
1203
+ * @param {boolean} [args.test = false] - If the current branch doesn't actually exist (such as right after git init) then return `undefined`.
1204
+ *
1205
+ * @returns {Promise<string|void>} The name of the current branch or undefined if the HEAD is detached.
1206
+ *
1207
+ * @example
1208
+ * // Get the current branch name
1209
+ * let branch = await git.currentBranch({
1210
+ * fs,
1211
+ * dir: '/tutorial',
1212
+ * fullname: false
1213
+ * })
1214
+ * console.log(branch)
1215
+ *
1216
+ */
1217
+ export function currentBranch({ fs, dir, gitdir, fullname, test, }: {
1218
+ fs: FsClient;
1219
+ dir?: string | undefined;
1220
+ gitdir?: string | undefined;
1221
+ fullname?: boolean | undefined;
1222
+ test?: boolean | undefined;
1223
+ }): Promise<string | void>;
1224
+ /**
1225
+ * Delete a local branch
1226
+ *
1227
+ * > Note: This only deletes loose branches - it should be fixed in the future to delete packed branches as well.
1228
+ *
1229
+ * @param {Object} args
1230
+ * @param {FsClient} args.fs - a file system implementation
1231
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
1232
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
1233
+ * @param {string} args.ref - The branch to delete
1234
+ *
1235
+ * @returns {Promise<void>} Resolves successfully when filesystem operations are complete
1236
+ *
1237
+ * @example
1238
+ * await git.deleteBranch({ fs, dir: '/tutorial', ref: 'local-branch' })
1239
+ * console.log('done')
1240
+ *
1241
+ */
1242
+ export function deleteBranch({ fs, dir, gitdir, ref, }: {
1243
+ fs: FsClient;
1244
+ dir?: string | undefined;
1245
+ gitdir?: string | undefined;
1246
+ ref: string;
1247
+ }): Promise<void>;
1248
+ /**
1249
+ * Delete a local ref
1250
+ *
1251
+ * @param {Object} args
1252
+ * @param {FsClient} args.fs - a file system implementation
1253
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
1254
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
1255
+ * @param {string} args.ref - The ref to delete
1256
+ *
1257
+ * @returns {Promise<void>} Resolves successfully when filesystem operations are complete
1258
+ *
1259
+ * @example
1260
+ * await git.deleteRef({ fs, dir: '/tutorial', ref: 'refs/tags/test-tag' })
1261
+ * console.log('done')
1262
+ *
1263
+ */
1264
+ export function deleteRef({ fs, dir, gitdir, ref }: {
1265
+ fs: FsClient;
1266
+ dir?: string | undefined;
1267
+ gitdir?: string | undefined;
1268
+ ref: string;
1269
+ }): Promise<void>;
1270
+ /**
1271
+ * Removes the local config entry for a given remote
1272
+ *
1273
+ * @param {Object} args
1274
+ * @param {FsClient} args.fs - a file system implementation
1275
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
1276
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
1277
+ * @param {string} args.remote - The name of the remote to delete
1278
+ *
1279
+ * @returns {Promise<void>} Resolves successfully when filesystem operations are complete
1280
+ *
1281
+ * @example
1282
+ * await git.deleteRemote({ fs, dir: '/tutorial', remote: 'upstream' })
1283
+ * console.log('done')
1284
+ *
1285
+ */
1286
+ export function deleteRemote({ fs, dir, gitdir, remote, }: {
1287
+ fs: FsClient;
1288
+ dir?: string | undefined;
1289
+ gitdir?: string | undefined;
1290
+ remote: string;
1291
+ }): Promise<void>;
1292
+ /**
1293
+ * Delete a local tag ref
1294
+ *
1295
+ * @param {Object} args
1296
+ * @param {FsClient} args.fs - a file system implementation
1297
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
1298
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
1299
+ * @param {string} args.ref - The tag to delete
1300
+ *
1301
+ * @returns {Promise<void>} Resolves successfully when filesystem operations are complete
1302
+ *
1303
+ * @example
1304
+ * await git.deleteTag({ fs, dir: '/tutorial', ref: 'test-tag' })
1305
+ * console.log('done')
1306
+ *
1307
+ */
1308
+ export function deleteTag({ fs, dir, gitdir, ref }: {
1309
+ fs: FsClient;
1310
+ dir?: string | undefined;
1311
+ gitdir?: string | undefined;
1312
+ ref: string;
1313
+ }): Promise<void>;
1314
+ /**
1315
+ * Expand and resolve a short oid into a full oid
1316
+ *
1317
+ * @param {Object} args
1318
+ * @param {FsClient} args.fs - a file system implementation
1319
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
1320
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
1321
+ * @param {string} args.oid - The shortened oid prefix to expand (like "0414d2a")
1322
+ * @param {object} [args.cache] - a [cache](cache.md) object
1323
+ *
1324
+ * @returns {Promise<string>} Resolves successfully with the full oid (like "0414d2a286d7bbc7a4a326a61c1f9f888a8ab87f")
1325
+ *
1326
+ * @example
1327
+ * let oid = await git.expandOid({ fs, dir: '/tutorial', oid: '0414d2a'})
1328
+ * console.log(oid)
1329
+ *
1330
+ */
1331
+ export function expandOid({ fs, dir, gitdir, oid, cache, }: {
1332
+ fs: FsClient;
1333
+ dir?: string | undefined;
1334
+ gitdir?: string | undefined;
1335
+ oid: string;
1336
+ cache?: object;
1337
+ }): Promise<string>;
1338
+ /**
1339
+ * Expand an abbreviated ref to its full name
1340
+ *
1341
+ * @param {Object} args
1342
+ * @param {FsClient} args.fs - a file system implementation
1343
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
1344
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
1345
+ * @param {string} args.ref - The ref to expand (like "v1.0.0")
1346
+ *
1347
+ * @returns {Promise<string>} Resolves successfully with a full ref name ("refs/tags/v1.0.0")
1348
+ *
1349
+ * @example
1350
+ * let fullRef = await git.expandRef({ fs, dir: '/tutorial', ref: 'main'})
1351
+ * console.log(fullRef)
1352
+ *
1353
+ */
1354
+ export function expandRef({ fs, dir, gitdir, ref }: {
1355
+ fs: FsClient;
1356
+ dir?: string | undefined;
1357
+ gitdir?: string | undefined;
1358
+ ref: string;
1359
+ }): Promise<string>;
1360
+ /**
1361
+ * Like `pull`, but hard-coded with `fastForward: true` so there is no need for an `author` parameter.
1362
+ *
1363
+ * @param {object} args
1364
+ * @param {FsClient} args.fs - a file system client
1365
+ * @param {HttpClient} args.http - an HTTP client
1366
+ * @param {ProgressCallback} [args.onProgress] - optional progress event callback
1367
+ * @param {MessageCallback} [args.onMessage] - optional message event callback
1368
+ * @param {AuthCallback} [args.onAuth] - optional auth fill callback
1369
+ * @param {AuthFailureCallback} [args.onAuthFailure] - optional auth rejected callback
1370
+ * @param {AuthSuccessCallback} [args.onAuthSuccess] - optional auth approved callback
1371
+ * @param {string} args.dir] - The [working tree](dir-vs-gitdir.md) directory path
1372
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
1373
+ * @param {string} [args.ref] - Which branch to merge into. By default this is the currently checked out branch.
1374
+ * @param {string} [args.url] - (Added in 1.1.0) The URL of the remote repository. The default is the value set in the git config for that remote.
1375
+ * @param {string} [args.remote] - (Added in 1.1.0) If URL is not specified, determines which remote to use.
1376
+ * @param {string} [args.remoteRef] - (Added in 1.1.0) The name of the branch on the remote to fetch. By default this is the configured remote tracking branch.
1377
+ * @param {string} [args.corsProxy] - Optional [CORS proxy](https://www.npmjs.com/%40isomorphic-git/cors-proxy). Overrides value in repo config.
1378
+ * @param {boolean} [args.singleBranch = false] - Instead of the default behavior of fetching all the branches, only fetch a single branch.
1379
+ * @param {Object<string, string>} [args.headers] - Additional headers to include in HTTP requests, similar to git's `extraHeader` config
1380
+ * @param {object} [args.cache] - a [cache](cache.md) object
1381
+ *
1382
+ * @returns {Promise<void>} Resolves successfully when pull operation completes
1383
+ *
1384
+ * @example
1385
+ * await git.fastForward({
1386
+ * fs,
1387
+ * http,
1388
+ * dir: '/tutorial',
1389
+ * ref: 'main',
1390
+ * singleBranch: true
1391
+ * })
1392
+ * console.log('done')
1393
+ *
1394
+ */
1395
+ export function fastForward({ fs, http, onProgress, onMessage, onAuth, onAuthSuccess, onAuthFailure, dir, gitdir, ref, url, remote, remoteRef, corsProxy, singleBranch, headers, cache, }: {
1396
+ fs: FsClient;
1397
+ http: HttpClient;
1398
+ onProgress?: ProgressCallback | undefined;
1399
+ onMessage?: MessageCallback | undefined;
1400
+ onAuth?: AuthCallback | undefined;
1401
+ onAuthFailure?: AuthFailureCallback | undefined;
1402
+ onAuthSuccess?: AuthSuccessCallback | undefined;
1403
+ dir: string;
1404
+ gitdir?: string | undefined;
1405
+ ref?: string | undefined;
1406
+ url?: string | undefined;
1407
+ remote?: string | undefined;
1408
+ remoteRef?: string | undefined;
1409
+ corsProxy?: string | undefined;
1410
+ singleBranch?: boolean | undefined;
1411
+ headers?: {
1412
+ [x: string]: string;
1413
+ } | undefined;
1414
+ cache?: object;
1415
+ }): Promise<void>;
1416
+ /**
1417
+ *
1418
+ * @typedef {object} FetchResult - The object returned has the following schema:
1419
+ * @property {string | null} defaultBranch - The branch that is cloned if no branch is specified
1420
+ * @property {string | null} fetchHead - The SHA-1 object id of the fetched head commit
1421
+ * @property {string | null} fetchHeadDescription - a textual description of the branch that was fetched
1422
+ * @property {Object<string, string>} [headers] - The HTTP response headers returned by the git server
1423
+ * @property {string[]} [pruned] - A list of branches that were pruned, if you provided the `prune` parameter
1424
+ *
1425
+ */
1426
+ /**
1427
+ * Fetch commits from a remote repository
1428
+ *
1429
+ * @param {object} args
1430
+ * @param {FsClient} args.fs - a file system client
1431
+ * @param {HttpClient} args.http - an HTTP client
1432
+ * @param {ProgressCallback} [args.onProgress] - optional progress event callback
1433
+ * @param {MessageCallback} [args.onMessage] - optional message event callback
1434
+ * @param {AuthCallback} [args.onAuth] - optional auth fill callback
1435
+ * @param {AuthFailureCallback} [args.onAuthFailure] - optional auth rejected callback
1436
+ * @param {AuthSuccessCallback} [args.onAuthSuccess] - optional auth approved callback
1437
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
1438
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
1439
+ * @param {string} [args.url] - The URL of the remote repository. The default is the value set in the git config for that remote.
1440
+ * @param {string} [args.remote] - If URL is not specified, determines which remote to use.
1441
+ * @param {boolean} [args.singleBranch = false] - Instead of the default behavior of fetching all the branches, only fetch a single branch.
1442
+ * @param {string} [args.ref] - Which branch to fetch if `singleBranch` is true. By default this is the current branch or the remote's default branch.
1443
+ * @param {string} [args.remoteRef] - The name of the branch on the remote to fetch if `singleBranch` is true. By default this is the configured remote tracking branch.
1444
+ * @param {boolean} [args.tags = false] - Also fetch tags
1445
+ * @param {number} [args.depth] - Integer. Determines how much of the git repository's history to retrieve
1446
+ * @param {boolean} [args.relative = false] - Changes the meaning of `depth` to be measured from the current shallow depth rather than from the branch tip.
1447
+ * @param {Date} [args.since] - Only fetch commits created after the given date. Mutually exclusive with `depth`.
1448
+ * @param {string[]} [args.exclude = []] - A list of branches or tags. Instructs the remote server not to send us any commits reachable from these refs.
1449
+ * @param {boolean} [args.prune = false] - Delete local remote-tracking branches that are not present on the remote
1450
+ * @param {boolean} [args.pruneTags = false] - Prune local tags that don’t exist on the remote, and force-update those tags that differ
1451
+ * @param {string} [args.corsProxy] - Optional [CORS proxy](https://www.npmjs.com/%40isomorphic-git/cors-proxy). Overrides value in repo config.
1452
+ * @param {Object<string, string>} [args.headers] - Additional headers to include in HTTP requests, similar to git's `extraHeader` config
1453
+ * @param {object} [args.cache] - a [cache](cache.md) object
1454
+ *
1455
+ * @returns {Promise<FetchResult>} Resolves successfully when fetch completes
1456
+ * @see FetchResult
1457
+ *
1458
+ * @example
1459
+ * let result = await git.fetch({
1460
+ * fs,
1461
+ * http,
1462
+ * dir: '/tutorial',
1463
+ * corsProxy: 'https://cors.isomorphic-git.org',
1464
+ * url: 'https://github.com/isomorphic-git/isomorphic-git',
1465
+ * ref: 'main',
1466
+ * depth: 1,
1467
+ * singleBranch: true,
1468
+ * tags: false
1469
+ * })
1470
+ * console.log(result)
1471
+ *
1472
+ */
1473
+ export function fetch({ fs, http, onProgress, onMessage, onAuth, onAuthSuccess, onAuthFailure, dir, gitdir, ref, remote, remoteRef, url, corsProxy, depth, since, exclude, relative, tags, singleBranch, headers, prune, pruneTags, cache, }: {
1474
+ fs: FsClient;
1475
+ http: HttpClient;
1476
+ onProgress?: ProgressCallback | undefined;
1477
+ onMessage?: MessageCallback | undefined;
1478
+ onAuth?: AuthCallback | undefined;
1479
+ onAuthFailure?: AuthFailureCallback | undefined;
1480
+ onAuthSuccess?: AuthSuccessCallback | undefined;
1481
+ dir?: string | undefined;
1482
+ gitdir?: string | undefined;
1483
+ url?: string | undefined;
1484
+ remote?: string | undefined;
1485
+ singleBranch?: boolean | undefined;
1486
+ ref?: string | undefined;
1487
+ remoteRef?: string | undefined;
1488
+ tags?: boolean | undefined;
1489
+ depth?: number | undefined;
1490
+ relative?: boolean | undefined;
1491
+ since?: Date | undefined;
1492
+ exclude?: string[] | undefined;
1493
+ prune?: boolean | undefined;
1494
+ pruneTags?: boolean | undefined;
1495
+ corsProxy?: string | undefined;
1496
+ headers?: {
1497
+ [x: string]: string;
1498
+ } | undefined;
1499
+ cache?: object;
1500
+ }): Promise<FetchResult>;
1501
+ /**
1502
+ * Find the merge base for a set of commits
1503
+ *
1504
+ * @param {object} args
1505
+ * @param {FsClient} args.fs - a file system client
1506
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
1507
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
1508
+ * @param {string[]} args.oids - Which commits
1509
+ * @param {object} [args.cache] - a [cache](cache.md) object
1510
+ *
1511
+ */
1512
+ export function findMergeBase({ fs, dir, gitdir, oids, cache, }: {
1513
+ fs: FsClient;
1514
+ dir?: string | undefined;
1515
+ gitdir?: string | undefined;
1516
+ oids: string[];
1517
+ cache?: object;
1518
+ }): Promise<any[]>;
1519
+ /**
1520
+ * Find the root git directory
1521
+ *
1522
+ * Starting at `filepath`, walks upward until it finds a directory that contains a subdirectory called '.git'.
1523
+ *
1524
+ * @param {Object} args
1525
+ * @param {FsClient} args.fs - a file system client
1526
+ * @param {string} args.filepath - The file directory to start searching in.
1527
+ *
1528
+ * @returns {Promise<string>} Resolves successfully with a root git directory path
1529
+ * @throws {NotFoundError}
1530
+ *
1531
+ * @example
1532
+ * let gitroot = await git.findRoot({
1533
+ * fs,
1534
+ * filepath: '/tutorial/src/utils'
1535
+ * })
1536
+ * console.log(gitroot)
1537
+ *
1538
+ */
1539
+ export function findRoot({ fs, filepath }: {
1540
+ fs: FsClient;
1541
+ filepath: string;
1542
+ }): Promise<string>;
1543
+ /**
1544
+ * Read an entry from the git config files.
1545
+ *
1546
+ * *Caveats:*
1547
+ * - Currently only the local `$GIT_DIR/config` file can be read or written. However support for the global `~/.gitconfig` and system `$(prefix)/etc/gitconfig` will be added in the future.
1548
+ * - The current parser does not support the more exotic features of the git-config file format such as `[include]` and `[includeIf]`.
1549
+ *
1550
+ * @param {Object} args
1551
+ * @param {FsClient} args.fs - a file system implementation
1552
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
1553
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
1554
+ * @param {string} args.path - The key of the git config entry
1555
+ *
1556
+ * @returns {Promise<any>} Resolves with the config value
1557
+ *
1558
+ * @example
1559
+ * // Read config value
1560
+ * let value = await git.getConfig({
1561
+ * fs,
1562
+ * dir: '/tutorial',
1563
+ * path: 'remote.origin.url'
1564
+ * })
1565
+ * console.log(value)
1566
+ *
1567
+ */
1568
+ export function getConfig({ fs, dir, gitdir, path }: {
1569
+ fs: FsClient;
1570
+ dir?: string | undefined;
1571
+ gitdir?: string | undefined;
1572
+ path: string;
1573
+ }): Promise<any>;
1574
+ /**
1575
+ * Read a multi-valued entry from the git config files.
1576
+ *
1577
+ * *Caveats:*
1578
+ * - Currently only the local `$GIT_DIR/config` file can be read or written. However support for the global `~/.gitconfig` and system `$(prefix)/etc/gitconfig` will be added in the future.
1579
+ * - The current parser does not support the more exotic features of the git-config file format such as `[include]` and `[includeIf]`.
1580
+ *
1581
+ * @param {Object} args
1582
+ * @param {FsClient} args.fs - a file system implementation
1583
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
1584
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
1585
+ * @param {string} args.path - The key of the git config entry
1586
+ *
1587
+ * @returns {Promise<Array<any>>} Resolves with the config value
1588
+ *
1589
+ */
1590
+ export function getConfigAll({ fs, dir, gitdir, path, }: {
1591
+ fs: FsClient;
1592
+ dir?: string | undefined;
1593
+ gitdir?: string | undefined;
1594
+ path: string;
1595
+ }): Promise<Array<any>>;
1596
+ /**
1597
+ *
1598
+ * @typedef {Object} GetRemoteInfoResult - The object returned has the following schema:
1599
+ * @property {string[]} capabilities - The list of capabilities returned by the server (part of the Git protocol)
1600
+ * @property {Object} [refs]
1601
+ * @property {string} [HEAD] - The default branch of the remote
1602
+ * @property {Object<string, string>} [refs.heads] - The branches on the remote
1603
+ * @property {Object<string, string>} [refs.pull] - The special branches representing pull requests (non-standard)
1604
+ * @property {Object<string, string>} [refs.tags] - The tags on the remote
1605
+ *
1606
+ */
1607
+ /**
1608
+ * List a remote servers branches, tags, and capabilities.
1609
+ *
1610
+ * This is a rare command that doesn't require an `fs`, `dir`, or even `gitdir` argument.
1611
+ * It just communicates to a remote git server, using the first step of the `git-upload-pack` handshake, but stopping short of fetching the packfile.
1612
+ *
1613
+ * @param {object} args
1614
+ * @param {HttpClient} args.http - an HTTP client
1615
+ * @param {AuthCallback} [args.onAuth] - optional auth fill callback
1616
+ * @param {AuthFailureCallback} [args.onAuthFailure] - optional auth rejected callback
1617
+ * @param {AuthSuccessCallback} [args.onAuthSuccess] - optional auth approved callback
1618
+ * @param {string} args.url - The URL of the remote repository. Will be gotten from gitconfig if absent.
1619
+ * @param {string} [args.corsProxy] - Optional [CORS proxy](https://www.npmjs.com/%40isomorphic-git/cors-proxy). Overrides value in repo config.
1620
+ * @param {boolean} [args.forPush = false] - By default, the command queries the 'fetch' capabilities. If true, it will ask for the 'push' capabilities.
1621
+ * @param {Object<string, string>} [args.headers] - Additional headers to include in HTTP requests, similar to git's `extraHeader` config
1622
+ *
1623
+ * @returns {Promise<GetRemoteInfoResult>} Resolves successfully with an object listing the branches, tags, and capabilities of the remote.
1624
+ * @see GetRemoteInfoResult
1625
+ *
1626
+ * @example
1627
+ * let info = await git.getRemoteInfo({
1628
+ * http,
1629
+ * url:
1630
+ * "https://cors.isomorphic-git.org/github.com/isomorphic-git/isomorphic-git.git"
1631
+ * });
1632
+ * console.log(info);
1633
+ *
1634
+ */
1635
+ export function getRemoteInfo({ http, onAuth, onAuthSuccess, onAuthFailure, corsProxy, url, headers, forPush, }: {
1636
+ http: HttpClient;
1637
+ onAuth?: AuthCallback | undefined;
1638
+ onAuthFailure?: AuthFailureCallback | undefined;
1639
+ onAuthSuccess?: AuthSuccessCallback | undefined;
1640
+ url: string;
1641
+ corsProxy?: string | undefined;
1642
+ forPush?: boolean | undefined;
1643
+ headers?: {
1644
+ [x: string]: string;
1645
+ } | undefined;
1646
+ }): Promise<GetRemoteInfoResult>;
1647
+ /**
1648
+ * @typedef {Object} GetRemoteInfo2Result - This object has the following schema:
1649
+ * @property {1 | 2} protocolVersion - Git protocol version the server supports
1650
+ * @property {Object<string, string | true>} capabilities - An object of capabilities represented as keys and values
1651
+ * @property {ServerRef[]} [refs] - Server refs (they get returned by protocol version 1 whether you want them or not)
1652
+ */
1653
+ /**
1654
+ * List a remote server's capabilities.
1655
+ *
1656
+ * This is a rare command that doesn't require an `fs`, `dir`, or even `gitdir` argument.
1657
+ * It just communicates to a remote git server, determining what protocol version, commands, and features it supports.
1658
+ *
1659
+ * > The successor to [`getRemoteInfo`](./getRemoteInfo.md), this command supports Git Wire Protocol Version 2.
1660
+ * > Therefore its return type is more complicated as either:
1661
+ * >
1662
+ * > - v1 capabilities (and refs) or
1663
+ * > - v2 capabilities (and no refs)
1664
+ * >
1665
+ * > are returned.
1666
+ * > If you just care about refs, use [`listServerRefs`](./listServerRefs.md)
1667
+ *
1668
+ * @param {object} args
1669
+ * @param {HttpClient} args.http - an HTTP client
1670
+ * @param {AuthCallback} [args.onAuth] - optional auth fill callback
1671
+ * @param {AuthFailureCallback} [args.onAuthFailure] - optional auth rejected callback
1672
+ * @param {AuthSuccessCallback} [args.onAuthSuccess] - optional auth approved callback
1673
+ * @param {string} args.url - The URL of the remote repository. Will be gotten from gitconfig if absent.
1674
+ * @param {string} [args.corsProxy] - Optional [CORS proxy](https://www.npmjs.com/%40isomorphic-git/cors-proxy). Overrides value in repo config.
1675
+ * @param {boolean} [args.forPush = false] - By default, the command queries the 'fetch' capabilities. If true, it will ask for the 'push' capabilities.
1676
+ * @param {Object<string, string>} [args.headers] - Additional headers to include in HTTP requests, similar to git's `extraHeader` config
1677
+ * @param {1 | 2} [args.protocolVersion = 2] - Which version of the Git Protocol to use.
1678
+ *
1679
+ * @returns {Promise<GetRemoteInfo2Result>} Resolves successfully with an object listing the capabilities of the remote.
1680
+ * @see GetRemoteInfo2Result
1681
+ * @see ServerRef
1682
+ *
1683
+ * @example
1684
+ * let info = await git.getRemoteInfo2({
1685
+ * http,
1686
+ * corsProxy: "https://cors.isomorphic-git.org",
1687
+ * url: "https://github.com/isomorphic-git/isomorphic-git.git"
1688
+ * });
1689
+ * console.log(info);
1690
+ *
1691
+ */
1692
+ export function getRemoteInfo2({ http, onAuth, onAuthSuccess, onAuthFailure, corsProxy, url, headers, forPush, protocolVersion, }: {
1693
+ http: HttpClient;
1694
+ onAuth?: AuthCallback | undefined;
1695
+ onAuthFailure?: AuthFailureCallback | undefined;
1696
+ onAuthSuccess?: AuthSuccessCallback | undefined;
1697
+ url: string;
1698
+ corsProxy?: string | undefined;
1699
+ forPush?: boolean | undefined;
1700
+ headers?: {
1701
+ [x: string]: string;
1702
+ } | undefined;
1703
+ protocolVersion?: 2 | 1 | undefined;
1704
+ }): Promise<GetRemoteInfo2Result>;
1705
+ /**
1706
+ *
1707
+ * @typedef {object} HashBlobResult - The object returned has the following schema:
1708
+ * @property {string} oid - The SHA-1 object id
1709
+ * @property {'blob'} type - The type of the object
1710
+ * @property {Uint8Array} object - The wrapped git object (the thing that is hashed)
1711
+ * @property {'wrapped'} format - The format of the object
1712
+ *
1713
+ */
1714
+ /**
1715
+ * Compute what the SHA-1 object id of a file would be
1716
+ *
1717
+ * @param {object} args
1718
+ * @param {Uint8Array|string} args.object - The object to write. If `object` is a String then it will be converted to a Uint8Array using UTF-8 encoding.
1719
+ *
1720
+ * @returns {Promise<HashBlobResult>} Resolves successfully with the SHA-1 object id and the wrapped object Uint8Array.
1721
+ * @see HashBlobResult
1722
+ *
1723
+ * @example
1724
+ * let { oid, type, object, format } = await git.hashBlob({
1725
+ * object: 'Hello world!',
1726
+ * })
1727
+ *
1728
+ * console.log('oid', oid)
1729
+ * console.log('type', type)
1730
+ * console.log('object', object)
1731
+ * console.log('format', format)
1732
+ *
1733
+ */
1734
+ export function hashBlob({ object }: {
1735
+ object: Uint8Array | string;
1736
+ }): Promise<HashBlobResult>;
1737
+ /**
1738
+ * Create the .idx file for a given .pack file
1739
+ *
1740
+ * @param {object} args
1741
+ * @param {FsClient} args.fs - a file system client
1742
+ * @param {ProgressCallback} [args.onProgress] - optional progress event callback
1743
+ * @param {string} args.dir - The [working tree](dir-vs-gitdir.md) directory path
1744
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
1745
+ * @param {string} args.filepath - The path to the .pack file to index
1746
+ * @param {object} [args.cache] - a [cache](cache.md) object
1747
+ *
1748
+ * @returns {Promise<{oids: string[]}>} Resolves with a list of the SHA-1 object ids contained in the packfile
1749
+ *
1750
+ * @example
1751
+ * let packfiles = await fs.promises.readdir('/tutorial/.git/objects/pack')
1752
+ * packfiles = packfiles.filter(name => name.endsWith('.pack'))
1753
+ * console.log('packfiles', packfiles)
1754
+ *
1755
+ * const { oids } = await git.indexPack({
1756
+ * fs,
1757
+ * dir: '/tutorial',
1758
+ * filepath: `.git/objects/pack/${packfiles[0]}`,
1759
+ * async onProgress (evt) {
1760
+ * console.log(`${evt.phase}: ${evt.loaded} / ${evt.total}`)
1761
+ * }
1762
+ * })
1763
+ * console.log(oids)
1764
+ *
1765
+ */
1766
+ export function indexPack({ fs, onProgress, dir, gitdir, filepath, cache, }: {
1767
+ fs: FsClient;
1768
+ onProgress?: ProgressCallback | undefined;
1769
+ dir: string;
1770
+ gitdir?: string | undefined;
1771
+ filepath: string;
1772
+ cache?: object;
1773
+ }): Promise<{
1774
+ oids: string[];
1775
+ }>;
1776
+ /**
1777
+ * Initialize a new repository
1778
+ *
1779
+ * @param {object} args
1780
+ * @param {FsClient} args.fs - a file system client
1781
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
1782
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
1783
+ * @param {boolean} [args.bare = false] - Initialize a bare repository
1784
+ * @param {string} [args.defaultBranch = 'master'] - The name of the default branch (might be changed to a required argument in 2.0.0)
1785
+ * @returns {Promise<void>} Resolves successfully when filesystem operations are complete
1786
+ *
1787
+ * @example
1788
+ * await git.init({ fs, dir: '/tutorial' })
1789
+ * console.log('done')
1790
+ *
1791
+ */
1792
+ export function init({ fs, bare, dir, gitdir, defaultBranch, }: {
1793
+ fs: FsClient;
1794
+ dir?: string | undefined;
1795
+ gitdir?: string | undefined;
1796
+ bare?: boolean | undefined;
1797
+ defaultBranch?: string | undefined;
1798
+ }): Promise<void>;
1799
+ /**
1800
+ * Check whether a git commit is descended from another
1801
+ *
1802
+ * @param {object} args
1803
+ * @param {FsClient} args.fs - a file system client
1804
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
1805
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
1806
+ * @param {string} args.oid - The descendent commit
1807
+ * @param {string} args.ancestor - The (proposed) ancestor commit
1808
+ * @param {number} [args.depth = -1] - Maximum depth to search before giving up. -1 means no maximum depth.
1809
+ * @param {object} [args.cache] - a [cache](cache.md) object
1810
+ *
1811
+ * @returns {Promise<boolean>} Resolves to true if `oid` is a descendent of `ancestor`
1812
+ *
1813
+ * @example
1814
+ * let oid = await git.resolveRef({ fs, dir: '/tutorial', ref: 'main' })
1815
+ * let ancestor = await git.resolveRef({ fs, dir: '/tutorial', ref: 'v0.20.0' })
1816
+ * console.log(oid, ancestor)
1817
+ * await git.isDescendent({ fs, dir: '/tutorial', oid, ancestor, depth: -1 })
1818
+ *
1819
+ */
1820
+ export function isDescendent({ fs, dir, gitdir, oid, ancestor, depth, cache, }: {
1821
+ fs: FsClient;
1822
+ dir?: string | undefined;
1823
+ gitdir?: string | undefined;
1824
+ oid: string;
1825
+ ancestor: string;
1826
+ depth?: number | undefined;
1827
+ cache?: object;
1828
+ }): Promise<boolean>;
1829
+ /**
1830
+ * Test whether a filepath should be ignored (because of .gitignore or .git/exclude)
1831
+ *
1832
+ * @param {object} args
1833
+ * @param {FsClient} args.fs - a file system client
1834
+ * @param {string} args.dir - The [working tree](dir-vs-gitdir.md) directory path
1835
+ * @param {string} [args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path
1836
+ * @param {string} args.filepath - The filepath to test
1837
+ *
1838
+ * @returns {Promise<boolean>} Resolves to true if the file should be ignored
1839
+ *
1840
+ * @example
1841
+ * await git.isIgnored({ fs, dir: '/tutorial', filepath: 'docs/add.md' })
1842
+ *
1843
+ */
1844
+ export function isIgnored({ fs, dir, gitdir, filepath, }: {
1845
+ fs: FsClient;
1846
+ dir: string;
1847
+ gitdir?: string | undefined;
1848
+ filepath: string;
1849
+ }): Promise<boolean>;
1850
+ /**
1851
+ * List branches
1852
+ *
1853
+ * By default it lists local branches. If a 'remote' is specified, it lists the remote's branches. When listing remote branches, the HEAD branch is not filtered out, so it may be included in the list of results.
1854
+ *
1855
+ * Note that specifying a remote does not actually contact the server and update the list of branches.
1856
+ * If you want an up-to-date list, first do a `fetch` to that remote.
1857
+ * (Which branch you fetch doesn't matter - the list of branches available on the remote is updated during the fetch handshake.)
1858
+ *
1859
+ * Also note, that a branch is a reference to a commit. If you initialize a new repository it has no commits, so the
1860
+ * `listBranches` function will return an empty list, until you create the first commit.
1861
+ *
1862
+ * @param {object} args
1863
+ * @param {FsClient} args.fs - a file system client
1864
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
1865
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
1866
+ * @param {string} [args.remote] - Instead of the branches in `refs/heads`, list the branches in `refs/remotes/${remote}`.
1867
+ *
1868
+ * @returns {Promise<Array<string>>} Resolves successfully with an array of branch names
1869
+ *
1870
+ * @example
1871
+ * let branches = await git.listBranches({ fs, dir: '/tutorial' })
1872
+ * console.log(branches)
1873
+ * let remoteBranches = await git.listBranches({ fs, dir: '/tutorial', remote: 'origin' })
1874
+ * console.log(remoteBranches)
1875
+ *
1876
+ */
1877
+ export function listBranches({ fs, dir, gitdir, remote, }: {
1878
+ fs: FsClient;
1879
+ dir?: string | undefined;
1880
+ gitdir?: string | undefined;
1881
+ remote?: string | undefined;
1882
+ }): Promise<Array<string>>;
1883
+ /**
1884
+ * List all the files in the git index or a commit
1885
+ *
1886
+ * > Note: This function is efficient for listing the files in the staging area, but listing all the files in a commit requires recursively walking through the git object store.
1887
+ * > If you do not require a complete list of every file, better performance can be achieved by using [walk](./walk) and ignoring subdirectories you don't care about.
1888
+ *
1889
+ * @param {object} args
1890
+ * @param {FsClient} args.fs - a file system client
1891
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
1892
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
1893
+ * @param {string} [args.ref] - Return a list of all the files in the commit at `ref` instead of the files currently in the git index (aka staging area)
1894
+ * @param {object} [args.cache] - a [cache](cache.md) object
1895
+ *
1896
+ * @returns {Promise<Array<string>>} Resolves successfully with an array of filepaths
1897
+ *
1898
+ * @example
1899
+ * // All the files in the previous commit
1900
+ * let files = await git.listFiles({ fs, dir: '/tutorial', ref: 'HEAD' })
1901
+ * console.log(files)
1902
+ * // All the files in the current staging area
1903
+ * files = await git.listFiles({ fs, dir: '/tutorial' })
1904
+ * console.log(files)
1905
+ *
1906
+ */
1907
+ export function listFiles({ fs, dir, gitdir, ref, cache, }: {
1908
+ fs: FsClient;
1909
+ dir?: string | undefined;
1910
+ gitdir?: string | undefined;
1911
+ ref?: string | undefined;
1912
+ cache?: object;
1913
+ }): Promise<Array<string>>;
1914
+ /**
1915
+ * List all the object notes
1916
+ *
1917
+ * @param {object} args
1918
+ * @param {FsClient} args.fs - a file system client
1919
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
1920
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
1921
+ * @param {string} [args.ref] - The notes ref to look under
1922
+ * @param {object} [args.cache] - a [cache](cache.md) object
1923
+ *
1924
+ * @returns {Promise<Array<{target: string, note: string}>>} Resolves successfully with an array of entries containing SHA-1 object ids of the note and the object the note targets
1925
+ */
1926
+ export function listNotes({ fs, dir, gitdir, ref, cache, }: {
1927
+ fs: FsClient;
1928
+ dir?: string | undefined;
1929
+ gitdir?: string | undefined;
1930
+ ref?: string | undefined;
1931
+ cache?: object;
1932
+ }): Promise<Array<{
1933
+ target: string;
1934
+ note: string;
1935
+ }>>;
1936
+ /**
1937
+ * List refs
1938
+ *
1939
+ * @param {object} args
1940
+ * @param {FsClient} args.fs - a file system client
1941
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
1942
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
1943
+ * @param {string} [args.filepath] - [required] The refs path to list
1944
+ *
1945
+ * @returns {Promise<Array<string>>} Resolves successfully with an array of ref names below the supplied `filepath`
1946
+ *
1947
+ * @example
1948
+ * let refs = await git.listRefs({ fs, dir: '/tutorial', filepath: 'refs/heads' })
1949
+ * console.log(refs)
1950
+ *
1951
+ */
1952
+ export function listRefs({ fs, dir, gitdir, filepath, }: {
1953
+ fs: FsClient;
1954
+ dir?: string | undefined;
1955
+ gitdir?: string | undefined;
1956
+ filepath?: string | undefined;
1957
+ }): Promise<Array<string>>;
1958
+ /**
1959
+ * List remotes
1960
+ *
1961
+ * @param {object} args
1962
+ * @param {FsClient} args.fs - a file system client
1963
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
1964
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
1965
+ *
1966
+ * @returns {Promise<Array<{remote: string, url: string}>>} Resolves successfully with an array of `{remote, url}` objects
1967
+ *
1968
+ * @example
1969
+ * let remotes = await git.listRemotes({ fs, dir: '/tutorial' })
1970
+ * console.log(remotes)
1971
+ *
1972
+ */
1973
+ export function listRemotes({ fs, dir, gitdir }: {
1974
+ fs: FsClient;
1975
+ dir?: string | undefined;
1976
+ gitdir?: string | undefined;
1977
+ }): Promise<Array<{
1978
+ remote: string;
1979
+ url: string;
1980
+ }>>;
1981
+ /**
1982
+ * Fetch a list of refs (branches, tags, etc) from a server.
1983
+ *
1984
+ * This is a rare command that doesn't require an `fs`, `dir`, or even `gitdir` argument.
1985
+ * It just requires an `http` argument.
1986
+ *
1987
+ * ### About `protocolVersion`
1988
+ *
1989
+ * There's a rather fun trade-off between Git Protocol Version 1 and Git Protocol Version 2.
1990
+ * Version 2 actually requires 2 HTTP requests instead of 1, making it similar to fetch or push in that regard.
1991
+ * However, version 2 supports server-side filtering by prefix, whereas that filtering is done client-side in version 1.
1992
+ * Which protocol is most efficient therefore depends on the number of refs on the remote, the latency of the server, and speed of the network connection.
1993
+ * For an small repos (or fast Internet connections), the requirement to make two trips to the server makes protocol 2 slower.
1994
+ * But for large repos (or slow Internet connections), the decreased payload size of the second request makes up for the additional request.
1995
+ *
1996
+ * Hard numbers vary by situation, but here's some numbers from my machine:
1997
+ *
1998
+ * Using isomorphic-git in a browser, with a CORS proxy, listing only the branches (refs/heads) of https://github.com/isomorphic-git/isomorphic-git
1999
+ * - Protocol Version 1 took ~300ms and transferred 84 KB.
2000
+ * - Protocol Version 2 took ~500ms and transferred 4.1 KB.
2001
+ *
2002
+ * Using isomorphic-git in a browser, with a CORS proxy, listing only the branches (refs/heads) of https://gitlab.com/gitlab-org/gitlab
2003
+ * - Protocol Version 1 took ~4900ms and transferred 9.41 MB.
2004
+ * - Protocol Version 2 took ~1280ms and transferred 433 KB.
2005
+ *
2006
+ * Finally, there is a fun quirk regarding the `symrefs` parameter.
2007
+ * Protocol Version 1 will generally only return the `HEAD` symref and not others.
2008
+ * Historically, this meant that servers don't use symbolic refs except for `HEAD`, which is used to point at the "default branch".
2009
+ * However Protocol Version 2 can return *all* the symbolic refs on the server.
2010
+ * So if you are running your own git server, you could take advantage of that I guess.
2011
+ *
2012
+ * #### TL;DR
2013
+ * If you are _not_ taking advantage of `prefix` I would recommend `protocolVersion: 1`.
2014
+ * Otherwise, I recommend to use the default which is `protocolVersion: 2`.
2015
+ *
2016
+ * @param {object} args
2017
+ * @param {HttpClient} args.http - an HTTP client
2018
+ * @param {AuthCallback} [args.onAuth] - optional auth fill callback
2019
+ * @param {AuthFailureCallback} [args.onAuthFailure] - optional auth rejected callback
2020
+ * @param {AuthSuccessCallback} [args.onAuthSuccess] - optional auth approved callback
2021
+ * @param {string} args.url - The URL of the remote repository. Will be gotten from gitconfig if absent.
2022
+ * @param {string} [args.corsProxy] - Optional [CORS proxy](https://www.npmjs.com/%40isomorphic-git/cors-proxy). Overrides value in repo config.
2023
+ * @param {boolean} [args.forPush = false] - By default, the command queries the 'fetch' capabilities. If true, it will ask for the 'push' capabilities.
2024
+ * @param {Object<string, string>} [args.headers] - Additional headers to include in HTTP requests, similar to git's `extraHeader` config
2025
+ * @param {1 | 2} [args.protocolVersion = 2] - Which version of the Git Protocol to use.
2026
+ * @param {string} [args.prefix] - Only list refs that start with this prefix
2027
+ * @param {boolean} [args.symrefs = false] - Include symbolic ref targets
2028
+ * @param {boolean} [args.peelTags = false] - Include annotated tag peeled targets
2029
+ *
2030
+ * @returns {Promise<ServerRef[]>} Resolves successfully with an array of ServerRef objects
2031
+ * @see ServerRef
2032
+ *
2033
+ * @example
2034
+ * // List all the branches on a repo
2035
+ * let refs = await git.listServerRefs({
2036
+ * http,
2037
+ * corsProxy: "https://cors.isomorphic-git.org",
2038
+ * url: "https://github.com/isomorphic-git/isomorphic-git.git",
2039
+ * prefix: "refs/heads/",
2040
+ * });
2041
+ * console.log(refs);
2042
+ *
2043
+ * @example
2044
+ * // Get the default branch on a repo
2045
+ * let refs = await git.listServerRefs({
2046
+ * http,
2047
+ * corsProxy: "https://cors.isomorphic-git.org",
2048
+ * url: "https://github.com/isomorphic-git/isomorphic-git.git",
2049
+ * prefix: "HEAD",
2050
+ * symrefs: true,
2051
+ * });
2052
+ * console.log(refs);
2053
+ *
2054
+ * @example
2055
+ * // List all the tags on a repo
2056
+ * let refs = await git.listServerRefs({
2057
+ * http,
2058
+ * corsProxy: "https://cors.isomorphic-git.org",
2059
+ * url: "https://github.com/isomorphic-git/isomorphic-git.git",
2060
+ * prefix: "refs/tags/",
2061
+ * peelTags: true,
2062
+ * });
2063
+ * console.log(refs);
2064
+ *
2065
+ * @example
2066
+ * // List all the pull requests on a repo
2067
+ * let refs = await git.listServerRefs({
2068
+ * http,
2069
+ * corsProxy: "https://cors.isomorphic-git.org",
2070
+ * url: "https://github.com/isomorphic-git/isomorphic-git.git",
2071
+ * prefix: "refs/pull/",
2072
+ * });
2073
+ * console.log(refs);
2074
+ *
2075
+ */
2076
+ export function listServerRefs({ http, onAuth, onAuthSuccess, onAuthFailure, corsProxy, url, headers, forPush, protocolVersion, prefix, symrefs, peelTags, }: {
2077
+ http: HttpClient;
2078
+ onAuth?: AuthCallback | undefined;
2079
+ onAuthFailure?: AuthFailureCallback | undefined;
2080
+ onAuthSuccess?: AuthSuccessCallback | undefined;
2081
+ url: string;
2082
+ corsProxy?: string | undefined;
2083
+ forPush?: boolean | undefined;
2084
+ headers?: {
2085
+ [x: string]: string;
2086
+ } | undefined;
2087
+ protocolVersion?: 2 | 1 | undefined;
2088
+ prefix?: string | undefined;
2089
+ symrefs?: boolean | undefined;
2090
+ peelTags?: boolean | undefined;
2091
+ }): Promise<ServerRef[]>;
2092
+ /**
2093
+ * List tags
2094
+ *
2095
+ * @param {object} args
2096
+ * @param {FsClient} args.fs - a file system client
2097
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
2098
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
2099
+ *
2100
+ * @returns {Promise<Array<string>>} Resolves successfully with an array of tag names
2101
+ *
2102
+ * @example
2103
+ * let tags = await git.listTags({ fs, dir: '/tutorial' })
2104
+ * console.log(tags)
2105
+ *
2106
+ */
2107
+ export function listTags({ fs, dir, gitdir }: {
2108
+ fs: FsClient;
2109
+ dir?: string | undefined;
2110
+ gitdir?: string | undefined;
2111
+ }): Promise<Array<string>>;
2112
+ /**
2113
+ * Get commit descriptions from the git history
2114
+ *
2115
+ * @param {object} args
2116
+ * @param {FsClient} args.fs - a file system client
2117
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
2118
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
2119
+ * @param {string=} args.filepath optional get the commit for the filepath only
2120
+ * @param {string} [args.ref = 'HEAD'] - The commit to begin walking backwards through the history from
2121
+ * @param {number=} [args.depth] - Limit the number of commits returned. No limit by default.
2122
+ * @param {Date} [args.since] - Return history newer than the given date. Can be combined with `depth` to get whichever is shorter.
2123
+ * @param {boolean=} [args.force=false] do not throw error if filepath is not exist (works only for a single file). defaults to false
2124
+ * @param {boolean=} [args.follow=false] Continue listing the history of a file beyond renames (works only for a single file). defaults to false
2125
+ * @param {object} [args.cache] - a [cache](cache.md) object
2126
+ *
2127
+ * @returns {Promise<Array<ReadCommitResult>>} Resolves to an array of ReadCommitResult objects
2128
+ * @see ReadCommitResult
2129
+ * @see CommitObject
2130
+ *
2131
+ * @example
2132
+ * let commits = await git.log({
2133
+ * fs,
2134
+ * dir: '/tutorial',
2135
+ * depth: 5,
2136
+ * ref: 'main'
2137
+ * })
2138
+ * console.log(commits)
2139
+ *
2140
+ */
2141
+ export function log({ fs, dir, gitdir, filepath, ref, depth, since, force, follow, cache, }: {
2142
+ fs: FsClient;
2143
+ dir?: string | undefined;
2144
+ gitdir?: string | undefined;
2145
+ filepath?: string | undefined;
2146
+ ref?: string | undefined;
2147
+ depth?: number | undefined;
2148
+ since?: Date | undefined;
2149
+ force?: boolean | undefined;
2150
+ follow?: boolean | undefined;
2151
+ cache?: object;
2152
+ }): Promise<Array<ReadCommitResult>>;
2153
+ /**
2154
+ *
2155
+ * @typedef {Object} MergeResult - Returns an object with a schema like this:
2156
+ * @property {string} [oid] - The SHA-1 object id that is now at the head of the branch. Absent only if `dryRun` was specified and `mergeCommit` is true.
2157
+ * @property {boolean} [alreadyMerged] - True if the branch was already merged so no changes were made
2158
+ * @property {boolean} [fastForward] - True if it was a fast-forward merge
2159
+ * @property {boolean} [mergeCommit] - True if merge resulted in a merge commit
2160
+ * @property {string} [tree] - The SHA-1 object id of the tree resulting from a merge commit
2161
+ *
2162
+ */
2163
+ /**
2164
+ * Merge two branches
2165
+ *
2166
+ * Currently it will fail if multiple candidate merge bases are found. (It doesn't yet implement the recursive merge strategy.)
2167
+ *
2168
+ * Currently it does not support selecting alternative merge strategies.
2169
+ *
2170
+ * Currently it is not possible to abort an incomplete merge. To restore the worktree to a clean state, you will need to checkout an earlier commit.
2171
+ *
2172
+ * Currently it does not directly support the behavior of `git merge --continue`. To complete a merge after manual conflict resolution, you will need to add and commit the files manually, and specify the appropriate parent commits.
2173
+ *
2174
+ * ## Manually resolving merge conflicts
2175
+ * By default, if isomorphic-git encounters a merge conflict it cannot resolve using the builtin diff3 algorithm or provided merge driver, it will abort and throw a `MergeNotSupportedError`.
2176
+ * This leaves the index and working tree untouched.
2177
+ *
2178
+ * When `abortOnConflict` is set to `false`, and a merge conflict cannot be automatically resolved, a `MergeConflictError` is thrown and the results of the incomplete merge will be written to the working directory.
2179
+ * This includes conflict markers in files with unresolved merge conflicts.
2180
+ *
2181
+ * To complete the merge, edit the conflicting files as you see fit, and then add and commit the resolved merge.
2182
+ *
2183
+ * For a proper merge commit, be sure to specify the branches or commits you are merging in the `parent` argument to `git.commit`.
2184
+ * For example, say we are merging the branch `feature` into the branch `main` and there is a conflict we want to resolve manually.
2185
+ * The flow would look like this:
2186
+ *
2187
+ * ```
2188
+ * await git.merge({
2189
+ * fs,
2190
+ * dir,
2191
+ * ours: 'main',
2192
+ * theirs: 'feature',
2193
+ * abortOnConflict: false,
2194
+ * }).catch(e => {
2195
+ * if (e instanceof Errors.MergeConflictError) {
2196
+ * console.log(
2197
+ * 'Automatic merge failed for the following files: '
2198
+ * + `${e.data}. `
2199
+ * + 'Resolve these conflicts and then commit your changes.'
2200
+ * )
2201
+ * } else throw e
2202
+ * })
2203
+ *
2204
+ * // This is the where we manually edit the files that have been written to the working directory
2205
+ * // ...
2206
+ * // Files have been edited and we are ready to commit
2207
+ *
2208
+ * await git.add({
2209
+ * fs,
2210
+ * dir,
2211
+ * filepath: '.',
2212
+ * })
2213
+ *
2214
+ * await git.commit({
2215
+ * fs,
2216
+ * dir,
2217
+ * ref: 'main',
2218
+ * message: "Merge branch 'feature' into main",
2219
+ * parent: ['main', 'feature'], // Be sure to specify the parents when creating a merge commit
2220
+ * })
2221
+ * ```
2222
+ *
2223
+ * @param {object} args
2224
+ * @param {FsClient} args.fs - a file system client
2225
+ * @param {SignCallback} [args.onSign] - a PGP signing implementation
2226
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
2227
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
2228
+ * @param {string} [args.ours] - The branch receiving the merge. If undefined, defaults to the current branch.
2229
+ * @param {string} args.theirs - The branch to be merged
2230
+ * @param {boolean} [args.fastForward = true] - If false, create a merge commit in all cases.
2231
+ * @param {boolean} [args.fastForwardOnly = false] - If true, then non-fast-forward merges will throw an Error instead of performing a merge.
2232
+ * @param {boolean} [args.dryRun = false] - If true, simulates a merge so you can test whether it would succeed.
2233
+ * @param {boolean} [args.noUpdateBranch = false] - If true, does not update the branch pointer after creating the commit.
2234
+ * @param {boolean} [args.abortOnConflict = true] - If true, merges with conflicts will not update the worktree or index.
2235
+ * @param {string} [args.message] - Overrides the default auto-generated merge commit message
2236
+ * @param {Object} [args.author] - passed to [commit](commit.md) when creating a merge commit
2237
+ * @param {string} [args.author.name] - Default is `user.name` config.
2238
+ * @param {string} [args.author.email] - Default is `user.email` config.
2239
+ * @param {number} [args.author.timestamp=Math.floor(Date.now()/1000)] - Set the author timestamp field. This is the integer number of seconds since the Unix epoch (1970-01-01 00:00:00).
2240
+ * @param {number} [args.author.timezoneOffset] - Set the author timezone offset field. This is the difference, in minutes, from the current timezone to UTC. Default is `(new Date()).getTimezoneOffset()`.
2241
+ * @param {Object} [args.committer] - passed to [commit](commit.md) when creating a merge commit
2242
+ * @param {string} [args.committer.name] - Default is `user.name` config.
2243
+ * @param {string} [args.committer.email] - Default is `user.email` config.
2244
+ * @param {number} [args.committer.timestamp=Math.floor(Date.now()/1000)] - Set the committer timestamp field. This is the integer number of seconds since the Unix epoch (1970-01-01 00:00:00).
2245
+ * @param {number} [args.committer.timezoneOffset] - Set the committer timezone offset field. This is the difference, in minutes, from the current timezone to UTC. Default is `(new Date()).getTimezoneOffset()`.
2246
+ * @param {string} [args.signingKey] - passed to [commit](commit.md) when creating a merge commit
2247
+ * @param {object} [args.cache] - a [cache](cache.md) object
2248
+ * @param {MergeDriverCallback} [args.mergeDriver] - a [merge driver](mergeDriver.md) implementation
2249
+ * @param {boolean} [args.allowUnrelatedHistories = false] - If true, allows merging histories of two branches that started their lives independently.
2250
+ *
2251
+ * @returns {Promise<MergeResult>} Resolves to a description of the merge operation
2252
+ * @see MergeResult
2253
+ *
2254
+ * @example
2255
+ * let m = await git.merge({
2256
+ * fs,
2257
+ * dir: '/tutorial',
2258
+ * ours: 'main',
2259
+ * theirs: 'remotes/origin/main'
2260
+ * })
2261
+ * console.log(m)
2262
+ *
2263
+ */
2264
+ export function merge({ fs: _fs, onSign, dir, gitdir, ours, theirs, fastForward, fastForwardOnly, dryRun, noUpdateBranch, abortOnConflict, message, author: _author, committer: _committer, signingKey, cache, mergeDriver, allowUnrelatedHistories, }: {
2265
+ fs: FsClient;
2266
+ onSign?: SignCallback | undefined;
2267
+ dir?: string | undefined;
2268
+ gitdir?: string | undefined;
2269
+ ours?: string | undefined;
2270
+ theirs: string;
2271
+ fastForward?: boolean | undefined;
2272
+ fastForwardOnly?: boolean | undefined;
2273
+ dryRun?: boolean | undefined;
2274
+ noUpdateBranch?: boolean | undefined;
2275
+ abortOnConflict?: boolean | undefined;
2276
+ message?: string | undefined;
2277
+ author?: {
2278
+ name?: string | undefined;
2279
+ email?: string | undefined;
2280
+ timestamp?: number | undefined;
2281
+ timezoneOffset?: number | undefined;
2282
+ } | undefined;
2283
+ committer?: {
2284
+ name?: string | undefined;
2285
+ email?: string | undefined;
2286
+ timestamp?: number | undefined;
2287
+ timezoneOffset?: number | undefined;
2288
+ } | undefined;
2289
+ signingKey?: string | undefined;
2290
+ cache?: object;
2291
+ mergeDriver?: MergeDriverCallback | undefined;
2292
+ allowUnrelatedHistories?: boolean | undefined;
2293
+ }): Promise<MergeResult>;
2294
+ /**
2295
+ *
2296
+ * @typedef {Object} PackObjectsResult The packObjects command returns an object with two properties:
2297
+ * @property {string} filename - The suggested filename for the packfile if you want to save it to disk somewhere. It includes the packfile SHA.
2298
+ * @property {Uint8Array} [packfile] - The packfile contents. Not present if `write` parameter was true, in which case the packfile was written straight to disk.
2299
+ */
2300
+ /**
2301
+ * Create a packfile from an array of SHA-1 object ids
2302
+ *
2303
+ * @param {object} args
2304
+ * @param {FsClient} args.fs - a file system client
2305
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
2306
+ * @param {string} [args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path
2307
+ * @param {string[]} args.oids - An array of SHA-1 object ids to be included in the packfile
2308
+ * @param {boolean} [args.write = false] - Whether to save the packfile to disk or not
2309
+ * @param {object} [args.cache] - a [cache](cache.md) object
2310
+ *
2311
+ * @returns {Promise<PackObjectsResult>} Resolves successfully when the packfile is ready with the filename and buffer
2312
+ * @see PackObjectsResult
2313
+ *
2314
+ * @example
2315
+ * // Create a packfile containing only an empty tree
2316
+ * let { packfile } = await git.packObjects({
2317
+ * fs,
2318
+ * dir: '/tutorial',
2319
+ * oids: ['4b825dc642cb6eb9a060e54bf8d69288fbee4904']
2320
+ * })
2321
+ * console.log(packfile)
2322
+ *
2323
+ */
2324
+ export function packObjects({ fs, dir, gitdir, oids, write, cache, }: {
2325
+ fs: FsClient;
2326
+ dir?: string | undefined;
2327
+ gitdir?: string | undefined;
2328
+ oids: string[];
2329
+ write?: boolean | undefined;
2330
+ cache?: object;
2331
+ }): Promise<PackObjectsResult>;
2332
+ /**
2333
+ * Fetch and merge commits from a remote repository
2334
+ *
2335
+ * @param {object} args
2336
+ * @param {FsClient} args.fs - a file system client
2337
+ * @param {HttpClient} args.http - an HTTP client
2338
+ * @param {ProgressCallback} [args.onProgress] - optional progress event callback
2339
+ * @param {MessageCallback} [args.onMessage] - optional message event callback
2340
+ * @param {AuthCallback} [args.onAuth] - optional auth fill callback
2341
+ * @param {AuthFailureCallback} [args.onAuthFailure] - optional auth rejected callback
2342
+ * @param {AuthSuccessCallback} [args.onAuthSuccess] - optional auth approved callback
2343
+ * @param {string} args.dir] - The [working tree](dir-vs-gitdir.md) directory path
2344
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
2345
+ * @param {string} [args.ref] - Which branch to merge into. By default this is the currently checked out branch.
2346
+ * @param {string} [args.url] - (Added in 1.1.0) The URL of the remote repository. The default is the value set in the git config for that remote.
2347
+ * @param {string} [args.remote] - (Added in 1.1.0) If URL is not specified, determines which remote to use.
2348
+ * @param {string} [args.remoteRef] - (Added in 1.1.0) The name of the branch on the remote to fetch. By default this is the configured remote tracking branch.
2349
+ * @param {boolean} [args.prune = false] - Delete local remote-tracking branches that are not present on the remote
2350
+ * @param {boolean} [args.pruneTags = false] - Prune local tags that don’t exist on the remote, and force-update those tags that differ
2351
+ * @param {string} [args.corsProxy] - Optional [CORS proxy](https://www.npmjs.com/%40isomorphic-git/cors-proxy). Overrides value in repo config.
2352
+ * @param {boolean} [args.singleBranch = false] - Instead of the default behavior of fetching all the branches, only fetch a single branch.
2353
+ * @param {boolean} [args.fastForward = true] - If false, only create merge commits.
2354
+ * @param {boolean} [args.fastForwardOnly = false] - Only perform simple fast-forward merges. (Don't create merge commits.)
2355
+ * @param {Object<string, string>} [args.headers] - Additional headers to include in HTTP requests, similar to git's `extraHeader` config
2356
+ * @param {Object} [args.author] - The details about the author.
2357
+ * @param {string} [args.author.name] - Default is `user.name` config.
2358
+ * @param {string} [args.author.email] - Default is `user.email` config.
2359
+ * @param {number} [args.author.timestamp=Math.floor(Date.now()/1000)] - Set the author timestamp field. This is the integer number of seconds since the Unix epoch (1970-01-01 00:00:00).
2360
+ * @param {number} [args.author.timezoneOffset] - Set the author timezone offset field. This is the difference, in minutes, from the current timezone to UTC. Default is `(new Date()).getTimezoneOffset()`.
2361
+ * @param {Object} [args.committer = author] - The details about the commit committer, in the same format as the author parameter. If not specified, the author details are used.
2362
+ * @param {string} [args.committer.name] - Default is `user.name` config.
2363
+ * @param {string} [args.committer.email] - Default is `user.email` config.
2364
+ * @param {number} [args.committer.timestamp=Math.floor(Date.now()/1000)] - Set the committer timestamp field. This is the integer number of seconds since the Unix epoch (1970-01-01 00:00:00).
2365
+ * @param {number} [args.committer.timezoneOffset] - Set the committer timezone offset field. This is the difference, in minutes, from the current timezone to UTC. Default is `(new Date()).getTimezoneOffset()`.
2366
+ * @param {string} [args.signingKey] - passed to [commit](commit.md) when creating a merge commit
2367
+ * @param {object} [args.cache] - a [cache](cache.md) object
2368
+ *
2369
+ * @returns {Promise<void>} Resolves successfully when pull operation completes
2370
+ *
2371
+ * @example
2372
+ * await git.pull({
2373
+ * fs,
2374
+ * http,
2375
+ * dir: '/tutorial',
2376
+ * ref: 'main',
2377
+ * singleBranch: true
2378
+ * })
2379
+ * console.log('done')
2380
+ *
2381
+ */
2382
+ export function pull({ fs: _fs, http, onProgress, onMessage, onAuth, onAuthSuccess, onAuthFailure, dir, gitdir, ref, url, remote, remoteRef, prune, pruneTags, fastForward, fastForwardOnly, corsProxy, singleBranch, headers, author: _author, committer: _committer, signingKey, cache, }: {
2383
+ fs: FsClient;
2384
+ http: HttpClient;
2385
+ onProgress?: ProgressCallback | undefined;
2386
+ onMessage?: MessageCallback | undefined;
2387
+ onAuth?: AuthCallback | undefined;
2388
+ onAuthFailure?: AuthFailureCallback | undefined;
2389
+ onAuthSuccess?: AuthSuccessCallback | undefined;
2390
+ dir: string;
2391
+ gitdir?: string | undefined;
2392
+ ref?: string | undefined;
2393
+ url?: string | undefined;
2394
+ remote?: string | undefined;
2395
+ remoteRef?: string | undefined;
2396
+ prune?: boolean | undefined;
2397
+ pruneTags?: boolean | undefined;
2398
+ corsProxy?: string | undefined;
2399
+ singleBranch?: boolean | undefined;
2400
+ fastForward?: boolean | undefined;
2401
+ fastForwardOnly?: boolean | undefined;
2402
+ headers?: {
2403
+ [x: string]: string;
2404
+ } | undefined;
2405
+ author?: {
2406
+ name?: string | undefined;
2407
+ email?: string | undefined;
2408
+ timestamp?: number | undefined;
2409
+ timezoneOffset?: number | undefined;
2410
+ } | undefined;
2411
+ committer?: {
2412
+ name?: string | undefined;
2413
+ email?: string | undefined;
2414
+ timestamp?: number | undefined;
2415
+ timezoneOffset?: number | undefined;
2416
+ } | undefined;
2417
+ signingKey?: string | undefined;
2418
+ cache?: object;
2419
+ }): Promise<void>;
2420
+ /**
2421
+ * Push a branch or tag
2422
+ *
2423
+ * The push command returns an object that describes the result of the attempted push operation.
2424
+ * *Notes:* If there were no errors, then there will be no `errors` property. There can be a mix of `ok` messages and `errors` messages.
2425
+ *
2426
+ * | param | type [= default] | description |
2427
+ * | ------ | ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
2428
+ * | ok | Array\<string\> | The first item is "unpack" if the overall operation was successful. The remaining items are the names of refs that were updated successfully. |
2429
+ * | errors | Array\<string\> | If the overall operation threw and error, the first item will be "unpack {Overall error message}". The remaining items are individual refs that failed to be updated in the format "{ref name} {error message}". |
2430
+ *
2431
+ * @param {object} args
2432
+ * @param {FsClient} args.fs - a file system client
2433
+ * @param {HttpClient} args.http - an HTTP client
2434
+ * @param {ProgressCallback} [args.onProgress] - optional progress event callback
2435
+ * @param {MessageCallback} [args.onMessage] - optional message event callback
2436
+ * @param {AuthCallback} [args.onAuth] - optional auth fill callback
2437
+ * @param {AuthFailureCallback} [args.onAuthFailure] - optional auth rejected callback
2438
+ * @param {AuthSuccessCallback} [args.onAuthSuccess] - optional auth approved callback
2439
+ * @param {PrePushCallback} [args.onPrePush] - optional pre-push hook callback
2440
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
2441
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
2442
+ * @param {string} [args.ref] - Which branch or tag to push. By default this is the currently checked out branch.
2443
+ * @param {string} [args.url] - The URL of the remote repository. The default is the value set in the git config for that remote.
2444
+ * @param {string} [args.remote] - If URL is not specified, determines which remote to use.
2445
+ * @param {string} [args.remoteRef] - The name of the receiving branch on the remote. By default this is the configured remote tracking branch.
2446
+ * @param {boolean} [args.force = false] - If true, behaves the same as `git push --force`
2447
+ * @param {boolean} [args.delete = false] - If true, delete the remote ref
2448
+ * @param {string} [args.corsProxy] - Optional [CORS proxy](https://www.npmjs.com/%40isomorphic-git/cors-proxy). Overrides value in repo config.
2449
+ * @param {Object<string, string>} [args.headers] - Additional headers to include in HTTP requests, similar to git's `extraHeader` config
2450
+ * @param {object} [args.cache] - a [cache](cache.md) object
2451
+ *
2452
+ * @returns {Promise<PushResult>} Resolves successfully when push completes with a detailed description of the operation from the server.
2453
+ * @see PushResult
2454
+ * @see RefUpdateStatus
2455
+ *
2456
+ * @example
2457
+ * let pushResult = await git.push({
2458
+ * fs,
2459
+ * http,
2460
+ * dir: '/tutorial',
2461
+ * remote: 'origin',
2462
+ * ref: 'main',
2463
+ * onAuth: () => ({ username: process.env.GITHUB_TOKEN }),
2464
+ * })
2465
+ * console.log(pushResult)
2466
+ *
2467
+ */
2468
+ export function push({ fs, http, onProgress, onMessage, onAuth, onAuthSuccess, onAuthFailure, onPrePush, dir, gitdir, ref, remoteRef, remote, url, force, delete: _delete, corsProxy, headers, cache, }: {
2469
+ fs: FsClient;
2470
+ http: HttpClient;
2471
+ onProgress?: ProgressCallback | undefined;
2472
+ onMessage?: MessageCallback | undefined;
2473
+ onAuth?: AuthCallback | undefined;
2474
+ onAuthFailure?: AuthFailureCallback | undefined;
2475
+ onAuthSuccess?: AuthSuccessCallback | undefined;
2476
+ onPrePush?: PrePushCallback | undefined;
2477
+ dir?: string | undefined;
2478
+ gitdir?: string | undefined;
2479
+ ref?: string | undefined;
2480
+ url?: string | undefined;
2481
+ remote?: string | undefined;
2482
+ remoteRef?: string | undefined;
2483
+ force?: boolean | undefined;
2484
+ delete?: boolean | undefined;
2485
+ corsProxy?: string | undefined;
2486
+ headers?: {
2487
+ [x: string]: string;
2488
+ } | undefined;
2489
+ cache?: object;
2490
+ }): Promise<PushResult>;
2491
+ /**
2492
+ *
2493
+ * @typedef {Object} ReadBlobResult - The object returned has the following schema:
2494
+ * @property {string} oid
2495
+ * @property {Uint8Array} blob
2496
+ *
2497
+ */
2498
+ /**
2499
+ * Read a blob object directly
2500
+ *
2501
+ * @param {object} args
2502
+ * @param {FsClient} args.fs - a file system client
2503
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
2504
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
2505
+ * @param {string} args.oid - The SHA-1 object id to get. Annotated tags, commits, and trees are peeled.
2506
+ * @param {string} [args.filepath] - Don't return the object with `oid` itself, but resolve `oid` to a tree and then return the blob object at that filepath.
2507
+ * @param {object} [args.cache] - a [cache](cache.md) object
2508
+ *
2509
+ * @returns {Promise<ReadBlobResult>} Resolves successfully with a blob object description
2510
+ * @see ReadBlobResult
2511
+ *
2512
+ * @example
2513
+ * // Get the contents of 'README.md' in the main branch.
2514
+ * let commitOid = await git.resolveRef({ fs, dir: '/tutorial', ref: 'main' })
2515
+ * console.log(commitOid)
2516
+ * let { blob } = await git.readBlob({
2517
+ * fs,
2518
+ * dir: '/tutorial',
2519
+ * oid: commitOid,
2520
+ * filepath: 'README.md'
2521
+ * })
2522
+ * console.log(Buffer.from(blob).toString('utf8'))
2523
+ *
2524
+ */
2525
+ export function readBlob({ fs, dir, gitdir, oid, filepath, cache, }: {
2526
+ fs: FsClient;
2527
+ dir?: string | undefined;
2528
+ gitdir?: string | undefined;
2529
+ oid: string;
2530
+ filepath?: string | undefined;
2531
+ cache?: object;
2532
+ }): Promise<ReadBlobResult>;
2533
+ /**
2534
+ * Read a commit object directly
2535
+ *
2536
+ * @param {object} args
2537
+ * @param {FsClient} args.fs - a file system client
2538
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
2539
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
2540
+ * @param {string} args.oid - The SHA-1 object id to get. Annotated tags are peeled.
2541
+ * @param {object} [args.cache] - a [cache](cache.md) object
2542
+ *
2543
+ * @returns {Promise<ReadCommitResult>} Resolves successfully with a git commit object
2544
+ * @see ReadCommitResult
2545
+ * @see CommitObject
2546
+ *
2547
+ * @example
2548
+ * // Read a commit object
2549
+ * let sha = await git.resolveRef({ fs, dir: '/tutorial', ref: 'main' })
2550
+ * console.log(sha)
2551
+ * let commit = await git.readCommit({ fs, dir: '/tutorial', oid: sha })
2552
+ * console.log(commit)
2553
+ *
2554
+ */
2555
+ export function readCommit({ fs, dir, gitdir, oid, cache, }: {
2556
+ fs: FsClient;
2557
+ dir?: string | undefined;
2558
+ gitdir?: string | undefined;
2559
+ oid: string;
2560
+ cache?: object;
2561
+ }): Promise<ReadCommitResult>;
2562
+ /**
2563
+ * Read the contents of a note
2564
+ *
2565
+ * @param {object} args
2566
+ * @param {FsClient} args.fs - a file system client
2567
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
2568
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
2569
+ * @param {string} [args.ref] - The notes ref to look under
2570
+ * @param {string} args.oid - The SHA-1 object id of the object to get the note for.
2571
+ * @param {object} [args.cache] - a [cache](cache.md) object
2572
+ *
2573
+ * @returns {Promise<Uint8Array>} Resolves successfully with note contents as a Buffer.
2574
+ */
2575
+ export function readNote({ fs, dir, gitdir, ref, oid, cache, }: {
2576
+ fs: FsClient;
2577
+ dir?: string | undefined;
2578
+ gitdir?: string | undefined;
2579
+ ref?: string | undefined;
2580
+ oid: string;
2581
+ cache?: object;
2582
+ }): Promise<Uint8Array>;
2583
+ /**
2584
+ *
2585
+ * @typedef {Object} DeflatedObject
2586
+ * @property {string} oid
2587
+ * @property {'deflated'} type
2588
+ * @property {'deflated'} format
2589
+ * @property {Uint8Array} object
2590
+ * @property {string} [source]
2591
+ *
2592
+ */
2593
+ /**
2594
+ *
2595
+ * @typedef {Object} WrappedObject
2596
+ * @property {string} oid
2597
+ * @property {'wrapped'} type
2598
+ * @property {'wrapped'} format
2599
+ * @property {Uint8Array} object
2600
+ * @property {string} [source]
2601
+ *
2602
+ */
2603
+ /**
2604
+ *
2605
+ * @typedef {Object} RawObject
2606
+ * @property {string} oid
2607
+ * @property {'blob'|'commit'|'tree'|'tag'} type
2608
+ * @property {'content'} format
2609
+ * @property {Uint8Array} object
2610
+ * @property {string} [source]
2611
+ *
2612
+ */
2613
+ /**
2614
+ *
2615
+ * @typedef {Object} ParsedBlobObject
2616
+ * @property {string} oid
2617
+ * @property {'blob'} type
2618
+ * @property {'parsed'} format
2619
+ * @property {string} object
2620
+ * @property {string} [source]
2621
+ *
2622
+ */
2623
+ /**
2624
+ *
2625
+ * @typedef {Object} ParsedCommitObject
2626
+ * @property {string} oid
2627
+ * @property {'commit'} type
2628
+ * @property {'parsed'} format
2629
+ * @property {CommitObject} object
2630
+ * @property {string} [source]
2631
+ *
2632
+ */
2633
+ /**
2634
+ *
2635
+ * @typedef {Object} ParsedTreeObject
2636
+ * @property {string} oid
2637
+ * @property {'tree'} type
2638
+ * @property {'parsed'} format
2639
+ * @property {TreeObject} object
2640
+ * @property {string} [source]
2641
+ *
2642
+ */
2643
+ /**
2644
+ *
2645
+ * @typedef {Object} ParsedTagObject
2646
+ * @property {string} oid
2647
+ * @property {'tag'} type
2648
+ * @property {'parsed'} format
2649
+ * @property {TagObject} object
2650
+ * @property {string} [source]
2651
+ *
2652
+ */
2653
+ /**
2654
+ *
2655
+ * @typedef {ParsedBlobObject | ParsedCommitObject | ParsedTreeObject | ParsedTagObject} ParsedObject
2656
+ */
2657
+ /**
2658
+ *
2659
+ * @typedef {DeflatedObject | WrappedObject | RawObject | ParsedObject } ReadObjectResult
2660
+ */
2661
+ /**
2662
+ * Read a git object directly by its SHA-1 object id
2663
+ *
2664
+ * Regarding `ReadObjectResult`:
2665
+ *
2666
+ * - `oid` will be the same as the `oid` argument unless the `filepath` argument is provided, in which case it will be the oid of the tree or blob being returned.
2667
+ * - `type` of deflated objects is `'deflated'`, and `type` of wrapped objects is `'wrapped'`
2668
+ * - `format` is usually, but not always, the format you requested. Packfiles do not store each object individually compressed so if you end up reading the object from a packfile it will be returned in format 'content' even if you requested 'deflated' or 'wrapped'.
2669
+ * - `object` will be an actual Object if format is 'parsed' and the object is a commit, tree, or annotated tag. Blobs are still formatted as Buffers unless an encoding is provided in which case they'll be strings. If format is anything other than 'parsed', object will be a Buffer.
2670
+ * - `source` is the name of the packfile or loose object file where the object was found.
2671
+ *
2672
+ * The `format` parameter can have the following values:
2673
+ *
2674
+ * | param | description |
2675
+ * | ---------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
2676
+ * | 'deflated' | Return the raw deflate-compressed buffer for an object if possible. Useful for efficiently shuffling around loose objects when you don't care about the contents and can save time by not inflating them. |
2677
+ * | 'wrapped' | Return the inflated object buffer wrapped in the git object header if possible. This is the raw data used when calculating the SHA-1 object id of a git object. |
2678
+ * | 'content' | Return the object buffer without the git header. |
2679
+ * | 'parsed' | Returns a parsed representation of the object. |
2680
+ *
2681
+ * The result will be in one of the following schemas:
2682
+ *
2683
+ * ## `'deflated'` format
2684
+ *
2685
+ * {@link DeflatedObject typedef}
2686
+ *
2687
+ * ## `'wrapped'` format
2688
+ *
2689
+ * {@link WrappedObject typedef}
2690
+ *
2691
+ * ## `'content'` format
2692
+ *
2693
+ * {@link RawObject typedef}
2694
+ *
2695
+ * ## `'parsed'` format
2696
+ *
2697
+ * ### parsed `'blob'` type
2698
+ *
2699
+ * {@link ParsedBlobObject typedef}
2700
+ *
2701
+ * ### parsed `'commit'` type
2702
+ *
2703
+ * {@link ParsedCommitObject typedef}
2704
+ * {@link CommitObject typedef}
2705
+ *
2706
+ * ### parsed `'tree'` type
2707
+ *
2708
+ * {@link ParsedTreeObject typedef}
2709
+ * {@link TreeObject typedef}
2710
+ * {@link TreeEntry typedef}
2711
+ *
2712
+ * ### parsed `'tag'` type
2713
+ *
2714
+ * {@link ParsedTagObject typedef}
2715
+ * {@link TagObject typedef}
2716
+ *
2717
+ * @deprecated
2718
+ * > This command is overly complicated.
2719
+ * >
2720
+ * > If you know the type of object you are reading, use [`readBlob`](./readBlob.md), [`readCommit`](./readCommit.md), [`readTag`](./readTag.md), or [`readTree`](./readTree.md).
2721
+ *
2722
+ * @param {object} args
2723
+ * @param {FsClient} args.fs - a file system client
2724
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
2725
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
2726
+ * @param {string} args.oid - The SHA-1 object id to get
2727
+ * @param {'deflated' | 'wrapped' | 'content' | 'parsed'} [args.format = 'parsed'] - What format to return the object in. The choices are described in more detail below.
2728
+ * @param {string} [args.filepath] - Don't return the object with `oid` itself, but resolve `oid` to a tree and then return the object at that filepath. To return the root directory of a tree set filepath to `''`
2729
+ * @param {string} [args.encoding] - A convenience argument that only affects blobs. Instead of returning `object` as a buffer, it returns a string parsed using the given encoding.
2730
+ * @param {object} [args.cache] - a [cache](cache.md) object
2731
+ *
2732
+ * @returns {Promise<ReadObjectResult>} Resolves successfully with a git object description
2733
+ * @see ReadObjectResult
2734
+ *
2735
+ * @example
2736
+ * // Given a ransom SHA-1 object id, figure out what it is
2737
+ * let { type, object } = await git.readObject({
2738
+ * fs,
2739
+ * dir: '/tutorial',
2740
+ * oid: '0698a781a02264a6f37ba3ff41d78067eaf0f075'
2741
+ * })
2742
+ * switch (type) {
2743
+ * case 'commit': {
2744
+ * console.log(object)
2745
+ * break
2746
+ * }
2747
+ * case 'tree': {
2748
+ * console.log(object)
2749
+ * break
2750
+ * }
2751
+ * case 'blob': {
2752
+ * console.log(object)
2753
+ * break
2754
+ * }
2755
+ * case 'tag': {
2756
+ * console.log(object)
2757
+ * break
2758
+ * }
2759
+ * }
2760
+ *
2761
+ */
2762
+ export function readObject({ fs: _fs, dir, gitdir, oid, format, filepath, encoding, cache, }: {
2763
+ fs: FsClient;
2764
+ dir?: string | undefined;
2765
+ gitdir?: string | undefined;
2766
+ oid: string;
2767
+ format?: "deflated" | "content" | "wrapped" | "parsed" | undefined;
2768
+ filepath?: string | undefined;
2769
+ encoding?: string | undefined;
2770
+ cache?: object;
2771
+ }): Promise<ReadObjectResult>;
2772
+ /**
2773
+ *
2774
+ * @typedef {Object} ReadTagResult - The object returned has the following schema:
2775
+ * @property {string} oid - SHA-1 object id of this tag
2776
+ * @property {TagObject} tag - the parsed tag object
2777
+ * @property {string} payload - PGP signing payload
2778
+ */
2779
+ /**
2780
+ * Read an annotated tag object directly
2781
+ *
2782
+ * @param {object} args
2783
+ * @param {FsClient} args.fs - a file system client
2784
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
2785
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
2786
+ * @param {string} args.oid - The SHA-1 object id to get
2787
+ * @param {object} [args.cache] - a [cache](cache.md) object
2788
+ *
2789
+ * @returns {Promise<ReadTagResult>} Resolves successfully with a git object description
2790
+ * @see ReadTagResult
2791
+ * @see TagObject
2792
+ *
2793
+ */
2794
+ export function readTag({ fs, dir, gitdir, oid, cache, }: {
2795
+ fs: FsClient;
2796
+ dir?: string | undefined;
2797
+ gitdir?: string | undefined;
2798
+ oid: string;
2799
+ cache?: object;
2800
+ }): Promise<ReadTagResult>;
2801
+ /**
2802
+ *
2803
+ * @typedef {Object} ReadTreeResult - The object returned has the following schema:
2804
+ * @property {string} oid - SHA-1 object id of this tree
2805
+ * @property {TreeObject} tree - the parsed tree object
2806
+ */
2807
+ /**
2808
+ * Read a tree object directly
2809
+ *
2810
+ * @param {object} args
2811
+ * @param {FsClient} args.fs - a file system client
2812
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
2813
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
2814
+ * @param {string} args.oid - The SHA-1 object id to get. Annotated tags and commits are peeled.
2815
+ * @param {string} [args.filepath] - Don't return the object with `oid` itself, but resolve `oid` to a tree and then return the tree object at that filepath.
2816
+ * @param {object} [args.cache] - a [cache](cache.md) object
2817
+ *
2818
+ * @returns {Promise<ReadTreeResult>} Resolves successfully with a git tree object
2819
+ * @see ReadTreeResult
2820
+ * @see TreeObject
2821
+ * @see TreeEntry
2822
+ *
2823
+ */
2824
+ export function readTree({ fs, dir, gitdir, oid, filepath, cache, }: {
2825
+ fs: FsClient;
2826
+ dir?: string | undefined;
2827
+ gitdir?: string | undefined;
2828
+ oid: string;
2829
+ filepath?: string | undefined;
2830
+ cache?: object;
2831
+ }): Promise<ReadTreeResult>;
2832
+ /**
2833
+ * Remove a file from the git index (aka staging area)
2834
+ *
2835
+ * Note that this does NOT delete the file in the working directory.
2836
+ *
2837
+ * @param {object} args
2838
+ * @param {FsClient} args.fs - a file system client
2839
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
2840
+ * @param {string} [args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path
2841
+ * @param {string} args.filepath - The path to the file to remove from the index
2842
+ * @param {object} [args.cache] - a [cache](cache.md) object
2843
+ *
2844
+ * @returns {Promise<void>} Resolves successfully once the git index has been updated
2845
+ *
2846
+ * @example
2847
+ * await git.remove({ fs, dir: '/tutorial', filepath: 'README.md' })
2848
+ * console.log('done')
2849
+ *
2850
+ */
2851
+ export function remove({ fs: _fs, dir, gitdir, filepath, cache, }: {
2852
+ fs: FsClient;
2853
+ dir?: string | undefined;
2854
+ gitdir?: string | undefined;
2855
+ filepath: string;
2856
+ cache?: object;
2857
+ }): Promise<void>;
2858
+ /**
2859
+ * Remove an object note
2860
+ *
2861
+ * @param {object} args
2862
+ * @param {FsClient} args.fs - a file system client
2863
+ * @param {SignCallback} [args.onSign] - a PGP signing implementation
2864
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
2865
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
2866
+ * @param {string} [args.ref] - The notes ref to look under
2867
+ * @param {string} args.oid - The SHA-1 object id of the object to remove the note from.
2868
+ * @param {Object} [args.author] - The details about the author.
2869
+ * @param {string} [args.author.name] - Default is `user.name` config.
2870
+ * @param {string} [args.author.email] - Default is `user.email` config.
2871
+ * @param {number} [args.author.timestamp=Math.floor(Date.now()/1000)] - Set the author timestamp field. This is the integer number of seconds since the Unix epoch (1970-01-01 00:00:00).
2872
+ * @param {number} [args.author.timezoneOffset] - Set the author timezone offset field. This is the difference, in minutes, from the current timezone to UTC. Default is `(new Date()).getTimezoneOffset()`.
2873
+ * @param {Object} [args.committer = author] - The details about the note committer, in the same format as the author parameter. If not specified, the author details are used.
2874
+ * @param {string} [args.committer.name] - Default is `user.name` config.
2875
+ * @param {string} [args.committer.email] - Default is `user.email` config.
2876
+ * @param {number} [args.committer.timestamp=Math.floor(Date.now()/1000)] - Set the committer timestamp field. This is the integer number of seconds since the Unix epoch (1970-01-01 00:00:00).
2877
+ * @param {number} [args.committer.timezoneOffset] - Set the committer timezone offset field. This is the difference, in minutes, from the current timezone to UTC. Default is `(new Date()).getTimezoneOffset()`.
2878
+ * @param {string} [args.signingKey] - Sign the tag object using this private PGP key.
2879
+ * @param {object} [args.cache] - a [cache](cache.md) object
2880
+ *
2881
+ * @returns {Promise<string>} Resolves successfully with the SHA-1 object id of the commit object for the note removal.
2882
+ */
2883
+ export function removeNote({ fs: _fs, onSign, dir, gitdir, ref, oid, author: _author, committer: _committer, signingKey, cache, }: {
2884
+ fs: FsClient;
2885
+ onSign?: SignCallback | undefined;
2886
+ dir?: string | undefined;
2887
+ gitdir?: string | undefined;
2888
+ ref?: string | undefined;
2889
+ oid: string;
2890
+ author?: {
2891
+ name?: string | undefined;
2892
+ email?: string | undefined;
2893
+ timestamp?: number | undefined;
2894
+ timezoneOffset?: number | undefined;
2895
+ } | undefined;
2896
+ committer?: {
2897
+ name?: string | undefined;
2898
+ email?: string | undefined;
2899
+ timestamp?: number | undefined;
2900
+ timezoneOffset?: number | undefined;
2901
+ } | undefined;
2902
+ signingKey?: string | undefined;
2903
+ cache?: object;
2904
+ }): Promise<string>;
2905
+ /**
2906
+ * Rename a branch
2907
+ *
2908
+ * @param {object} args
2909
+ * @param {FsClient} args.fs - a file system implementation
2910
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
2911
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
2912
+ * @param {string} args.ref - What to name the branch
2913
+ * @param {string} args.oldref - What the name of the branch was
2914
+ * @param {boolean} [args.checkout = false] - Update `HEAD` to point at the newly created branch
2915
+ *
2916
+ * @returns {Promise<void>} Resolves successfully when filesystem operations are complete
2917
+ *
2918
+ * @example
2919
+ * await git.renameBranch({ fs, dir: '/tutorial', ref: 'main', oldref: 'master' })
2920
+ * console.log('done')
2921
+ *
2922
+ */
2923
+ export function renameBranch({ fs, dir, gitdir, ref, oldref, checkout, }: {
2924
+ fs: FsClient;
2925
+ dir?: string | undefined;
2926
+ gitdir?: string | undefined;
2927
+ ref: string;
2928
+ oldref: string;
2929
+ checkout?: boolean | undefined;
2930
+ }): Promise<void>;
2931
+ /**
2932
+ * Reset a file in the git index (aka staging area)
2933
+ *
2934
+ * Note that this does NOT modify the file in the working directory.
2935
+ *
2936
+ * @param {object} args
2937
+ * @param {FsClient} args.fs - a file system client
2938
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
2939
+ * @param {string} [args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path
2940
+ * @param {string} args.filepath - The path to the file to reset in the index
2941
+ * @param {string} [args.ref = 'HEAD'] - A ref to the commit to use
2942
+ * @param {object} [args.cache] - a [cache](cache.md) object
2943
+ *
2944
+ * @returns {Promise<void>} Resolves successfully once the git index has been updated
2945
+ *
2946
+ * @example
2947
+ * await git.resetIndex({ fs, dir: '/tutorial', filepath: 'README.md' })
2948
+ * console.log('done')
2949
+ *
2950
+ */
2951
+ export function resetIndex({ fs: _fs, dir, gitdir, filepath, ref, cache, }: {
2952
+ fs: FsClient;
2953
+ dir?: string | undefined;
2954
+ gitdir?: string | undefined;
2955
+ filepath: string;
2956
+ ref?: string | undefined;
2957
+ cache?: object;
2958
+ }): Promise<void>;
2959
+ /**
2960
+ * Get the value of a symbolic ref or resolve a ref to its SHA-1 object id
2961
+ *
2962
+ * @param {object} args
2963
+ * @param {FsClient} args.fs - a file system client
2964
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
2965
+ * @param {string} [args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path
2966
+ * @param {string} args.ref - The ref to resolve
2967
+ * @param {number} [args.depth = undefined] - How many symbolic references to follow before returning
2968
+ *
2969
+ * @returns {Promise<string>} Resolves successfully with a SHA-1 object id or the value of a symbolic ref
2970
+ *
2971
+ * @example
2972
+ * let currentCommit = await git.resolveRef({ fs, dir: '/tutorial', ref: 'HEAD' })
2973
+ * console.log(currentCommit)
2974
+ * let currentBranch = await git.resolveRef({ fs, dir: '/tutorial', ref: 'HEAD', depth: 2 })
2975
+ * console.log(currentBranch)
2976
+ *
2977
+ */
2978
+ export function resolveRef({ fs, dir, gitdir, ref, depth, }: {
2979
+ fs: FsClient;
2980
+ dir?: string | undefined;
2981
+ gitdir?: string | undefined;
2982
+ ref: string;
2983
+ depth?: number | undefined;
2984
+ }): Promise<string>;
2985
+ /**
2986
+ * Write an entry to the git config files.
2987
+ *
2988
+ * *Caveats:*
2989
+ * - Currently only the local `$GIT_DIR/config` file can be read or written. However support for the global `~/.gitconfig` and system `$(prefix)/etc/gitconfig` will be added in the future.
2990
+ * - The current parser does not support the more exotic features of the git-config file format such as `[include]` and `[includeIf]`.
2991
+ *
2992
+ * @param {Object} args
2993
+ * @param {FsClient} args.fs - a file system implementation
2994
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
2995
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
2996
+ * @param {string} args.path - The key of the git config entry
2997
+ * @param {string | boolean | number | void} args.value - A value to store at that path. (Use `undefined` as the value to delete a config entry.)
2998
+ * @param {boolean} [args.append = false] - If true, will append rather than replace when setting (use with multi-valued config options).
2999
+ *
3000
+ * @returns {Promise<void>} Resolves successfully when operation completed
3001
+ *
3002
+ * @example
3003
+ * // Write config value
3004
+ * await git.setConfig({
3005
+ * fs,
3006
+ * dir: '/tutorial',
3007
+ * path: 'user.name',
3008
+ * value: 'Mr. Test'
3009
+ * })
3010
+ *
3011
+ * // Print out config file
3012
+ * let file = await fs.promises.readFile('/tutorial/.git/config', 'utf8')
3013
+ * console.log(file)
3014
+ *
3015
+ * // Delete a config entry
3016
+ * await git.setConfig({
3017
+ * fs,
3018
+ * dir: '/tutorial',
3019
+ * path: 'user.name',
3020
+ * value: undefined
3021
+ * })
3022
+ *
3023
+ * // Print out config file
3024
+ * file = await fs.promises.readFile('/tutorial/.git/config', 'utf8')
3025
+ * console.log(file)
3026
+ */
3027
+ export function setConfig({ fs: _fs, dir, gitdir, path, value, append, }: {
3028
+ fs: FsClient;
3029
+ dir?: string | undefined;
3030
+ gitdir?: string | undefined;
3031
+ path: string;
3032
+ value: string | boolean | number | void;
3033
+ append?: boolean | undefined;
3034
+ }): Promise<void>;
3035
+ /**
3036
+ * stash api, supports {'push' | 'pop' | 'apply' | 'drop' | 'list' | 'clear' | 'create'} StashOp
3037
+ * _note_,
3038
+ * - all stash operations are done on tracked files only with loose objects, no packed objects
3039
+ * - when op === 'push', both working directory and index (staged) changes will be stashed, tracked files only
3040
+ * - when op === 'push', message is optional, and only applicable when op === 'push'
3041
+ * - when op === 'apply | pop', the stashed changes will overwrite the working directory, no abort when conflicts
3042
+ * - when op === 'create', creates a stash commit without modifying working directory or refs, returns the commit hash
3043
+ *
3044
+ * @param {object} args
3045
+ * @param {FsClient} args.fs - [required] a file system client
3046
+ * @param {string} [args.dir] - [required] The [working tree](dir-vs-gitdir.md) directory path
3047
+ * @param {string} [args.gitdir=join(dir,'.git')] - [optional] The [git directory](dir-vs-gitdir.md) path
3048
+ * @param {'push' | 'pop' | 'apply' | 'drop' | 'list' | 'clear' | 'create'} [args.op = 'push'] - [optional] name of stash operation, default to 'push'
3049
+ * @param {string} [args.message = ''] - [optional] message to be used for the stash entry, only applicable when op === 'push' or 'create'
3050
+ * @param {number} [args.refIdx = 0] - [optional - Number] stash ref index of entry, only applicable when op === ['apply' | 'drop' | 'pop'], refIdx >= 0 and < num of stash pushed
3051
+ * @returns {Promise<string | void>} Resolves successfully when stash operations are complete. Returns commit hash for 'create' operation.
3052
+ *
3053
+ * @example
3054
+ * // stash changes in the working directory and index
3055
+ * let dir = '/tutorial'
3056
+ * await fs.promises.writeFile(`${dir}/a.txt`, 'original content - a')
3057
+ * await fs.promises.writeFile(`${dir}/b.js`, 'original content - b')
3058
+ * await git.add({ fs, dir, filepath: [`a.txt`,`b.txt`] })
3059
+ * let sha = await git.commit({
3060
+ * fs,
3061
+ * dir,
3062
+ * author: {
3063
+ * name: 'Mr. Stash',
3064
+ * email: 'mstasher@stash.com',
3065
+ * },
3066
+ * message: 'add a.txt and b.txt to test stash'
3067
+ * })
3068
+ * console.log(sha)
3069
+ *
3070
+ * await fs.promises.writeFile(`${dir}/a.txt`, 'stashed chang- a')
3071
+ * await git.add({ fs, dir, filepath: `${dir}/a.txt` })
3072
+ * await fs.promises.writeFile(`${dir}/b.js`, 'work dir change. not stashed - b')
3073
+ *
3074
+ * await git.stash({ fs, dir }) // default gitdir and op
3075
+ *
3076
+ * console.log(await git.status({ fs, dir, filepath: 'a.txt' })) // 'unmodified'
3077
+ * console.log(await git.status({ fs, dir, filepath: 'b.txt' })) // 'unmodified'
3078
+ *
3079
+ * const refLog = await git.stash({ fs, dir, op: 'list' })
3080
+ * console.log(refLog) // [{stash{#} message}]
3081
+ *
3082
+ * await git.stash({ fs, dir, op: 'apply' }) // apply the stash
3083
+ *
3084
+ * console.log(await git.status({ fs, dir, filepath: 'a.txt' })) // 'modified'
3085
+ * console.log(await git.status({ fs, dir, filepath: 'b.txt' })) // '*modified'
3086
+ *
3087
+ * // create a stash commit without modifying working directory
3088
+ * const stashCommitHash = await git.stash({ fs, dir, op: 'create', message: 'my stash' })
3089
+ * console.log(stashCommitHash) // returns the stash commit hash
3090
+ */
3091
+ export function stash({ fs, dir, gitdir, op, message, refIdx, }: {
3092
+ fs: FsClient;
3093
+ dir?: string | undefined;
3094
+ gitdir?: string | undefined;
3095
+ op?: "pop" | "push" | "apply" | "drop" | "list" | "clear" | "create" | undefined;
3096
+ message?: string | undefined;
3097
+ refIdx?: number | undefined;
3098
+ }): Promise<string | void>;
3099
+ /**
3100
+ * Tell whether a file has been changed
3101
+ *
3102
+ * The possible resolve values are:
3103
+ *
3104
+ * | status | description |
3105
+ * | --------------------- | ------------------------------------------------------------------------------------- |
3106
+ * | `"ignored"` | file ignored by a .gitignore rule |
3107
+ * | `"unmodified"` | file unchanged from HEAD commit |
3108
+ * | `"*modified"` | file has modifications, not yet staged |
3109
+ * | `"*deleted"` | file has been removed, but the removal is not yet staged |
3110
+ * | `"*added"` | file is untracked, not yet staged |
3111
+ * | `"absent"` | file not present in HEAD commit, staging area, or working dir |
3112
+ * | `"modified"` | file has modifications, staged |
3113
+ * | `"deleted"` | file has been removed, staged |
3114
+ * | `"added"` | previously untracked file, staged |
3115
+ * | `"*unmodified"` | working dir and HEAD commit match, but index differs |
3116
+ * | `"*absent"` | file not present in working dir or HEAD commit, but present in the index |
3117
+ * | `"*undeleted"` | file was deleted from the index, but is still in the working dir |
3118
+ * | `"*undeletemodified"` | file was deleted from the index, but is present with modifications in the working dir |
3119
+ *
3120
+ * @param {object} args
3121
+ * @param {FsClient} args.fs - a file system client
3122
+ * @param {string} args.dir - The [working tree](dir-vs-gitdir.md) directory path
3123
+ * @param {string} [args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path
3124
+ * @param {string} args.filepath - The path to the file to query
3125
+ * @param {object} [args.cache] - a [cache](cache.md) object
3126
+ *
3127
+ * @returns {Promise<'ignored'|'unmodified'|'*modified'|'*deleted'|'*added'|'absent'|'modified'|'deleted'|'added'|'*unmodified'|'*absent'|'*undeleted'|'*undeletemodified'>} Resolves successfully with the file's git status
3128
+ *
3129
+ * @example
3130
+ * let status = await git.status({ fs, dir: '/tutorial', filepath: 'README.md' })
3131
+ * console.log(status)
3132
+ *
3133
+ */
3134
+ export function status({ fs: _fs, dir, gitdir, filepath, cache, }: {
3135
+ fs: FsClient;
3136
+ dir: string;
3137
+ gitdir?: string | undefined;
3138
+ filepath: string;
3139
+ cache?: object;
3140
+ }): Promise<"ignored" | "unmodified" | "*modified" | "*deleted" | "*added" | "absent" | "modified" | "deleted" | "added" | "*unmodified" | "*absent" | "*undeleted" | "*undeletemodified">;
3141
+ /**
3142
+ * Efficiently get the status of multiple files at once.
3143
+ *
3144
+ * The returned `StatusMatrix` is admittedly not the easiest format to read.
3145
+ * However it conveys a large amount of information in dense format that should make it easy to create reports about the current state of the repository;
3146
+ * without having to do multiple, time-consuming isomorphic-git calls.
3147
+ * My hope is that the speed and flexibility of the function will make up for the learning curve of interpreting the return value.
3148
+ *
3149
+ * ```js live
3150
+ * // get the status of all the files in 'src'
3151
+ * let status = await git.statusMatrix({
3152
+ * fs,
3153
+ * dir: '/tutorial',
3154
+ * filter: f => f.startsWith('src/')
3155
+ * })
3156
+ * console.log(status)
3157
+ * ```
3158
+ *
3159
+ * ```js live
3160
+ * // get the status of all the JSON and Markdown files
3161
+ * let status = await git.statusMatrix({
3162
+ * fs,
3163
+ * dir: '/tutorial',
3164
+ * filter: f => f.endsWith('.json') || f.endsWith('.md')
3165
+ * })
3166
+ * console.log(status)
3167
+ * ```
3168
+ *
3169
+ * The result is returned as a 2D array.
3170
+ * The outer array represents the files and/or blobs in the repo, in alphabetical order.
3171
+ * The inner arrays describe the status of the file:
3172
+ * the first value is the filepath, and the next three are integers
3173
+ * representing the HEAD status, WORKDIR status, and STAGE status of the entry.
3174
+ *
3175
+ * ```js
3176
+ * // example StatusMatrix
3177
+ * [
3178
+ * ["a.txt", 0, 2, 0], // new, untracked
3179
+ * ["b.txt", 0, 2, 2], // added, staged
3180
+ * ["c.txt", 0, 2, 3], // added, staged, with unstaged changes
3181
+ * ["d.txt", 1, 1, 1], // unmodified
3182
+ * ["e.txt", 1, 2, 1], // modified, unstaged
3183
+ * ["f.txt", 1, 2, 2], // modified, staged
3184
+ * ["g.txt", 1, 2, 3], // modified, staged, with unstaged changes
3185
+ * ["h.txt", 1, 0, 1], // deleted, unstaged
3186
+ * ["i.txt", 1, 0, 0], // deleted, staged
3187
+ * ["j.txt", 1, 2, 0], // deleted, staged, with unstaged-modified changes (new file of the same name)
3188
+ * ["k.txt", 1, 1, 0], // deleted, staged, with unstaged changes (new file of the same name)
3189
+ * ]
3190
+ * ```
3191
+ *
3192
+ * - The HEAD status is either absent (0) or present (1).
3193
+ * - The WORKDIR status is either absent (0), identical to HEAD (1), or different from HEAD (2).
3194
+ * - The STAGE status is either absent (0), identical to HEAD (1), identical to WORKDIR (2), or different from WORKDIR (3).
3195
+ *
3196
+ * ```ts
3197
+ * type Filename = string
3198
+ * type HeadStatus = 0 | 1
3199
+ * type WorkdirStatus = 0 | 1 | 2
3200
+ * type StageStatus = 0 | 1 | 2 | 3
3201
+ *
3202
+ * type StatusRow = [Filename, HeadStatus, WorkdirStatus, StageStatus]
3203
+ *
3204
+ * type StatusMatrix = StatusRow[]
3205
+ * ```
3206
+ *
3207
+ * > Think of the natural progression of file modifications as being from HEAD (previous) -> WORKDIR (current) -> STAGE (next).
3208
+ * > Then HEAD is "version 1", WORKDIR is "version 2", and STAGE is "version 3".
3209
+ * > Then, imagine a "version 0" which is before the file was created.
3210
+ * > Then the status value in each column corresponds to the oldest version of the file it is identical to.
3211
+ * > (For a file to be identical to "version 0" means the file is deleted.)
3212
+ *
3213
+ * Here are some examples of queries you can answer using the result:
3214
+ *
3215
+ * #### Q: What files have been deleted?
3216
+ * ```js
3217
+ * const FILE = 0, WORKDIR = 2
3218
+ *
3219
+ * const filenames = (await statusMatrix({ dir }))
3220
+ * .filter(row => row[WORKDIR] === 0)
3221
+ * .map(row => row[FILE])
3222
+ * ```
3223
+ *
3224
+ * #### Q: What files have unstaged changes?
3225
+ * ```js
3226
+ * const FILE = 0, WORKDIR = 2, STAGE = 3
3227
+ *
3228
+ * const filenames = (await statusMatrix({ dir }))
3229
+ * .filter(row => row[WORKDIR] !== row[STAGE])
3230
+ * .map(row => row[FILE])
3231
+ * ```
3232
+ *
3233
+ * #### Q: What files have been modified since the last commit?
3234
+ * ```js
3235
+ * const FILE = 0, HEAD = 1, WORKDIR = 2
3236
+ *
3237
+ * const filenames = (await statusMatrix({ dir }))
3238
+ * .filter(row => row[HEAD] !== row[WORKDIR])
3239
+ * .map(row => row[FILE])
3240
+ * ```
3241
+ *
3242
+ * #### Q: What files will NOT be changed if I commit right now?
3243
+ * ```js
3244
+ * const FILE = 0, HEAD = 1, STAGE = 3
3245
+ *
3246
+ * const filenames = (await statusMatrix({ dir }))
3247
+ * .filter(row => row[HEAD] === row[STAGE])
3248
+ * .map(row => row[FILE])
3249
+ * ```
3250
+ *
3251
+ * For reference, here are all possible combinations:
3252
+ *
3253
+ * | HEAD | WORKDIR | STAGE | `git status --short` equivalent |
3254
+ * | ---- | ------- | ----- | ------------------------------- |
3255
+ * | 0 | 0 | 0 | `` |
3256
+ * | 0 | 0 | 3 | `AD` |
3257
+ * | 0 | 2 | 0 | `??` |
3258
+ * | 0 | 2 | 2 | `A ` |
3259
+ * | 0 | 2 | 3 | `AM` |
3260
+ * | 1 | 0 | 0 | `D ` |
3261
+ * | 1 | 0 | 1 | ` D` |
3262
+ * | 1 | 0 | 3 | `MD` |
3263
+ * | 1 | 1 | 0 | `D ` + `??` |
3264
+ * | 1 | 1 | 1 | `` |
3265
+ * | 1 | 1 | 3 | `MM` |
3266
+ * | 1 | 2 | 0 | `D ` + `??` |
3267
+ * | 1 | 2 | 1 | ` M` |
3268
+ * | 1 | 2 | 2 | `M ` |
3269
+ * | 1 | 2 | 3 | `MM` |
3270
+ *
3271
+ * @param {object} args
3272
+ * @param {FsClient} args.fs - a file system client
3273
+ * @param {string} args.dir - The [working tree](dir-vs-gitdir.md) directory path
3274
+ * @param {string} [args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path
3275
+ * @param {string} [args.ref = 'HEAD'] - Optionally specify a different commit to compare against the workdir and stage instead of the HEAD
3276
+ * @param {string[]} [args.filepaths = ['.']] - Limit the query to the given files and directories
3277
+ * @param {function(string): boolean} [args.filter] - Filter the results to only those whose filepath matches a function.
3278
+ * @param {object} [args.cache] - a [cache](cache.md) object
3279
+ * @param {boolean} [args.ignored = false] - include ignored files in the result
3280
+ *
3281
+ * @returns {Promise<Array<StatusRow>>} Resolves with a status matrix, described below.
3282
+ * @see StatusRow
3283
+ */
3284
+ export function statusMatrix({ fs: _fs, dir, gitdir, ref, filepaths, filter, cache, ignored: shouldIgnore, }: {
3285
+ fs: FsClient;
3286
+ dir: string;
3287
+ gitdir?: string | undefined;
3288
+ ref?: string | undefined;
3289
+ filepaths?: string[] | undefined;
3290
+ filter?: ((arg0: string) => boolean) | undefined;
3291
+ cache?: object;
3292
+ ignored?: boolean | undefined;
3293
+ }): Promise<Array<StatusRow>>;
3294
+ /**
3295
+ * Create a lightweight tag
3296
+ *
3297
+ * @param {object} args
3298
+ * @param {FsClient} args.fs - a file system client
3299
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
3300
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
3301
+ * @param {string} args.ref - What to name the tag
3302
+ * @param {string} [args.object = 'HEAD'] - What oid the tag refers to. (Will resolve to oid if value is a ref.) By default, the commit object which is referred by the current `HEAD` is used.
3303
+ * @param {boolean} [args.force = false] - Instead of throwing an error if a tag named `ref` already exists, overwrite the existing tag.
3304
+ *
3305
+ * @returns {Promise<void>} Resolves successfully when filesystem operations are complete
3306
+ *
3307
+ * @example
3308
+ * await git.tag({ fs, dir: '/tutorial', ref: 'test-tag' })
3309
+ * console.log('done')
3310
+ *
3311
+ */
3312
+ export function tag({ fs: _fs, dir, gitdir, ref, object, force, }: {
3313
+ fs: FsClient;
3314
+ dir?: string | undefined;
3315
+ gitdir?: string | undefined;
3316
+ ref: string;
3317
+ object?: string | undefined;
3318
+ force?: boolean | undefined;
3319
+ }): Promise<void>;
3320
+ /**
3321
+ * Register file contents in the working tree or object database to the git index (aka staging area).
3322
+ *
3323
+ * @param {object} args
3324
+ * @param {FsClient} args.fs - a file system client
3325
+ * @param {string} args.dir - The [working tree](dir-vs-gitdir.md) directory path
3326
+ * @param {string} [args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path
3327
+ * @param {string} args.filepath - File to act upon.
3328
+ * @param {string} [args.oid] - OID of the object in the object database to add to the index with the specified filepath.
3329
+ * @param {number} [args.mode = 100644] - The file mode to add the file to the index.
3330
+ * @param {boolean} [args.add] - Adds the specified file to the index if it does not yet exist in the index.
3331
+ * @param {boolean} [args.remove] - Remove the specified file from the index if it does not exist in the workspace anymore.
3332
+ * @param {boolean} [args.force] - Remove the specified file from the index, even if it still exists in the workspace.
3333
+ * @param {object} [args.cache] - a [cache](cache.md) object
3334
+ *
3335
+ * @returns {Promise<string | void>} Resolves successfully with the SHA-1 object id of the object written or updated in the index, or nothing if the file was removed.
3336
+ *
3337
+ * @example
3338
+ * await git.updateIndex({
3339
+ * fs,
3340
+ * dir: '/tutorial',
3341
+ * filepath: 'readme.md'
3342
+ * })
3343
+ *
3344
+ * @example
3345
+ * // Manually create a blob in the object database.
3346
+ * let oid = await git.writeBlob({
3347
+ * fs,
3348
+ * dir: '/tutorial',
3349
+ * blob: new Uint8Array([])
3350
+ * })
3351
+ *
3352
+ * // Write the object in the object database to the index.
3353
+ * await git.updateIndex({
3354
+ * fs,
3355
+ * dir: '/tutorial',
3356
+ * add: true,
3357
+ * filepath: 'readme.md',
3358
+ * oid
3359
+ * })
3360
+ */
3361
+ declare function updateIndex$1({ fs: _fs, dir, gitdir, cache, filepath, oid, mode, add, remove, force, }: {
3362
+ fs: FsClient;
3363
+ dir: string;
3364
+ gitdir?: string | undefined;
3365
+ filepath: string;
3366
+ oid?: string | undefined;
3367
+ mode?: number | undefined;
3368
+ add?: boolean | undefined;
3369
+ remove?: boolean | undefined;
3370
+ force?: boolean | undefined;
3371
+ cache?: object;
3372
+ }): Promise<string | void>;
3373
+ /**
3374
+ * Return the version number of isomorphic-git
3375
+ *
3376
+ * I don't know why you might need this. I added it just so I could check that I was getting
3377
+ * the correct version of the library and not a cached version.
3378
+ *
3379
+ * @returns {string} the version string taken from package.json at publication time
3380
+ *
3381
+ * @example
3382
+ * console.log(git.version())
3383
+ *
3384
+ */
3385
+ export function version(): string;
3386
+ /**
3387
+ * @callback WalkerMap
3388
+ * @param {string} filename
3389
+ * @param {Array<WalkerEntry | null>} entries
3390
+ * @returns {Promise<any>}
3391
+ */
3392
+ /**
3393
+ * @callback WalkerReduce
3394
+ * @param {any} parent
3395
+ * @param {any[]} children
3396
+ * @returns {Promise<any>}
3397
+ */
3398
+ /**
3399
+ * @callback WalkerIterateCallback
3400
+ * @param {WalkerEntry[]} entries
3401
+ * @returns {Promise<any[]>}
3402
+ */
3403
+ /**
3404
+ * @callback WalkerIterate
3405
+ * @param {WalkerIterateCallback} walk
3406
+ * @param {IterableIterator<WalkerEntry[]>} children
3407
+ * @returns {Promise<any[]>}
3408
+ */
3409
+ /**
3410
+ * A powerful recursive tree-walking utility.
3411
+ *
3412
+ * The `walk` API simplifies gathering detailed information about a tree or comparing all the filepaths in two or more trees.
3413
+ * Trees can be git commits, the working directory, or the or git index (staging area).
3414
+ * As long as a file or directory is present in at least one of the trees, it will be traversed.
3415
+ * Entries are traversed in alphabetical order.
3416
+ *
3417
+ * The arguments to `walk` are the `trees` you want to traverse, and 3 optional transform functions:
3418
+ * `map`, `reduce`, and `iterate`.
3419
+ *
3420
+ * ## `TREE`, `WORKDIR`, and `STAGE`
3421
+ *
3422
+ * Tree walkers are represented by three separate functions that can be imported:
3423
+ *
3424
+ * ```js
3425
+ * import { TREE, WORKDIR, STAGE } from 'isomorphic-git'
3426
+ * ```
3427
+ *
3428
+ * These functions return opaque handles called `Walker`s.
3429
+ * The only thing that `Walker` objects are good for is passing into `walk`.
3430
+ * Here are the three `Walker`s passed into `walk` by the `statusMatrix` command for example:
3431
+ *
3432
+ * ```js
3433
+ * let ref = 'HEAD'
3434
+ *
3435
+ * let trees = [TREE({ ref }), WORKDIR(), STAGE()]
3436
+ * ```
3437
+ *
3438
+ * For the arguments, see the doc pages for [TREE](./TREE.md), [WORKDIR](./WORKDIR.md), and [STAGE](./STAGE.md).
3439
+ *
3440
+ * `map`, `reduce`, and `iterate` allow you control the recursive walk by pruning and transforming `WalkerEntry`s into the desired result.
3441
+ *
3442
+ * ## WalkerEntry
3443
+ *
3444
+ * {@link WalkerEntry typedef}
3445
+ *
3446
+ * `map` receives an array of `WalkerEntry[]` as its main argument, one `WalkerEntry` for each `Walker` in the `trees` argument.
3447
+ * The methods are memoized per `WalkerEntry` so calling them multiple times in a `map` function does not adversely impact performance.
3448
+ * By only computing these values if needed, you build can build lean, mean, efficient walking machines.
3449
+ *
3450
+ * ### WalkerEntry#type()
3451
+ *
3452
+ * Returns the kind as a string. This is normally either `tree` or `blob`.
3453
+ *
3454
+ * `TREE`, `STAGE`, and `WORKDIR` walkers all return a string.
3455
+ *
3456
+ * Possible values:
3457
+ *
3458
+ * - `'tree'` directory
3459
+ * - `'blob'` file
3460
+ * - `'special'` used by `WORKDIR` to represent irregular files like sockets and FIFOs
3461
+ * - `'commit'` used by `TREE` to represent submodules
3462
+ *
3463
+ * ```js
3464
+ * await entry.type()
3465
+ * ```
3466
+ *
3467
+ * ### WalkerEntry#mode()
3468
+ *
3469
+ * Returns the file mode as a number. Use this to distinguish between regular files, symlinks, and executable files.
3470
+ *
3471
+ * `TREE`, `STAGE`, and `WORKDIR` walkers all return a number for all `type`s of entries.
3472
+ *
3473
+ * It has been normalized to one of the 4 values that are allowed in git commits:
3474
+ *
3475
+ * - `0o40000` directory
3476
+ * - `0o100644` file
3477
+ * - `0o100755` file (executable)
3478
+ * - `0o120000` symlink
3479
+ *
3480
+ * Tip: to make modes more readable, you can print them to octal using `.toString(8)`.
3481
+ *
3482
+ * ```js
3483
+ * await entry.mode()
3484
+ * ```
3485
+ *
3486
+ * ### WalkerEntry#oid()
3487
+ *
3488
+ * Returns the SHA-1 object id for blobs and trees.
3489
+ *
3490
+ * `TREE` walkers return a string for `blob` and `tree` entries.
3491
+ *
3492
+ * `STAGE` and `WORKDIR` walkers return a string for `blob` entries and `undefined` for `tree` entries.
3493
+ *
3494
+ * ```js
3495
+ * await entry.oid()
3496
+ * ```
3497
+ *
3498
+ * ### WalkerEntry#content()
3499
+ *
3500
+ * Returns the file contents as a Buffer.
3501
+ *
3502
+ * `TREE` and `WORKDIR` walkers return a Buffer for `blob` entries and `undefined` for `tree` entries.
3503
+ *
3504
+ * `STAGE` walkers always return `undefined` since the file contents are never stored in the stage.
3505
+ *
3506
+ * ```js
3507
+ * await entry.content()
3508
+ * ```
3509
+ *
3510
+ * ### WalkerEntry#stat()
3511
+ *
3512
+ * Returns a normalized subset of filesystem Stat data.
3513
+ *
3514
+ * `WORKDIR` walkers return a `Stat` for `blob` and `tree` entries.
3515
+ *
3516
+ * `STAGE` walkers return a `Stat` for `blob` entries and `undefined` for `tree` entries.
3517
+ *
3518
+ * `TREE` walkers return `undefined` for all entry types.
3519
+ *
3520
+ * ```js
3521
+ * await entry.stat()
3522
+ * ```
3523
+ *
3524
+ * {@link Stat typedef}
3525
+ *
3526
+ * ## map(string, Array<WalkerEntry|null>) => Promise<any>
3527
+ *
3528
+ * {@link WalkerMap typedef}
3529
+ *
3530
+ * This is the function that is called once per entry BEFORE visiting the children of that node.
3531
+ *
3532
+ * If you return `null` for a `tree` entry, then none of the children of that `tree` entry will be walked.
3533
+ *
3534
+ * This is a good place for query logic, such as examining the contents of a file.
3535
+ * Ultimately, compare all the entries and return any values you are interested in.
3536
+ * If you do not return a value (or return undefined) that entry will be filtered from the results.
3537
+ *
3538
+ * Example 1: Find all the files containing the word 'foo'.
3539
+ * ```js
3540
+ * async function map(filepath, [head, workdir]) {
3541
+ * let content = (await workdir.content()).toString('utf8')
3542
+ * if (content.contains('foo')) {
3543
+ * return {
3544
+ * filepath,
3545
+ * content
3546
+ * }
3547
+ * }
3548
+ * }
3549
+ * ```
3550
+ *
3551
+ * Example 2: Return the difference between the working directory and the HEAD commit
3552
+ * ```js
3553
+ * const map = async (filepath, [head, workdir]) => {
3554
+ * return {
3555
+ * filepath,
3556
+ * oid: await head?.oid(),
3557
+ * diff: diff(
3558
+ * (await head?.content())?.toString('utf8') || '',
3559
+ * (await workdir?.content())?.toString('utf8') || ''
3560
+ * )
3561
+ * }
3562
+ * }
3563
+ * ```
3564
+ *
3565
+ * Example 3:
3566
+ * ```js
3567
+ * let path = require('path')
3568
+ * // Only examine files in the directory `cwd`
3569
+ * let cwd = 'src/app'
3570
+ * async function map (filepath, [head, workdir, stage]) {
3571
+ * if (
3572
+ * // don't skip the root directory
3573
+ * head.fullpath !== '.' &&
3574
+ * // return true for 'src' and 'src/app'
3575
+ * !cwd.startsWith(filepath) &&
3576
+ * // return true for 'src/app/*'
3577
+ * path.dirname(filepath) !== cwd
3578
+ * ) {
3579
+ * return null
3580
+ * } else {
3581
+ * return filepath
3582
+ * }
3583
+ * }
3584
+ * ```
3585
+ *
3586
+ * ## reduce(parent, children)
3587
+ *
3588
+ * {@link WalkerReduce typedef}
3589
+ *
3590
+ * This is the function that is called once per entry AFTER visiting the children of that node.
3591
+ *
3592
+ * Default: `async (parent, children) => parent === undefined ? children.flat() : [parent, children].flat()`
3593
+ *
3594
+ * The default implementation of this function returns all directories and children in a giant flat array.
3595
+ * You can define a different accumulation method though.
3596
+ *
3597
+ * Example: Return a hierarchical structure
3598
+ * ```js
3599
+ * async function reduce (parent, children) {
3600
+ * return Object.assign(parent, { children })
3601
+ * }
3602
+ * ```
3603
+ *
3604
+ * ## iterate(walk, children)
3605
+ *
3606
+ * {@link WalkerIterate typedef}
3607
+ *
3608
+ * {@link WalkerIterateCallback typedef}
3609
+ *
3610
+ * Default: `(walk, children) => Promise.all([...children].map(walk))`
3611
+ *
3612
+ * The default implementation recurses all children concurrently using Promise.all.
3613
+ * However you could use a custom function to traverse children serially or use a global queue to throttle recursion.
3614
+ *
3615
+ * @param {object} args
3616
+ * @param {FsClient} args.fs - a file system client
3617
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
3618
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
3619
+ * @param {Walker[]} args.trees - The trees you want to traverse
3620
+ * @param {WalkerMap} [args.map] - Transform `WalkerEntry`s into a result form
3621
+ * @param {WalkerReduce} [args.reduce] - Control how mapped entries are combined with their parent result
3622
+ * @param {WalkerIterate} [args.iterate] - Fine-tune how entries within a tree are iterated over
3623
+ * @param {object} [args.cache] - a [cache](cache.md) object
3624
+ *
3625
+ * @returns {Promise<any>} The finished tree-walking result
3626
+ */
3627
+ export function walk({ fs, dir, gitdir, trees, map, reduce, iterate, cache, }: {
3628
+ fs: FsClient;
3629
+ dir?: string | undefined;
3630
+ gitdir?: string | undefined;
3631
+ trees: Walker[];
3632
+ map?: WalkerMap | undefined;
3633
+ reduce?: WalkerReduce | undefined;
3634
+ iterate?: WalkerIterate | undefined;
3635
+ cache?: object;
3636
+ }): Promise<any>;
3637
+ /**
3638
+ * Write a blob object directly
3639
+ *
3640
+ * @param {object} args
3641
+ * @param {FsClient} args.fs - a file system client
3642
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
3643
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
3644
+ * @param {Uint8Array} args.blob - The blob object to write
3645
+ *
3646
+ * @returns {Promise<string>} Resolves successfully with the SHA-1 object id of the newly written object
3647
+ *
3648
+ * @example
3649
+ * // Manually create a blob.
3650
+ * let oid = await git.writeBlob({
3651
+ * fs,
3652
+ * dir: '/tutorial',
3653
+ * blob: new Uint8Array([])
3654
+ * })
3655
+ *
3656
+ * console.log('oid', oid) // should be 'e69de29bb2d1d6434b8b29ae775ad8c2e48c5391'
3657
+ *
3658
+ */
3659
+ export function writeBlob({ fs, dir, gitdir, blob }: {
3660
+ fs: FsClient;
3661
+ dir?: string | undefined;
3662
+ gitdir?: string | undefined;
3663
+ blob: Uint8Array;
3664
+ }): Promise<string>;
3665
+ /**
3666
+ * Write a commit object directly
3667
+ *
3668
+ * @param {object} args
3669
+ * @param {FsClient} args.fs - a file system client
3670
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
3671
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
3672
+ * @param {CommitObject} args.commit - The object to write
3673
+ *
3674
+ * @returns {Promise<string>} Resolves successfully with the SHA-1 object id of the newly written object
3675
+ * @see CommitObject
3676
+ *
3677
+ */
3678
+ export function writeCommit({ fs, dir, gitdir, commit, }: {
3679
+ fs: FsClient;
3680
+ dir?: string | undefined;
3681
+ gitdir?: string | undefined;
3682
+ commit: CommitObject;
3683
+ }): Promise<string>;
3684
+ /**
3685
+ * Write a git object directly
3686
+ *
3687
+ * `format` can have the following values:
3688
+ *
3689
+ * | param | description |
3690
+ * | ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
3691
+ * | 'deflated' | Treat `object` as the raw deflate-compressed buffer for an object, meaning can be written to `.git/objects/**` as-is. |
3692
+ * | 'wrapped' | Treat `object` as the inflated object buffer wrapped in the git object header. This is the raw buffer used when calculating the SHA-1 object id of a git object. |
3693
+ * | 'content' | Treat `object` as the object buffer without the git header. |
3694
+ * | 'parsed' | Treat `object` as a parsed representation of the object. |
3695
+ *
3696
+ * If `format` is `'parsed'`, then `object` must match one of the schemas for `CommitObject`, `TreeObject`, `TagObject`, or a `string` (for blobs).
3697
+ *
3698
+ * {@link CommitObject typedef}
3699
+ *
3700
+ * {@link TreeObject typedef}
3701
+ *
3702
+ * {@link TagObject typedef}
3703
+ *
3704
+ * If `format` is `'content'`, `'wrapped'`, or `'deflated'`, `object` should be a `Uint8Array`.
3705
+ *
3706
+ * @deprecated
3707
+ * > This command is overly complicated.
3708
+ * >
3709
+ * > If you know the type of object you are writing, use [`writeBlob`](./writeBlob.md), [`writeCommit`](./writeCommit.md), [`writeTag`](./writeTag.md), or [`writeTree`](./writeTree.md).
3710
+ *
3711
+ * @param {object} args
3712
+ * @param {FsClient} args.fs - a file system client
3713
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
3714
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
3715
+ * @param {string | Uint8Array | CommitObject | TreeObject | TagObject} args.object - The object to write.
3716
+ * @param {'blob'|'tree'|'commit'|'tag'} [args.type] - The kind of object to write.
3717
+ * @param {'deflated' | 'wrapped' | 'content' | 'parsed'} [args.format = 'parsed'] - What format the object is in. The possible choices are listed below.
3718
+ * @param {string} [args.oid] - If `format` is `'deflated'` then this param is required. Otherwise it is calculated.
3719
+ * @param {string} [args.encoding] - If `type` is `'blob'` then `object` will be converted to a Uint8Array using `encoding`.
3720
+ *
3721
+ * @returns {Promise<string>} Resolves successfully with the SHA-1 object id of the newly written object.
3722
+ *
3723
+ * @example
3724
+ * // Manually create an annotated tag.
3725
+ * let sha = await git.resolveRef({ fs, dir: '/tutorial', ref: 'HEAD' })
3726
+ * console.log('commit', sha)
3727
+ *
3728
+ * let oid = await git.writeObject({
3729
+ * fs,
3730
+ * dir: '/tutorial',
3731
+ * type: 'tag',
3732
+ * object: {
3733
+ * object: sha,
3734
+ * type: 'commit',
3735
+ * tag: 'my-tag',
3736
+ * tagger: {
3737
+ * name: 'your name',
3738
+ * email: 'email@example.com',
3739
+ * timestamp: Math.floor(Date.now()/1000),
3740
+ * timezoneOffset: new Date().getTimezoneOffset()
3741
+ * },
3742
+ * message: 'Optional message'
3743
+ * }
3744
+ * })
3745
+ *
3746
+ * console.log('tag', oid)
3747
+ *
3748
+ */
3749
+ export function writeObject({ fs: _fs, dir, gitdir, type, object, format, oid, encoding, }: {
3750
+ fs: FsClient;
3751
+ dir?: string | undefined;
3752
+ gitdir?: string | undefined;
3753
+ object: string | Uint8Array | CommitObject | TreeObject | TagObject;
3754
+ type?: "commit" | "blob" | "tree" | "tag" | undefined;
3755
+ format?: "deflated" | "content" | "wrapped" | "parsed" | undefined;
3756
+ oid?: string | undefined;
3757
+ encoding?: string | undefined;
3758
+ }): Promise<string>;
3759
+ /**
3760
+ * Write a ref which refers to the specified SHA-1 object id, or a symbolic ref which refers to the specified ref.
3761
+ *
3762
+ * @param {object} args
3763
+ * @param {FsClient} args.fs - a file system client
3764
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
3765
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
3766
+ * @param {string} args.ref - The name of the ref to write
3767
+ * @param {string} args.value - When `symbolic` is false, a ref or an SHA-1 object id. When true, a ref starting with `refs/`.
3768
+ * @param {boolean} [args.force = false] - Instead of throwing an error if a ref named `ref` already exists, overwrite the existing ref.
3769
+ * @param {boolean} [args.symbolic = false] - Whether the ref is symbolic or not.
3770
+ *
3771
+ * @returns {Promise<void>} Resolves successfully when filesystem operations are complete
3772
+ *
3773
+ * @example
3774
+ * await git.writeRef({
3775
+ * fs,
3776
+ * dir: '/tutorial',
3777
+ * ref: 'refs/heads/another-branch',
3778
+ * value: 'HEAD'
3779
+ * })
3780
+ * await git.writeRef({
3781
+ * fs,
3782
+ * dir: '/tutorial',
3783
+ * ref: 'HEAD',
3784
+ * value: 'refs/heads/another-branch',
3785
+ * force: true,
3786
+ * symbolic: true
3787
+ * })
3788
+ * console.log('done')
3789
+ *
3790
+ */
3791
+ export function writeRef({ fs: _fs, dir, gitdir, ref, value, force, symbolic, }: {
3792
+ fs: FsClient;
3793
+ dir?: string | undefined;
3794
+ gitdir?: string | undefined;
3795
+ ref: string;
3796
+ value: string;
3797
+ force?: boolean | undefined;
3798
+ symbolic?: boolean | undefined;
3799
+ }): Promise<void>;
3800
+ /**
3801
+ * Write an annotated tag object directly
3802
+ *
3803
+ * @param {object} args
3804
+ * @param {FsClient} args.fs - a file system client
3805
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
3806
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
3807
+ * @param {TagObject} args.tag - The object to write
3808
+ *
3809
+ * @returns {Promise<string>} Resolves successfully with the SHA-1 object id of the newly written object
3810
+ * @see TagObject
3811
+ *
3812
+ * @example
3813
+ * // Manually create an annotated tag.
3814
+ * let sha = await git.resolveRef({ fs, dir: '/tutorial', ref: 'HEAD' })
3815
+ * console.log('commit', sha)
3816
+ *
3817
+ * let oid = await git.writeTag({
3818
+ * fs,
3819
+ * dir: '/tutorial',
3820
+ * tag: {
3821
+ * object: sha,
3822
+ * type: 'commit',
3823
+ * tag: 'my-tag',
3824
+ * tagger: {
3825
+ * name: 'your name',
3826
+ * email: 'email@example.com',
3827
+ * timestamp: Math.floor(Date.now()/1000),
3828
+ * timezoneOffset: new Date().getTimezoneOffset()
3829
+ * },
3830
+ * message: 'Optional message'
3831
+ * }
3832
+ * })
3833
+ *
3834
+ * console.log('tag', oid)
3835
+ *
3836
+ */
3837
+ export function writeTag({ fs, dir, gitdir, tag }: {
3838
+ fs: FsClient;
3839
+ dir?: string | undefined;
3840
+ gitdir?: string | undefined;
3841
+ tag: TagObject;
3842
+ }): Promise<string>;
3843
+ /**
3844
+ * Write a tree object directly
3845
+ *
3846
+ * @param {object} args
3847
+ * @param {FsClient} args.fs - a file system client
3848
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
3849
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
3850
+ * @param {TreeObject} args.tree - The object to write
3851
+ *
3852
+ * @returns {Promise<string>} Resolves successfully with the SHA-1 object id of the newly written object.
3853
+ * @see TreeObject
3854
+ * @see TreeEntry
3855
+ *
3856
+ */
3857
+ export function writeTree({ fs, dir, gitdir, tree }: {
3858
+ fs: FsClient;
3859
+ dir?: string | undefined;
3860
+ gitdir?: string | undefined;
3861
+ tree: TreeObject;
3862
+ }): Promise<string>;
3863
+ declare class AlreadyExistsError extends BaseError {
3864
+ /**
3865
+ * @param {'note'|'remote'|'tag'|'branch'} noun
3866
+ * @param {string} where
3867
+ * @param {boolean} canForce
3868
+ */
3869
+ constructor(noun: "note" | "remote" | "tag" | "branch", where: string, canForce?: boolean);
3870
+ code: "AlreadyExistsError";
3871
+ name: "AlreadyExistsError";
3872
+ data: {
3873
+ noun: "tag" | "branch" | "remote" | "note";
3874
+ where: string;
3875
+ canForce: boolean;
3876
+ };
3877
+ }
3878
+ declare namespace AlreadyExistsError {
3879
+ let code: "AlreadyExistsError";
3880
+ }
3881
+ declare class AmbiguousError extends BaseError {
3882
+ /**
3883
+ * @param {'oids'|'refs'} nouns
3884
+ * @param {string} short
3885
+ * @param {string[]} matches
3886
+ */
3887
+ constructor(nouns: "oids" | "refs", short: string, matches: string[]);
3888
+ code: "AmbiguousError";
3889
+ name: "AmbiguousError";
3890
+ data: {
3891
+ nouns: "refs" | "oids";
3892
+ short: string;
3893
+ matches: string[];
3894
+ };
3895
+ }
3896
+ declare namespace AmbiguousError {
3897
+ let code_1: "AmbiguousError";
3898
+ export { code_1 as code };
3899
+ }
3900
+ declare class CheckoutConflictError extends BaseError {
3901
+ /**
3902
+ * @param {string[]} filepaths
3903
+ */
3904
+ constructor(filepaths: string[]);
3905
+ code: "CheckoutConflictError";
3906
+ name: "CheckoutConflictError";
3907
+ data: {
3908
+ filepaths: string[];
3909
+ };
3910
+ }
3911
+ declare namespace CheckoutConflictError {
3912
+ let code_2: "CheckoutConflictError";
3913
+ export { code_2 as code };
3914
+ }
3915
+ declare class CommitNotFetchedError extends BaseError {
3916
+ /**
3917
+ * @param {string} ref
3918
+ * @param {string} oid
3919
+ */
3920
+ constructor(ref: string, oid: string);
3921
+ code: "CommitNotFetchedError";
3922
+ name: "CommitNotFetchedError";
3923
+ data: {
3924
+ ref: string;
3925
+ oid: string;
3926
+ };
3927
+ }
3928
+ declare namespace CommitNotFetchedError {
3929
+ let code_3: "CommitNotFetchedError";
3930
+ export { code_3 as code };
3931
+ }
3932
+ declare class EmptyServerResponseError extends BaseError {
3933
+ constructor();
3934
+ code: "EmptyServerResponseError";
3935
+ name: "EmptyServerResponseError";
3936
+ data: {};
3937
+ }
3938
+ declare namespace EmptyServerResponseError {
3939
+ let code_4: "EmptyServerResponseError";
3940
+ export { code_4 as code };
3941
+ }
3942
+ declare class FastForwardError extends BaseError {
3943
+ constructor();
3944
+ code: "FastForwardError";
3945
+ name: "FastForwardError";
3946
+ data: {};
3947
+ }
3948
+ declare namespace FastForwardError {
3949
+ let code_5: "FastForwardError";
3950
+ export { code_5 as code };
3951
+ }
3952
+ declare class GitPushError extends BaseError {
3953
+ /**
3954
+ * @param {string} prettyDetails
3955
+ * @param {PushResult} result
3956
+ */
3957
+ constructor(prettyDetails: string, result: PushResult);
3958
+ code: "GitPushError";
3959
+ name: "GitPushError";
3960
+ data: {
3961
+ prettyDetails: string;
3962
+ result: PushResult;
3963
+ };
3964
+ }
3965
+ declare namespace GitPushError {
3966
+ let code_6: "GitPushError";
3967
+ export { code_6 as code };
3968
+ }
3969
+ declare class HttpError extends BaseError {
3970
+ /**
3971
+ * @param {number} statusCode
3972
+ * @param {string} statusMessage
3973
+ * @param {string} response
3974
+ */
3975
+ constructor(statusCode: number, statusMessage: string, response: string);
3976
+ code: "HttpError";
3977
+ name: "HttpError";
3978
+ data: {
3979
+ statusCode: number;
3980
+ statusMessage: string;
3981
+ response: string;
3982
+ };
3983
+ }
3984
+ declare namespace HttpError {
3985
+ let code_7: "HttpError";
3986
+ export { code_7 as code };
3987
+ }
3988
+ declare class InternalError extends BaseError {
3989
+ /**
3990
+ * @param {string} message
3991
+ */
3992
+ constructor(message: string);
3993
+ code: "InternalError";
3994
+ name: "InternalError";
3995
+ data: {
3996
+ message: string;
3997
+ };
3998
+ }
3999
+ declare namespace InternalError {
4000
+ let code_8: "InternalError";
4001
+ export { code_8 as code };
4002
+ }
4003
+ declare class InvalidFilepathError extends BaseError {
4004
+ /**
4005
+ * @param {'leading-slash'|'trailing-slash'|'directory'} [reason]
4006
+ */
4007
+ constructor(reason?: "leading-slash" | "trailing-slash" | "directory");
4008
+ code: "InvalidFilepathError";
4009
+ name: "InvalidFilepathError";
4010
+ data: {
4011
+ reason: "leading-slash" | "trailing-slash" | "directory" | undefined;
4012
+ };
4013
+ }
4014
+ declare namespace InvalidFilepathError {
4015
+ let code_9: "InvalidFilepathError";
4016
+ export { code_9 as code };
4017
+ }
4018
+ declare class InvalidOidError extends BaseError {
4019
+ /**
4020
+ * @param {string} value
4021
+ */
4022
+ constructor(value: string);
4023
+ code: "InvalidOidError";
4024
+ name: "InvalidOidError";
4025
+ data: {
4026
+ value: string;
4027
+ };
4028
+ }
4029
+ declare namespace InvalidOidError {
4030
+ let code_10: "InvalidOidError";
4031
+ export { code_10 as code };
4032
+ }
4033
+ declare class InvalidRefNameError extends BaseError {
4034
+ /**
4035
+ * @param {string} ref
4036
+ * @param {string} suggestion
4037
+ * @param {boolean} canForce
4038
+ */
4039
+ constructor(ref: string, suggestion: string);
4040
+ code: "InvalidRefNameError";
4041
+ name: "InvalidRefNameError";
4042
+ data: {
4043
+ ref: string;
4044
+ suggestion: string;
4045
+ };
4046
+ }
4047
+ declare namespace InvalidRefNameError {
4048
+ let code_11: "InvalidRefNameError";
4049
+ export { code_11 as code };
4050
+ }
4051
+ declare class MaxDepthError extends BaseError {
4052
+ /**
4053
+ * @param {number} depth
4054
+ */
4055
+ constructor(depth: number);
4056
+ code: "MaxDepthError";
4057
+ name: "MaxDepthError";
4058
+ data: {
4059
+ depth: number;
4060
+ };
4061
+ }
4062
+ declare namespace MaxDepthError {
4063
+ let code_12: "MaxDepthError";
4064
+ export { code_12 as code };
4065
+ }
4066
+ declare class MergeNotSupportedError extends BaseError {
4067
+ constructor();
4068
+ code: "MergeNotSupportedError";
4069
+ name: "MergeNotSupportedError";
4070
+ data: {};
4071
+ }
4072
+ declare namespace MergeNotSupportedError {
4073
+ let code_13: "MergeNotSupportedError";
4074
+ export { code_13 as code };
4075
+ }
4076
+ declare class MergeConflictError extends BaseError {
4077
+ /**
4078
+ * @param {Array<string>} filepaths
4079
+ * @param {Array<string>} bothModified
4080
+ * @param {Array<string>} deleteByUs
4081
+ * @param {Array<string>} deleteByTheirs
4082
+ */
4083
+ constructor(filepaths: Array<string>, bothModified: Array<string>, deleteByUs: Array<string>, deleteByTheirs: Array<string>);
4084
+ code: "MergeConflictError";
4085
+ name: "MergeConflictError";
4086
+ data: {
4087
+ filepaths: string[];
4088
+ bothModified: string[];
4089
+ deleteByUs: string[];
4090
+ deleteByTheirs: string[];
4091
+ };
4092
+ }
4093
+ declare namespace MergeConflictError {
4094
+ let code_14: "MergeConflictError";
4095
+ export { code_14 as code };
4096
+ }
4097
+ declare class MissingNameError extends BaseError {
4098
+ /**
4099
+ * @param {'author'|'committer'|'tagger'} role
4100
+ */
4101
+ constructor(role: "author" | "committer" | "tagger");
4102
+ code: "MissingNameError";
4103
+ name: "MissingNameError";
4104
+ data: {
4105
+ role: "author" | "committer" | "tagger";
4106
+ };
4107
+ }
4108
+ declare namespace MissingNameError {
4109
+ let code_15: "MissingNameError";
4110
+ export { code_15 as code };
4111
+ }
4112
+ declare class MissingParameterError extends BaseError {
4113
+ /**
4114
+ * @param {string} parameter
4115
+ */
4116
+ constructor(parameter: string);
4117
+ code: "MissingParameterError";
4118
+ name: "MissingParameterError";
4119
+ data: {
4120
+ parameter: string;
4121
+ };
4122
+ }
4123
+ declare namespace MissingParameterError {
4124
+ let code_16: "MissingParameterError";
4125
+ export { code_16 as code };
4126
+ }
4127
+ declare class MultipleGitError extends BaseError {
4128
+ /**
4129
+ * @param {Error[]} errors
4130
+ * @param {string} message
4131
+ */
4132
+ constructor(errors: Error[]);
4133
+ code: "MultipleGitError";
4134
+ name: "MultipleGitError";
4135
+ data: {
4136
+ errors: Error[];
4137
+ };
4138
+ errors: Error[];
4139
+ }
4140
+ declare namespace MultipleGitError {
4141
+ let code_17: "MultipleGitError";
4142
+ export { code_17 as code };
4143
+ }
4144
+ declare class NoRefspecError extends BaseError {
4145
+ /**
4146
+ * @param {string} remote
4147
+ */
4148
+ constructor(remote: string);
4149
+ code: "NoRefspecError";
4150
+ name: "NoRefspecError";
4151
+ data: {
4152
+ remote: string;
4153
+ };
4154
+ }
4155
+ declare namespace NoRefspecError {
4156
+ let code_18: "NoRefspecError";
4157
+ export { code_18 as code };
4158
+ }
4159
+ declare class NotFoundError extends BaseError {
4160
+ /**
4161
+ * @param {string} what
4162
+ */
4163
+ constructor(what: string);
4164
+ code: "NotFoundError";
4165
+ name: "NotFoundError";
4166
+ data: {
4167
+ what: string;
4168
+ };
4169
+ }
4170
+ declare namespace NotFoundError {
4171
+ let code_19: "NotFoundError";
4172
+ export { code_19 as code };
4173
+ }
4174
+ declare class ObjectTypeError extends BaseError {
4175
+ /**
4176
+ * @param {string} oid
4177
+ * @param {'blob'|'commit'|'tag'|'tree'} actual
4178
+ * @param {'blob'|'commit'|'tag'|'tree'} expected
4179
+ * @param {string} [filepath]
4180
+ */
4181
+ constructor(oid: string, actual: "blob" | "commit" | "tag" | "tree", expected: "blob" | "commit" | "tag" | "tree", filepath?: string);
4182
+ code: "ObjectTypeError";
4183
+ name: "ObjectTypeError";
4184
+ data: {
4185
+ oid: string;
4186
+ actual: "commit" | "blob" | "tree" | "tag";
4187
+ expected: "commit" | "blob" | "tree" | "tag";
4188
+ filepath: string | undefined;
4189
+ };
4190
+ }
4191
+ declare namespace ObjectTypeError {
4192
+ let code_20: "ObjectTypeError";
4193
+ export { code_20 as code };
4194
+ }
4195
+ declare class ParseError extends BaseError {
4196
+ /**
4197
+ * @param {string} expected
4198
+ * @param {string} actual
4199
+ */
4200
+ constructor(expected: string, actual: string);
4201
+ code: "ParseError";
4202
+ name: "ParseError";
4203
+ data: {
4204
+ expected: string;
4205
+ actual: string;
4206
+ };
4207
+ }
4208
+ declare namespace ParseError {
4209
+ let code_21: "ParseError";
4210
+ export { code_21 as code };
4211
+ }
4212
+ declare class PushRejectedError extends BaseError {
4213
+ /**
4214
+ * @param {'not-fast-forward'|'tag-exists'} reason
4215
+ */
4216
+ constructor(reason: "not-fast-forward" | "tag-exists");
4217
+ code: "PushRejectedError";
4218
+ name: "PushRejectedError";
4219
+ data: {
4220
+ reason: "not-fast-forward" | "tag-exists";
4221
+ };
4222
+ }
4223
+ declare namespace PushRejectedError {
4224
+ let code_22: "PushRejectedError";
4225
+ export { code_22 as code };
4226
+ }
4227
+ declare class RemoteCapabilityError extends BaseError {
4228
+ /**
4229
+ * @param {'shallow'|'deepen-since'|'deepen-not'|'deepen-relative'} capability
4230
+ * @param {'depth'|'since'|'exclude'|'relative'} parameter
4231
+ */
4232
+ constructor(capability: "shallow" | "deepen-since" | "deepen-not" | "deepen-relative", parameter: "depth" | "since" | "exclude" | "relative");
4233
+ code: "RemoteCapabilityError";
4234
+ name: "RemoteCapabilityError";
4235
+ data: {
4236
+ capability: "shallow" | "deepen-since" | "deepen-not" | "deepen-relative";
4237
+ parameter: "depth" | "since" | "exclude" | "relative";
4238
+ };
4239
+ }
4240
+ declare namespace RemoteCapabilityError {
4241
+ let code_23: "RemoteCapabilityError";
4242
+ export { code_23 as code };
4243
+ }
4244
+ declare class SmartHttpError extends BaseError {
4245
+ /**
4246
+ * @param {string} preview
4247
+ * @param {string} response
4248
+ */
4249
+ constructor(preview: string, response: string);
4250
+ code: "SmartHttpError";
4251
+ name: "SmartHttpError";
4252
+ data: {
4253
+ preview: string;
4254
+ response: string;
4255
+ };
4256
+ }
4257
+ declare namespace SmartHttpError {
4258
+ let code_24: "SmartHttpError";
4259
+ export { code_24 as code };
4260
+ }
4261
+ declare class UnknownTransportError extends BaseError {
4262
+ /**
4263
+ * @param {string} url
4264
+ * @param {string} transport
4265
+ * @param {string} [suggestion]
4266
+ */
4267
+ constructor(url: string, transport: string, suggestion?: string);
4268
+ code: "UnknownTransportError";
4269
+ name: "UnknownTransportError";
4270
+ data: {
4271
+ url: string;
4272
+ transport: string;
4273
+ suggestion: string | undefined;
4274
+ };
4275
+ }
4276
+ declare namespace UnknownTransportError {
4277
+ let code_25: "UnknownTransportError";
4278
+ export { code_25 as code };
4279
+ }
4280
+ declare class UnsafeFilepathError extends BaseError {
4281
+ /**
4282
+ * @param {string} filepath
4283
+ */
4284
+ constructor(filepath: string);
4285
+ code: "UnsafeFilepathError";
4286
+ name: "UnsafeFilepathError";
4287
+ data: {
4288
+ filepath: string;
4289
+ };
4290
+ }
4291
+ declare namespace UnsafeFilepathError {
4292
+ let code_26: "UnsafeFilepathError";
4293
+ export { code_26 as code };
4294
+ }
4295
+ declare class UrlParseError extends BaseError {
4296
+ /**
4297
+ * @param {string} url
4298
+ */
4299
+ constructor(url: string);
4300
+ code: "UrlParseError";
4301
+ name: "UrlParseError";
4302
+ data: {
4303
+ url: string;
4304
+ };
4305
+ }
4306
+ declare namespace UrlParseError {
4307
+ let code_27: "UrlParseError";
4308
+ export { code_27 as code };
4309
+ }
4310
+ declare class UserCanceledError extends BaseError {
4311
+ constructor();
4312
+ code: "UserCanceledError";
4313
+ name: "UserCanceledError";
4314
+ data: {};
4315
+ }
4316
+ declare namespace UserCanceledError {
4317
+ let code_28: "UserCanceledError";
4318
+ export { code_28 as code };
4319
+ }
4320
+ declare class UnmergedPathsError extends BaseError {
4321
+ /**
4322
+ * @param {Array<string>} filepaths
4323
+ */
4324
+ constructor(filepaths: Array<string>);
4325
+ code: "UnmergedPathsError";
4326
+ name: "UnmergedPathsError";
4327
+ data: {
4328
+ filepaths: string[];
4329
+ };
4330
+ }
4331
+ declare namespace UnmergedPathsError {
4332
+ let code_29: "UnmergedPathsError";
4333
+ export { code_29 as code };
4334
+ }
4335
+ declare class IndexResetError extends BaseError {
4336
+ /**
4337
+ * @param {Array<string>} filepaths
4338
+ */
4339
+ constructor(filepath: any);
4340
+ code: "IndexResetError";
4341
+ name: "IndexResetError";
4342
+ data: {
4343
+ filepath: any;
4344
+ };
4345
+ }
4346
+ declare namespace IndexResetError {
4347
+ let code_30: "IndexResetError";
4348
+ export { code_30 as code };
4349
+ }
4350
+ declare class NoCommitError extends BaseError {
4351
+ /**
4352
+ * @param {string} ref
4353
+ */
4354
+ constructor(ref: string);
4355
+ code: "NoCommitError";
4356
+ name: "NoCommitError";
4357
+ data: {
4358
+ ref: string;
4359
+ };
4360
+ }
4361
+ declare namespace NoCommitError {
4362
+ let code_31: "NoCommitError";
4363
+ export { code_31 as code };
4364
+ }
4365
+ declare class BaseError extends Error {
4366
+ constructor(message: any);
4367
+ caller: string;
4368
+ toJSON(): {
4369
+ code: any;
4370
+ data: any;
4371
+ caller: string;
4372
+ message: string;
4373
+ stack: string | undefined;
4374
+ };
4375
+ fromJSON(json: any): BaseError;
4376
+ get isIsomorphicGitError(): boolean;
4377
+ }
4378
+ export { updateIndex$1 as updateIndex };