@yaks/git 0.0.0-stage → 0.2.36

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 (183) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +754 -2
  3. package/_dist/address.d.ts +6 -0
  4. package/_dist/address.d.ts.map +1 -0
  5. package/_dist/checkout_vocab.d.ts +3 -0
  6. package/_dist/checkout_vocab.d.ts.map +1 -0
  7. package/_dist/cites.d.ts +48 -0
  8. package/_dist/cites.d.ts.map +1 -0
  9. package/_dist/commit.d.ts +36 -0
  10. package/_dist/commit.d.ts.map +1 -0
  11. package/_dist/comp.d.ts +29 -0
  12. package/_dist/comp.d.ts.map +1 -0
  13. package/_dist/door.d.ts +29 -0
  14. package/_dist/door.d.ts.map +1 -0
  15. package/_dist/format.d.ts +2 -0
  16. package/_dist/format.d.ts.map +1 -0
  17. package/_dist/hold.d.ts +6 -0
  18. package/_dist/hold.d.ts.map +1 -0
  19. package/_dist/host.d.ts +126 -0
  20. package/_dist/host.d.ts.map +1 -0
  21. package/_dist/http.d.ts +33 -0
  22. package/_dist/http.d.ts.map +1 -0
  23. package/_dist/import.d.ts +13 -0
  24. package/_dist/import.d.ts.map +1 -0
  25. package/_dist/index.d.ts +80 -0
  26. package/_dist/index.d.ts.map +1 -0
  27. package/_dist/land.d.ts +77 -0
  28. package/_dist/land.d.ts.map +1 -0
  29. package/_dist/mod.d.ts +73 -0
  30. package/_dist/mod.d.ts.map +1 -0
  31. package/_dist/objects.d.ts +40 -0
  32. package/_dist/objects.d.ts.map +1 -0
  33. package/_dist/oid.d.ts +24 -0
  34. package/_dist/oid.d.ts.map +1 -0
  35. package/_dist/pack-store.d.ts +9 -0
  36. package/_dist/pack-store.d.ts.map +1 -0
  37. package/_dist/pack.d.ts +26 -0
  38. package/_dist/pack.d.ts.map +1 -0
  39. package/_dist/pkt.d.ts +14 -0
  40. package/_dist/pkt.d.ts.map +1 -0
  41. package/_dist/placement.d.ts +4 -0
  42. package/_dist/placement.d.ts.map +1 -0
  43. package/_dist/plugin.d.ts +43 -0
  44. package/_dist/plugin.d.ts.map +1 -0
  45. package/_dist/project.d.ts +20 -0
  46. package/_dist/project.d.ts.map +1 -0
  47. package/_dist/push.d.ts +42 -0
  48. package/_dist/push.d.ts.map +1 -0
  49. package/_dist/refs.d.ts +81 -0
  50. package/_dist/refs.d.ts.map +1 -0
  51. package/_dist/rewrite.d.ts +35 -0
  52. package/_dist/rewrite.d.ts.map +1 -0
  53. package/_dist/service.d.ts +35 -0
  54. package/_dist/service.d.ts.map +1 -0
  55. package/_dist/sha1.d.ts +11 -0
  56. package/_dist/sha1.d.ts.map +1 -0
  57. package/_dist/source.d.ts +12 -0
  58. package/_dist/source.d.ts.map +1 -0
  59. package/_dist/tools.d.ts +11 -0
  60. package/_dist/tools.d.ts.map +1 -0
  61. package/_dist/tree.d.ts +28 -0
  62. package/_dist/tree.d.ts.map +1 -0
  63. package/_dist/unpack.d.ts +5 -0
  64. package/_dist/unpack.d.ts.map +1 -0
  65. package/_dist/vocab.d.ts +8 -0
  66. package/_dist/vocab.d.ts.map +1 -0
  67. package/_dist/workspace.d.ts +17 -0
  68. package/_dist/workspace.d.ts.map +1 -0
  69. package/address.js +9 -0
  70. package/address.js.map +1 -0
  71. package/address.ts +15 -0
  72. package/cache.js +9 -0
  73. package/cache.js.map +1 -0
  74. package/cache.ts +6 -0
  75. package/checkout.js +18 -0
  76. package/checkout.js.map +1 -0
  77. package/checkout.ts +24 -0
  78. package/checkout_vocab.js +14 -0
  79. package/checkout_vocab.js.map +1 -0
  80. package/checkout_vocab.ts +11 -0
  81. package/cites.js +189 -0
  82. package/cites.js.map +1 -0
  83. package/cites.ts +206 -0
  84. package/commit.js +128 -0
  85. package/commit.js.map +1 -0
  86. package/commit.ts +183 -0
  87. package/comp.js +94 -0
  88. package/comp.js.map +1 -0
  89. package/comp.ts +111 -0
  90. package/deno.json +1 -0
  91. package/door.js +88 -0
  92. package/door.js.map +1 -0
  93. package/door.ts +142 -0
  94. package/format.js +43 -0
  95. package/format.js.map +1 -0
  96. package/format.ts +49 -0
  97. package/hold.js +17 -0
  98. package/hold.js.map +1 -0
  99. package/hold.ts +21 -0
  100. package/host.js +1024 -0
  101. package/host.js.map +1 -0
  102. package/host.ts +1140 -0
  103. package/http.js +268 -0
  104. package/http.js.map +1 -0
  105. package/http.ts +329 -0
  106. package/import.js +141 -0
  107. package/import.js.map +1 -0
  108. package/import.ts +128 -0
  109. package/index.js +496 -0
  110. package/index.js.map +1 -0
  111. package/index.ts +634 -0
  112. package/land.js +788 -0
  113. package/land.js.map +1 -0
  114. package/land.ts +871 -0
  115. package/mod.js +73 -0
  116. package/mod.js.map +1 -0
  117. package/mod.ts +74 -0
  118. package/objects.js +331 -0
  119. package/objects.js.map +1 -0
  120. package/objects.ts +390 -0
  121. package/oid.js +50 -0
  122. package/oid.js.map +1 -0
  123. package/oid.ts +83 -0
  124. package/pack-index.js +103 -0
  125. package/pack-index.js.map +1 -0
  126. package/pack-index.ts +104 -0
  127. package/pack-store.js +216 -0
  128. package/pack-store.js.map +1 -0
  129. package/pack-store.ts +292 -0
  130. package/pack.js +121 -0
  131. package/pack.js.map +1 -0
  132. package/pack.ts +146 -0
  133. package/package.json +78 -4
  134. package/pkt.js +73 -0
  135. package/pkt.js.map +1 -0
  136. package/pkt.ts +93 -0
  137. package/placement.js +44 -0
  138. package/placement.js.map +1 -0
  139. package/placement.ts +38 -0
  140. package/plugin.js +66 -0
  141. package/plugin.js.map +1 -0
  142. package/plugin.ts +88 -0
  143. package/process-cwd.py +57 -0
  144. package/project.js +142 -0
  145. package/project.js.map +1 -0
  146. package/project.ts +151 -0
  147. package/push.js +401 -0
  148. package/push.js.map +1 -0
  149. package/push.ts +451 -0
  150. package/refs.js +176 -0
  151. package/refs.js.map +1 -0
  152. package/refs.ts +285 -0
  153. package/rewrite.js +176 -0
  154. package/rewrite.js.map +1 -0
  155. package/rewrite.ts +173 -0
  156. package/service.js +104 -0
  157. package/service.js.map +1 -0
  158. package/service.ts +194 -0
  159. package/sha1.js +115 -0
  160. package/sha1.js.map +1 -0
  161. package/sha1.ts +146 -0
  162. package/source.js +100 -0
  163. package/source.js.map +1 -0
  164. package/source.ts +116 -0
  165. package/spare.js +108 -0
  166. package/spare.js.map +1 -0
  167. package/spare.ts +94 -0
  168. package/tools.js +278 -0
  169. package/tools.js.map +1 -0
  170. package/tools.ts +310 -0
  171. package/tree.js +105 -0
  172. package/tree.js.map +1 -0
  173. package/tree.ts +132 -0
  174. package/unpack.js +207 -0
  175. package/unpack.js.map +1 -0
  176. package/unpack.ts +210 -0
  177. package/vocab.js +20 -0
  178. package/vocab.js.map +1 -0
  179. package/vocab.json +386 -0
  180. package/vocab.ts +22 -0
  181. package/workspace.js +449 -0
  182. package/workspace.js.map +1 -0
  183. package/workspace.ts +445 -0
package/import.js ADDED
@@ -0,0 +1,141 @@
1
+ import { lanes } from "@yaks/fp";
2
+ import { sha256 } from "@yaks/graph/sha256";
3
+ import { commitParts } from "./commit.js";
4
+ import { names } from "./index.js";
5
+ import { preparing } from "./refs.js";
6
+ import { DIR, treeEntries } from "./tree.js";
7
+ import { BadPush } from "./unpack.js";
8
+ let links = (obj)=>{
9
+ try {
10
+ if (obj.type == 'commit') {
11
+ let { tree, parents } = commitParts(obj.bytes);
12
+ return [
13
+ [
14
+ tree,
15
+ 'tree'
16
+ ],
17
+ ...parents.map((oid)=>[
18
+ oid,
19
+ 'commit'
20
+ ])
21
+ ];
22
+ }
23
+ if (obj.type == 'tree') {
24
+ let entries = treeEntries(obj.bytes);
25
+ let named = new Set();
26
+ for (let { name, mode } of entries){
27
+ if (/[/\\]/.test(name) || Array.from(name).some((char)=>char.charCodeAt(0) < 32 || char.charCodeAt(0) == 127) || [
28
+ '.',
29
+ '..',
30
+ '.git'
31
+ ].includes(name.toLowerCase()) || named.has(name) || ![
32
+ DIR,
33
+ '100644',
34
+ '100755'
35
+ ].includes(mode)) {
36
+ throw new BadPush(`unsupported tree entry ${name} (${mode})`);
37
+ }
38
+ named.add(name);
39
+ }
40
+ return entries.map((e)=>[
41
+ e.oid,
42
+ e.mode == DIR ? 'tree' : 'blob'
43
+ ]);
44
+ }
45
+ return [];
46
+ } catch (error) {
47
+ if (error instanceof BadPush) throw error;
48
+ throw new BadPush(`invalid ${obj.type} body`);
49
+ }
50
+ };
51
+ /** Keep the new objects reachable from the pushed tip, bottom up. `kind`
52
+ * checks repository-local objects the pack omitted. Returns incoming files
53
+ * by their content address for callers that also publish the snapshot. */ export let importPush = async (repo, tip, pushed, kind)=>{
54
+ let done = new Map();
55
+ let seen = new Set();
56
+ let ordered = [];
57
+ let retained = new Map();
58
+ let stack = [
59
+ {
60
+ oid: tip,
61
+ type: 'commit'
62
+ }
63
+ ];
64
+ while(stack.length){
65
+ let { oid, type, close } = stack.pop();
66
+ if (close) {
67
+ seen.delete(oid);
68
+ done.set(oid, type);
69
+ ordered.push(oid);
70
+ continue;
71
+ }
72
+ let previous = done.get(oid);
73
+ if (previous) {
74
+ if (previous != type) {
75
+ throw new BadPush(`unexpected object type at ${oid}`);
76
+ }
77
+ continue;
78
+ }
79
+ if (seen.has(oid)) throw new BadPush('cyclic object links');
80
+ let object = pushed.get(oid);
81
+ if (!object) {
82
+ retained.set(oid, type);
83
+ done.set(oid, type);
84
+ continue;
85
+ }
86
+ if (object.type != type) throw new BadPush(`expected ${type} ${oid}`);
87
+ seen.add(oid);
88
+ stack.push({
89
+ oid,
90
+ type,
91
+ close: true
92
+ });
93
+ for (let [oid, type] of links(object).reverse())stack.push({
94
+ oid,
95
+ type
96
+ });
97
+ }
98
+ // The objects the push names without carrying are checked while their
99
+ // other ids are read: neither waits on the other.
100
+ let [known] = await Promise.all([
101
+ names(repo.objects, [
102
+ ...retained.keys()
103
+ ]),
104
+ lanes(6)([
105
+ ...retained
106
+ ], async ([id, type])=>{
107
+ if (await kind(id) != type) {
108
+ throw new BadPush(`missing ${type} ${id}`);
109
+ }
110
+ })
111
+ ]);
112
+ let ids = new Map();
113
+ for (let [id, oid256] of known)ids.set(id, {
114
+ oid: id,
115
+ oid256
116
+ });
117
+ await preparing(repo, async (git)=>{
118
+ for (let id of ordered)ids.set(id, await git.receive(pushed.get(id), ids));
119
+ });
120
+ return carriedOf(pushed).bytes;
121
+ };
122
+ let bodyOf = (bytes)=>bytes.buffer instanceof ArrayBuffer ? new Uint8Array(bytes.buffer, bytes.byteOffset, bytes.byteLength) : Uint8Array.from(bytes);
123
+ /** A push's objects in hand, as @yaks/git/index `listTrees` reads them before
124
+ * they are stored: each blob's address (the SHA-256 its bytes are kept under)
125
+ * by its id, and its bytes by that address. */ export let carriedOf = (pushed)=>{
126
+ let addresses = new Map();
127
+ let bytes = new Map();
128
+ for (let [id, { type, bytes: raw }] of pushed){
129
+ if (type != 'blob') continue;
130
+ let body = bodyOf(raw);
131
+ let address = sha256(body);
132
+ addresses.set(id, address);
133
+ bytes.set(address, body);
134
+ }
135
+ return {
136
+ objects: pushed,
137
+ addresses,
138
+ bytes
139
+ };
140
+ };
141
+ //# sourceMappingURL=import.js.map
package/import.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"import.js","sources":["./import.ts"],"names":[],"mappings":"AAAA,SAAS,KAAK,wBAA6B;AAC3C,SAAS,MAAM,kCAAuC;AACtD,SAAS,WAAW,sBAAqB;AACzC,SAAuB,KAAK,qBAAoB;AAGhD,SAAS,SAAS,oBAA8B;AAChD,SAAS,GAAG,EAAE,WAAW,oBAAmB;AAC5C,SAAS,OAAO,sBAAqB;AAErC,IAAI,QAAQ,CAAC;EACX,IAAI;IACF,IAAI,IAAI,IAAI,IAAI,UAAU;MACxB,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,YAAY,IAAI,KAAK;MAC7C,OAAO;QACL;UAAC;UAAM;SAAO;WACX,QAAQ,GAAG,CAAC,CAAC,MAAwB;YAAC;YAAK;WAAS;OACxD;IACH;IACA,IAAI,IAAI,IAAI,IAAI,QAAQ;MACtB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QACZ,MAAM,MAAM,YAAY,cACpB,IAAI,WAAW,MAAM,MAAM,EAAE,MAAM,UAAU,EAAE,MAAM,UAAU,IAC/D,WAAW,IAAI,CAAC;AAEtB;;6CAE6C,GAC7C,OAAO,IAAI,YAAY,CACrB;EAEA,IAAI,YAAY,IAAI;EACpB,IAAI,QAAQ,IAAI;EAChB,KAAK,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,GAAG,EAAE,CAAC,IAAI,OAAQ;IAC7C,IAAI,QAAQ,QAAQ;IACpB,IAAI,OAAO,OAAO;IAClB,IAAI,UAAU,OAAO;IACrB,UAAU,GAAG,CAAC,IAAI;IAClB,MAAM,GAAG,CAAC,SAAS;EACrB;EACA,OAAO;IAAE,SAAS;IAAQ;IAAW;EAAM;AAC7C,EAAC"}
package/import.ts ADDED
@@ -0,0 +1,128 @@
1
+ import { lanes } from '@yaks/fp'
2
+ import { sha256 } from '@yaks/graph/sha256'
3
+ import { commitParts } from './commit.js'
4
+ import { type Carried, names } from './index.js'
5
+ import { type Kind, type Oids } from './oid.js'
6
+ import type { Obj } from './pack.ts'
7
+ import { preparing, type Repo } from './refs.js'
8
+ import { DIR, treeEntries } from './tree.js'
9
+ import { BadPush } from './unpack.js'
10
+
11
+ let links = (obj: Obj): [string, Kind][] => {
12
+ try {
13
+ if (obj.type == 'commit') {
14
+ let { tree, parents } = commitParts(obj.bytes)
15
+ return [
16
+ [tree, 'tree'],
17
+ ...parents.map((oid): [string, Kind] => [oid, 'commit']),
18
+ ]
19
+ }
20
+ if (obj.type == 'tree') {
21
+ let entries = treeEntries(obj.bytes)
22
+ let named = new Set<string>()
23
+ for (let { name, mode } of entries) {
24
+ if (
25
+ /[/\\]/.test(name) ||
26
+ Array.from(name).some((char) =>
27
+ char.charCodeAt(0) < 32 || char.charCodeAt(0) == 127
28
+ ) ||
29
+ ['.', '..', '.git'].includes(name.toLowerCase()) ||
30
+ named.has(name) || ![DIR, '100644', '100755'].includes(mode)
31
+ ) {
32
+ throw new BadPush(`unsupported tree entry ${name} (${mode})`)
33
+ }
34
+ named.add(name)
35
+ }
36
+ return entries.map((e) => [e.oid, e.mode == DIR ? 'tree' : 'blob'])
37
+ }
38
+ return []
39
+ } catch (error) {
40
+ if (error instanceof BadPush) throw error
41
+ throw new BadPush(`invalid ${obj.type} body`)
42
+ }
43
+ }
44
+
45
+ /** Keep the new objects reachable from the pushed tip, bottom up. `kind`
46
+ * checks repository-local objects the pack omitted. Returns incoming files
47
+ * by their content address for callers that also publish the snapshot. */
48
+ export let importPush = async (
49
+ repo: Pick<Repo, 'objects' | 'bytes'>,
50
+ tip: string,
51
+ pushed: Map<string, Obj>,
52
+ kind: (id: string) => Promise<Kind | undefined>,
53
+ ): Promise<Map<string, Uint8Array<ArrayBuffer>>> => {
54
+ let done = new Map<string, Kind>()
55
+ let seen = new Set<string>()
56
+ let ordered: string[] = []
57
+ let retained = new Map<string, Kind>()
58
+ let stack: { oid: string; type: Kind; close?: true }[] = [{
59
+ oid: tip,
60
+ type: 'commit',
61
+ }]
62
+ while (stack.length) {
63
+ let { oid, type, close } = stack.pop()!
64
+ if (close) {
65
+ seen.delete(oid)
66
+ done.set(oid, type)
67
+ ordered.push(oid)
68
+ continue
69
+ }
70
+ let previous = done.get(oid)
71
+ if (previous) {
72
+ if (previous != type) {
73
+ throw new BadPush(`unexpected object type at ${oid}`)
74
+ }
75
+ continue
76
+ }
77
+ if (seen.has(oid)) throw new BadPush('cyclic object links')
78
+ let object = pushed.get(oid)
79
+ if (!object) {
80
+ retained.set(oid, type)
81
+ done.set(oid, type)
82
+ continue
83
+ }
84
+ if (object.type != type) throw new BadPush(`expected ${type} ${oid}`)
85
+ seen.add(oid)
86
+ stack.push({ oid, type, close: true })
87
+ for (let [oid, type] of links(object).reverse()) stack.push({ oid, type })
88
+ }
89
+ // The objects the push names without carrying are checked while their
90
+ // other ids are read: neither waits on the other.
91
+ let [known] = await Promise.all([
92
+ names(repo.objects, [...retained.keys()]),
93
+ lanes(6)([...retained], async ([id, type]) => {
94
+ if (await kind(id) != type) {
95
+ throw new BadPush(`missing ${type} ${id}`)
96
+ }
97
+ }),
98
+ ])
99
+ let ids = new Map<string, Oids>()
100
+ for (let [id, oid256] of known) ids.set(id, { oid: id, oid256 })
101
+ await preparing(repo, async (git) => {
102
+ for (let id of ordered) ids.set(id, await git.receive(pushed.get(id)!, ids))
103
+ })
104
+ return carriedOf(pushed).bytes
105
+ }
106
+
107
+ let bodyOf = (bytes: Uint8Array): Uint8Array<ArrayBuffer> =>
108
+ bytes.buffer instanceof ArrayBuffer
109
+ ? new Uint8Array(bytes.buffer, bytes.byteOffset, bytes.byteLength)
110
+ : Uint8Array.from(bytes)
111
+
112
+ /** A push's objects in hand, as @yaks/git/index `listTrees` reads them before
113
+ * they are stored: each blob's address (the SHA-256 its bytes are kept under)
114
+ * by its id, and its bytes by that address. */
115
+ export let carriedOf = (
116
+ pushed: ReadonlyMap<string, Obj>,
117
+ ): Carried & { bytes: Map<string, Uint8Array<ArrayBuffer>> } => {
118
+ let addresses = new Map<string, string>()
119
+ let bytes = new Map<string, Uint8Array<ArrayBuffer>>()
120
+ for (let [id, { type, bytes: raw }] of pushed) {
121
+ if (type != 'blob') continue
122
+ let body = bodyOf(raw)
123
+ let address = sha256(body)
124
+ addresses.set(id, address)
125
+ bytes.set(address, body)
126
+ }
127
+ return { objects: pushed, addresses, bytes }
128
+ }