@leed-ai/git-gateway-contract 0.0.0-stage → 0.1.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/LICENSE +201 -0
  2. package/README.md +50 -2
  3. package/dist/behaviour/assertions.d.ts +23 -0
  4. package/dist/behaviour/assertions.js +56 -0
  5. package/dist/behaviour/assertions.js.map +1 -0
  6. package/dist/behaviour/behaviour-case.d.ts +19 -0
  7. package/dist/behaviour/behaviour-case.js +12 -0
  8. package/dist/behaviour/behaviour-case.js.map +1 -0
  9. package/dist/behaviour/behaviour-suite.d.ts +30 -0
  10. package/dist/behaviour/behaviour-suite.js +50 -0
  11. package/dist/behaviour/behaviour-suite.js.map +1 -0
  12. package/dist/behaviour/commit-action-cases.d.ts +4 -0
  13. package/dist/behaviour/commit-action-cases.js +342 -0
  14. package/dist/behaviour/commit-action-cases.js.map +1 -0
  15. package/dist/behaviour/commit-write-cases.d.ts +4 -0
  16. package/dist/behaviour/commit-write-cases.js +234 -0
  17. package/dist/behaviour/commit-write-cases.js.map +1 -0
  18. package/dist/behaviour/fixtures.d.ts +29 -0
  19. package/dist/behaviour/fixtures.js +83 -0
  20. package/dist/behaviour/fixtures.js.map +1 -0
  21. package/dist/behaviour/lifecycle-cases.d.ts +4 -0
  22. package/dist/behaviour/lifecycle-cases.js +158 -0
  23. package/dist/behaviour/lifecycle-cases.js.map +1 -0
  24. package/dist/behaviour/promote-cases.d.ts +4 -0
  25. package/dist/behaviour/promote-cases.js +122 -0
  26. package/dist/behaviour/promote-cases.js.map +1 -0
  27. package/dist/behaviour/read-cases.d.ts +4 -0
  28. package/dist/behaviour/read-cases.js +248 -0
  29. package/dist/behaviour/read-cases.js.map +1 -0
  30. package/dist/behaviour/sync-cases.d.ts +4 -0
  31. package/dist/behaviour/sync-cases.js +205 -0
  32. package/dist/behaviour/sync-cases.js.map +1 -0
  33. package/dist/clock-B3MlpmVY.d.ts +10 -0
  34. package/dist/commit-BEZmeAOl.d.ts +23 -0
  35. package/dist/file-map-CxUveLWz.d.ts +18 -0
  36. package/dist/gateway-config-oVsdTEeK.d.ts +39 -0
  37. package/dist/gateway-error-body-BWzZFAQI.d.ts +214 -0
  38. package/dist/gateway-error.d.ts +30 -0
  39. package/dist/gateway-error.js +63 -0
  40. package/dist/gateway-error.js.map +1 -0
  41. package/dist/git-gateway-VA9Tc5tn.d.ts +358 -0
  42. package/dist/git-gateway.d.ts +2 -0
  43. package/dist/git-gateway.js +65 -0
  44. package/dist/git-gateway.js.map +1 -0
  45. package/dist/health.d.ts +9 -0
  46. package/dist/health.js +18 -0
  47. package/dist/health.js.map +1 -0
  48. package/dist/history-CqvHaUE-.d.ts +20 -0
  49. package/dist/package-name.d.ts +3 -0
  50. package/dist/package-name.js +6 -0
  51. package/dist/package-name.js.map +1 -0
  52. package/dist/proxy/audit-event.d.ts +61 -0
  53. package/dist/proxy/audit-event.js +97 -0
  54. package/dist/proxy/audit-event.js.map +1 -0
  55. package/dist/proxy/branch-rule.d.ts +72 -0
  56. package/dist/proxy/branch-rule.js +106 -0
  57. package/dist/proxy/branch-rule.js.map +1 -0
  58. package/dist/proxy/gateway-hooks.d.ts +58 -0
  59. package/dist/proxy/gateway-hooks.js +0 -0
  60. package/dist/proxy/git-operation.d.ts +17 -0
  61. package/dist/proxy/git-operation.js +32 -0
  62. package/dist/proxy/git-operation.js.map +1 -0
  63. package/dist/proxy/policy-result.d.ts +51 -0
  64. package/dist/proxy/policy-result.js +90 -0
  65. package/dist/proxy/policy-result.js.map +1 -0
  66. package/dist/proxy/principal.d.ts +18 -0
  67. package/dist/proxy/principal.js +32 -0
  68. package/dist/proxy/principal.js.map +1 -0
  69. package/dist/proxy/push-policy-result.d.ts +34 -0
  70. package/dist/proxy/push-policy-result.js +48 -0
  71. package/dist/proxy/push-policy-result.js.map +1 -0
  72. package/dist/proxy/push-policy.d.ts +146 -0
  73. package/dist/proxy/push-policy.js +112 -0
  74. package/dist/proxy/push-policy.js.map +1 -0
  75. package/dist/proxy/request-credential.d.ts +22 -0
  76. package/dist/proxy/request-credential.js +46 -0
  77. package/dist/proxy/request-credential.js.map +1 -0
  78. package/dist/proxy/smart-http-config.d.ts +22 -0
  79. package/dist/proxy/smart-http-config.js +40 -0
  80. package/dist/proxy/smart-http-config.js.map +1 -0
  81. package/dist/reference/apply-actions.d.ts +9 -0
  82. package/dist/reference/apply-actions.js +84 -0
  83. package/dist/reference/apply-actions.js.map +1 -0
  84. package/dist/reference/branch-methods.d.ts +7 -0
  85. package/dist/reference/branch-methods.js +105 -0
  86. package/dist/reference/branch-methods.js.map +1 -0
  87. package/dist/reference/bytes.d.ts +22 -0
  88. package/dist/reference/bytes.js +62 -0
  89. package/dist/reference/bytes.js.map +1 -0
  90. package/dist/reference/clock.d.ts +2 -0
  91. package/dist/reference/clock.js +18 -0
  92. package/dist/reference/clock.js.map +1 -0
  93. package/dist/reference/commit-method.d.ts +5 -0
  94. package/dist/reference/commit-method.js +83 -0
  95. package/dist/reference/commit-method.js.map +1 -0
  96. package/dist/reference/file-map.d.ts +2 -0
  97. package/dist/reference/file-map.js +24 -0
  98. package/dist/reference/file-map.js.map +1 -0
  99. package/dist/reference/hash.d.ts +10 -0
  100. package/dist/reference/hash.js +25 -0
  101. package/dist/reference/hash.js.map +1 -0
  102. package/dist/reference/history.d.ts +2 -0
  103. package/dist/reference/history.js +65 -0
  104. package/dist/reference/history.js.map +1 -0
  105. package/dist/reference/lifecycle-methods.d.ts +9 -0
  106. package/dist/reference/lifecycle-methods.js +48 -0
  107. package/dist/reference/lifecycle-methods.js.map +1 -0
  108. package/dist/reference/read-methods.d.ts +13 -0
  109. package/dist/reference/read-methods.js +68 -0
  110. package/dist/reference/read-methods.js.map +1 -0
  111. package/dist/reference/reference-gateway.d.ts +18 -0
  112. package/dist/reference/reference-gateway.js +35 -0
  113. package/dist/reference/reference-gateway.js.map +1 -0
  114. package/dist/reference/repo-state.d.ts +43 -0
  115. package/dist/reference/repo-state.js +45 -0
  116. package/dist/reference/repo-state.js.map +1 -0
  117. package/dist/reference/run-method.d.ts +13 -0
  118. package/dist/reference/run-method.js +15 -0
  119. package/dist/reference/run-method.js.map +1 -0
  120. package/dist/reference/three-way-merge.d.ts +16 -0
  121. package/dist/reference/three-way-merge.js +45 -0
  122. package/dist/reference/three-way-merge.js.map +1 -0
  123. package/dist/reference/trailer.d.ts +7 -0
  124. package/dist/reference/trailer.js +16 -0
  125. package/dist/reference/trailer.js.map +1 -0
  126. package/dist/reference/tree-index.d.ts +2 -0
  127. package/dist/reference/tree-index.js +66 -0
  128. package/dist/reference/tree-index.js.map +1 -0
  129. package/dist/reference/write-commit.d.ts +15 -0
  130. package/dist/reference/write-commit.js +44 -0
  131. package/dist/reference/write-commit.js.map +1 -0
  132. package/dist/rpc/commit-exists.d.ts +16 -0
  133. package/dist/rpc/commit-exists.js +30 -0
  134. package/dist/rpc/commit-exists.js.map +1 -0
  135. package/dist/rpc/commit.d.ts +172 -0
  136. package/dist/rpc/commit.js +115 -0
  137. package/dist/rpc/commit.js.map +1 -0
  138. package/dist/rpc/list-tree.d.ts +59 -0
  139. package/dist/rpc/list-tree.js +54 -0
  140. package/dist/rpc/list-tree.js.map +1 -0
  141. package/dist/rpc/log.d.ts +35 -0
  142. package/dist/rpc/log.js +41 -0
  143. package/dist/rpc/log.js.map +1 -0
  144. package/dist/rpc/mint-read-token.d.ts +17 -0
  145. package/dist/rpc/mint-read-token.js +36 -0
  146. package/dist/rpc/mint-read-token.js.map +1 -0
  147. package/dist/rpc/promote.d.ts +39 -0
  148. package/dist/rpc/promote.js +69 -0
  149. package/dist/rpc/promote.js.map +1 -0
  150. package/dist/rpc/read-file.d.ts +44 -0
  151. package/dist/rpc/read-file.js +56 -0
  152. package/dist/rpc/read-file.js.map +1 -0
  153. package/dist/rpc/repo-lifecycle.d.ts +39 -0
  154. package/dist/rpc/repo-lifecycle.js +64 -0
  155. package/dist/rpc/repo-lifecycle.js.map +1 -0
  156. package/dist/rpc/resolve-ref.d.ts +15 -0
  157. package/dist/rpc/resolve-ref.js +28 -0
  158. package/dist/rpc/resolve-ref.js.map +1 -0
  159. package/dist/rpc/sync-branch.d.ts +107 -0
  160. package/dist/rpc/sync-branch.js +114 -0
  161. package/dist/rpc/sync-branch.js.map +1 -0
  162. package/dist/schemas/commit-action.d.ts +100 -0
  163. package/dist/schemas/commit-action.js +138 -0
  164. package/dist/schemas/commit-action.js.map +1 -0
  165. package/dist/schemas/commit.d.ts +2 -0
  166. package/dist/schemas/commit.js +24 -0
  167. package/dist/schemas/commit.js.map +1 -0
  168. package/dist/schemas/content-encoding.d.ts +24 -0
  169. package/dist/schemas/content-encoding.js +41 -0
  170. package/dist/schemas/content-encoding.js.map +1 -0
  171. package/dist/schemas/examples.d.ts +38 -0
  172. package/dist/schemas/examples.js +32 -0
  173. package/dist/schemas/examples.js.map +1 -0
  174. package/dist/schemas/gateway-config.d.ts +2 -0
  175. package/dist/schemas/gateway-config.js +72 -0
  176. package/dist/schemas/gateway-config.js.map +1 -0
  177. package/dist/schemas/gateway-error-body.d.ts +2 -0
  178. package/dist/schemas/gateway-error-body.js +188 -0
  179. package/dist/schemas/gateway-error-body.js.map +1 -0
  180. package/dist/schemas/identity.d.ts +21 -0
  181. package/dist/schemas/identity.js +40 -0
  182. package/dist/schemas/identity.js.map +1 -0
  183. package/dist/schemas/names.d.ts +26 -0
  184. package/dist/schemas/names.js +58 -0
  185. package/dist/schemas/names.js.map +1 -0
  186. package/dist/schemas/ref-update.d.ts +10 -0
  187. package/dist/schemas/ref-update.js +25 -0
  188. package/dist/schemas/ref-update.js.map +1 -0
  189. package/dist/schemas/sha.d.ts +8 -0
  190. package/dist/schemas/sha.js +14 -0
  191. package/dist/schemas/sha.js.map +1 -0
  192. package/dist/schemas/tree-entry.d.ts +2 -0
  193. package/dist/schemas/tree-entry.js +62 -0
  194. package/dist/schemas/tree-entry.js.map +1 -0
  195. package/dist/storage/git-remote.d.ts +17 -0
  196. package/dist/storage/git-remote.js +31 -0
  197. package/dist/storage/git-remote.js.map +1 -0
  198. package/dist/storage/storage-backend.d.ts +61 -0
  199. package/dist/storage/storage-backend.js +0 -0
  200. package/dist/storage/storage-errors.d.ts +12 -0
  201. package/dist/storage/storage-errors.js +22 -0
  202. package/dist/storage/storage-errors.js.map +1 -0
  203. package/dist/storage/storage-input.d.ts +7 -0
  204. package/dist/storage/storage-input.js +14 -0
  205. package/dist/storage/storage-input.js.map +1 -0
  206. package/dist/storage/storage-read.d.ts +13 -0
  207. package/dist/storage/storage-read.js +30 -0
  208. package/dist/storage/storage-read.js.map +1 -0
  209. package/dist/storage/storage-repo-info.d.ts +16 -0
  210. package/dist/storage/storage-repo-info.js +30 -0
  211. package/dist/storage/storage-repo-info.js.map +1 -0
  212. package/dist/storage/storage-tree-entry.d.ts +21 -0
  213. package/dist/storage/storage-tree-entry.js +17 -0
  214. package/dist/storage/storage-tree-entry.js.map +1 -0
  215. package/dist/tree-entry-BM_1gou1.d.ts +41 -0
  216. package/dist/tree-index-Bk721Phv.d.ts +14 -0
  217. package/package.json +401 -4
  218. package/src/behaviour/assertions.ts +75 -0
  219. package/src/behaviour/behaviour-case.ts +28 -0
  220. package/src/behaviour/behaviour-suite.ts +76 -0
  221. package/src/behaviour/commit-action-cases.ts +253 -0
  222. package/src/behaviour/commit-write-cases.ts +205 -0
  223. package/src/behaviour/fixtures.ts +103 -0
  224. package/src/behaviour/lifecycle-cases.ts +104 -0
  225. package/src/behaviour/promote-cases.ts +78 -0
  226. package/src/behaviour/read-cases.ts +176 -0
  227. package/src/behaviour/sync-cases.ts +156 -0
  228. package/src/gateway-error.ts +72 -0
  229. package/src/git-gateway.ts +76 -0
  230. package/src/health.ts +26 -0
  231. package/src/package-name.ts +4 -0
  232. package/src/proxy/audit-event.ts +135 -0
  233. package/src/proxy/branch-rule.ts +190 -0
  234. package/src/proxy/gateway-hooks.ts +67 -0
  235. package/src/proxy/git-operation.ts +36 -0
  236. package/src/proxy/policy-result.ts +127 -0
  237. package/src/proxy/principal.ts +81 -0
  238. package/src/proxy/push-policy-result.ts +86 -0
  239. package/src/proxy/push-policy.ts +158 -0
  240. package/src/proxy/request-credential.ts +47 -0
  241. package/src/proxy/smart-http-config.ts +158 -0
  242. package/src/reference/apply-actions.ts +96 -0
  243. package/src/reference/branch-methods.ts +105 -0
  244. package/src/reference/bytes.ts +66 -0
  245. package/src/reference/clock.ts +19 -0
  246. package/src/reference/commit-method.ts +97 -0
  247. package/src/reference/file-map.ts +35 -0
  248. package/src/reference/hash.ts +25 -0
  249. package/src/reference/history.ts +78 -0
  250. package/src/reference/lifecycle-methods.ts +52 -0
  251. package/src/reference/read-methods.ts +87 -0
  252. package/src/reference/reference-gateway.ts +50 -0
  253. package/src/reference/repo-state.ts +83 -0
  254. package/src/reference/run-method.ts +25 -0
  255. package/src/reference/three-way-merge.ts +42 -0
  256. package/src/reference/trailer.ts +18 -0
  257. package/src/reference/tree-index.ts +65 -0
  258. package/src/reference/write-commit.ts +44 -0
  259. package/src/rpc/commit-exists.ts +46 -0
  260. package/src/rpc/commit.ts +156 -0
  261. package/src/rpc/list-tree.ts +78 -0
  262. package/src/rpc/log.ts +51 -0
  263. package/src/rpc/mint-read-token.ts +59 -0
  264. package/src/rpc/promote.ts +72 -0
  265. package/src/rpc/read-file.ts +75 -0
  266. package/src/rpc/repo-lifecycle.ts +103 -0
  267. package/src/rpc/resolve-ref.ts +41 -0
  268. package/src/rpc/sync-branch.ts +149 -0
  269. package/src/schemas/commit-action.ts +157 -0
  270. package/src/schemas/commit.ts +43 -0
  271. package/src/schemas/content-encoding.ts +58 -0
  272. package/src/schemas/examples.ts +24 -0
  273. package/src/schemas/gateway-config.ts +116 -0
  274. package/src/schemas/gateway-error-body.ts +230 -0
  275. package/src/schemas/identity.ts +57 -0
  276. package/src/schemas/names.ts +126 -0
  277. package/src/schemas/ref-update.ts +38 -0
  278. package/src/schemas/sha.ts +20 -0
  279. package/src/schemas/tree-entry.ts +72 -0
  280. package/src/storage/git-remote.ts +58 -0
  281. package/src/storage/storage-backend.ts +65 -0
  282. package/src/storage/storage-errors.ts +24 -0
  283. package/src/storage/storage-input.ts +14 -0
  284. package/src/storage/storage-read.ts +45 -0
  285. package/src/storage/storage-repo-info.ts +46 -0
  286. package/src/storage/storage-tree-entry.ts +20 -0
@@ -0,0 +1,248 @@
1
+ import { assertEqual, assertTrue, expectGatewayError, present } from "./assertions.js";
2
+ import { behaviourCase } from "./behaviour-case.js";
3
+ import { branchFrom, readText, seedRepo, writeFiles } from "./fixtures.js";
4
+ // src/behaviour/read-cases.ts
5
+ const GROUP = "reads";
6
+ const SEED = {
7
+ "a.md": "hello\n",
8
+ "dir/b.md": "b",
9
+ "dir/sub/c.md": "c",
10
+ "z.md": "hello\n"
11
+ };
12
+ const UNKNOWN_SHA = "ffffffffffffffffffffffffffffffffffffffff";
13
+ /** readFile, listTree, resolveRef, log and commitExists. */
14
+ const readCases = [
15
+ behaviourCase(GROUP, "readFile returns content, git blob id, size, mode and commit", async ({ gateway, repo }) => {
16
+ const seed = await seedRepo(gateway, repo, SEED);
17
+ const file = present(await gateway.readFile({
18
+ repo,
19
+ ref: "main",
20
+ path: "a.md"
21
+ }), "file exists");
22
+ assertEqual(file, {
23
+ path: "a.md",
24
+ commit: seed.sha,
25
+ sha: "ce013625030ba8dba906f756967f9e9ca394464a",
26
+ size: 6,
27
+ executable: false,
28
+ encoding: "text",
29
+ content: "hello\n"
30
+ }, "file read");
31
+ const twin = await gateway.readFile({
32
+ repo,
33
+ ref: "main",
34
+ path: "z.md"
35
+ });
36
+ assertEqual(twin?.sha, file.sha, "equal content has an equal blob id");
37
+ }),
38
+ behaviourCase(GROUP, "readFile at an old commit reads the old content", async ({ gateway, repo }) => {
39
+ const seed = await seedRepo(gateway, repo, SEED);
40
+ await writeFiles(gateway, repo, "main", { "a.md": "changed" });
41
+ assertEqual(await readText(gateway, repo, seed.sha, "a.md"), "hello\n", "old content by sha");
42
+ assertEqual(await readText(gateway, repo, "main", "a.md"), "changed", "new content by branch");
43
+ }),
44
+ behaviourCase(GROUP, "readFile is null for a missing path or a directory", async ({ gateway, repo }) => {
45
+ await seedRepo(gateway, repo, SEED);
46
+ assertEqual(await gateway.readFile({
47
+ repo,
48
+ ref: "main",
49
+ path: "nope.md"
50
+ }), null, "missing path");
51
+ assertEqual(await gateway.readFile({
52
+ repo,
53
+ ref: "main",
54
+ path: "dir"
55
+ }), null, "directory");
56
+ }),
57
+ behaviourCase(GROUP, "reads at a missing ref are ref_not_found", async ({ gateway, repo }) => {
58
+ await seedRepo(gateway, repo, SEED);
59
+ await expectGatewayError(gateway.readFile({
60
+ repo,
61
+ ref: "nope",
62
+ path: "a.md"
63
+ }), "ref_not_found");
64
+ await expectGatewayError(gateway.readFile({
65
+ repo,
66
+ ref: UNKNOWN_SHA,
67
+ path: "a.md"
68
+ }), "ref_not_found");
69
+ await expectGatewayError(gateway.listTree({
70
+ repo,
71
+ ref: "nope"
72
+ }), "ref_not_found");
73
+ await expectGatewayError(gateway.log({
74
+ repo,
75
+ ref: "nope"
76
+ }), "ref_not_found");
77
+ }),
78
+ behaviourCase(GROUP, "listTree lists one level, sorted, with types and modes", async ({ gateway, repo }) => {
79
+ const seed = await seedRepo(gateway, repo, SEED);
80
+ const root = present(await gateway.listTree({
81
+ repo,
82
+ ref: "main"
83
+ }), "root listing");
84
+ assertEqual([root.commit, root.path], [seed.sha, null], "listing header");
85
+ assertEqual(root.entries.map((entry) => [
86
+ entry.path,
87
+ entry.name,
88
+ entry.type,
89
+ entry.mode
90
+ ]), [
91
+ [
92
+ "a.md",
93
+ "a.md",
94
+ "blob",
95
+ "100644"
96
+ ],
97
+ [
98
+ "dir",
99
+ "dir",
100
+ "tree",
101
+ "040000"
102
+ ],
103
+ [
104
+ "z.md",
105
+ "z.md",
106
+ "blob",
107
+ "100644"
108
+ ]
109
+ ], "root entries");
110
+ const dir = present(await gateway.listTree({
111
+ repo,
112
+ ref: "main",
113
+ path: "dir"
114
+ }), "dir listing");
115
+ assertEqual(dir.entries.map((entry) => entry.path), ["dir/b.md", "dir/sub"], "dir entries");
116
+ }),
117
+ behaviourCase(GROUP, "listTree recursive lists everything beneath, directories included", async ({ gateway, repo }) => {
118
+ await seedRepo(gateway, repo, SEED);
119
+ const listing = present(await gateway.listTree({
120
+ repo,
121
+ ref: "main",
122
+ path: "dir",
123
+ recursive: true
124
+ }), "listing");
125
+ assertEqual(listing.entries.map((entry) => entry.path), [
126
+ "dir/b.md",
127
+ "dir/sub",
128
+ "dir/sub/c.md"
129
+ ], "entries");
130
+ }),
131
+ behaviourCase(GROUP, "listTree is null for a file or a missing directory", async ({ gateway, repo }) => {
132
+ await seedRepo(gateway, repo, SEED);
133
+ assertEqual(await gateway.listTree({
134
+ repo,
135
+ ref: "main",
136
+ path: "a.md"
137
+ }), null, "file");
138
+ assertEqual(await gateway.listTree({
139
+ repo,
140
+ ref: "main",
141
+ path: "nope"
142
+ }), null, "missing");
143
+ }),
144
+ behaviourCase(GROUP, "an unchanged directory keeps its tree id", async ({ gateway, repo }) => {
145
+ const seed = await seedRepo(gateway, repo, SEED);
146
+ const next = await writeFiles(gateway, repo, "main", { "a.md": "changed" });
147
+ const dirSha = async (ref) => (await gateway.listTree({
148
+ repo,
149
+ ref
150
+ }))?.entries.find((entry) => entry.path === "dir")?.sha;
151
+ assertEqual(await dirSha(next.sha), await dirSha(seed.sha), "dir tree id unchanged");
152
+ assertTrue(next.tree !== seed.tree, "root tree id changed");
153
+ }),
154
+ behaviourCase(GROUP, "resolveRef resolves branches and confirms commit ids", async ({ gateway, repo }) => {
155
+ const seed = await seedRepo(gateway, repo, SEED);
156
+ assertEqual(await gateway.resolveRef({
157
+ repo,
158
+ ref: "main"
159
+ }), { sha: seed.sha }, "branch");
160
+ assertEqual(await gateway.resolveRef({
161
+ repo,
162
+ ref: seed.sha
163
+ }), { sha: seed.sha }, "commit id");
164
+ assertEqual(await gateway.resolveRef({
165
+ repo,
166
+ ref: "nope"
167
+ }), null, "missing branch");
168
+ assertEqual(await gateway.resolveRef({
169
+ repo,
170
+ ref: UNKNOWN_SHA
171
+ }), null, "unknown commit");
172
+ }),
173
+ behaviourCase(GROUP, "log lists newest first and pages with limit, offset and hasMore", async ({ gateway, repo }) => {
174
+ const first = await seedRepo(gateway, repo, SEED);
175
+ const second = await writeFiles(gateway, repo, "main", { "n.md": "2" });
176
+ const third = await writeFiles(gateway, repo, "main", { "n.md": "3" });
177
+ const all = await gateway.log({
178
+ repo,
179
+ ref: "main"
180
+ });
181
+ assertEqual(all.commits.map((c) => c.sha), [
182
+ third.sha,
183
+ second.sha,
184
+ first.sha
185
+ ], "newest first");
186
+ assertEqual(all.hasMore, false, "no more");
187
+ const page = await gateway.log({
188
+ repo,
189
+ ref: "main",
190
+ limit: 1,
191
+ offset: 1
192
+ });
193
+ assertEqual([page.commits.map((c) => c.sha), page.hasMore], [[second.sha], true], "second page");
194
+ const atSha = await gateway.log({
195
+ repo,
196
+ ref: second.sha
197
+ });
198
+ assertEqual(atSha.commits.map((c) => c.sha), [second.sha, first.sha], "log from a commit id");
199
+ }),
200
+ behaviourCase(GROUP, "log since keeps commits at or after the time", async ({ gateway, repo }) => {
201
+ const first = await seedRepo(gateway, repo, SEED);
202
+ const second = await writeFiles(gateway, repo, "main", { "n.md": "2" });
203
+ const since = (date) => gateway.log({
204
+ repo,
205
+ ref: "main",
206
+ since: date
207
+ });
208
+ assertEqual((await since("2000-01-01T00:00:00.000Z")).commits.length, 2, "all after the distant past");
209
+ assertEqual((await since("2999-01-01T00:00:00.000Z")).commits, [], "none after the far future");
210
+ const fromSecond = (await since(second.committer.date)).commits.map((c) => c.sha);
211
+ assertTrue(fromSecond.includes(second.sha), "a commit at exactly `since` is kept");
212
+ assertTrue(first.committer.date <= second.committer.date, "dates never go backwards");
213
+ }),
214
+ behaviourCase(GROUP, "log of a merge lists both sides, children before parents", async ({ gateway, repo }) => {
215
+ const seed = await seedRepo(gateway, repo, SEED);
216
+ const side = await branchFrom(gateway, repo, "main", "side", { "s.md": "s" });
217
+ const mainline = await writeFiles(gateway, repo, "main", { "m.md": "m" });
218
+ await gateway.syncBranch({
219
+ repo,
220
+ from: "side",
221
+ into: "main"
222
+ });
223
+ const shas = (await gateway.log({
224
+ repo,
225
+ ref: "main"
226
+ })).commits.map((c) => c.sha);
227
+ assertEqual(shas.length, 4, "merge, both sides and the seed");
228
+ assertEqual(shas.at(-1), seed.sha, "root last");
229
+ assertTrue(shas.includes(side.sha) && shas.includes(mainline.sha), "both sides listed");
230
+ }),
231
+ behaviourCase(GROUP, "commitExists checks the repository and, optionally, a branch", async ({ gateway, repo }) => {
232
+ const seed = await seedRepo(gateway, repo, SEED);
233
+ const side = await branchFrom(gateway, repo, "main", "side", { "s.md": "s" });
234
+ const exists = async (sha, branch) => (await gateway.commitExists({
235
+ repo,
236
+ sha,
237
+ ...branch === void 0 ? {} : { branch }
238
+ })).exists;
239
+ assertEqual(await exists(side.sha), true, "any commit");
240
+ assertEqual(await exists(UNKNOWN_SHA), false, "unknown commit");
241
+ assertEqual(await exists(seed.sha, "side"), true, "ancestor is reachable");
242
+ assertEqual(await exists(side.sha, "main"), false, "not on main");
243
+ assertEqual(await exists(seed.sha, "nope"), false, "missing branch");
244
+ })
245
+ ];
246
+ export { readCases };
247
+
248
+ //# sourceMappingURL=read-cases.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read-cases.js","names":[],"sources":["../../src/behaviour/read-cases.ts"],"sourcesContent":["// SPDX-License-Identifier: Apache-2.0\nimport { assertEqual, assertTrue, expectGatewayError, present } from './assertions.ts';\nimport { behaviourCase, type BehaviourCase } from './behaviour-case.ts';\nimport { branchFrom, readText, seedRepo, writeFiles } from './fixtures.ts';\n\nconst GROUP = 'reads';\nconst SEED = { 'a.md': 'hello\\n', 'dir/b.md': 'b', 'dir/sub/c.md': 'c', 'z.md': 'hello\\n' };\nconst UNKNOWN_SHA = 'ffffffffffffffffffffffffffffffffffffffff';\n\n/** readFile, listTree, resolveRef, log and commitExists. */\nexport const readCases: readonly BehaviourCase[] = [\n behaviourCase(\n GROUP,\n 'readFile returns content, git blob id, size, mode and commit',\n async ({ gateway, repo }) => {\n const seed = await seedRepo(gateway, repo, SEED);\n const file = present(await gateway.readFile({ repo, ref: 'main', path: 'a.md' }), 'file exists');\n assertEqual(\n file,\n {\n path: 'a.md',\n commit: seed.sha,\n sha: 'ce013625030ba8dba906f756967f9e9ca394464a',\n size: 6,\n executable: false,\n encoding: 'text',\n content: 'hello\\n',\n },\n 'file read',\n );\n const twin = await gateway.readFile({ repo, ref: 'main', path: 'z.md' });\n assertEqual(twin?.sha, file.sha, 'equal content has an equal blob id');\n },\n ),\n behaviourCase(GROUP, 'readFile at an old commit reads the old content', async ({ gateway, repo }) => {\n const seed = await seedRepo(gateway, repo, SEED);\n await writeFiles(gateway, repo, 'main', { 'a.md': 'changed' });\n assertEqual(await readText(gateway, repo, seed.sha, 'a.md'), 'hello\\n', 'old content by sha');\n assertEqual(await readText(gateway, repo, 'main', 'a.md'), 'changed', 'new content by branch');\n }),\n behaviourCase(GROUP, 'readFile is null for a missing path or a directory', async ({ gateway, repo }) => {\n await seedRepo(gateway, repo, SEED);\n assertEqual(await gateway.readFile({ repo, ref: 'main', path: 'nope.md' }), null, 'missing path');\n assertEqual(await gateway.readFile({ repo, ref: 'main', path: 'dir' }), null, 'directory');\n }),\n behaviourCase(GROUP, 'reads at a missing ref are ref_not_found', async ({ gateway, repo }) => {\n await seedRepo(gateway, repo, SEED);\n await expectGatewayError(gateway.readFile({ repo, ref: 'nope', path: 'a.md' }), 'ref_not_found');\n await expectGatewayError(gateway.readFile({ repo, ref: UNKNOWN_SHA, path: 'a.md' }), 'ref_not_found');\n await expectGatewayError(gateway.listTree({ repo, ref: 'nope' }), 'ref_not_found');\n await expectGatewayError(gateway.log({ repo, ref: 'nope' }), 'ref_not_found');\n }),\n behaviourCase(\n GROUP,\n 'listTree lists one level, sorted, with types and modes',\n async ({ gateway, repo }) => {\n const seed = await seedRepo(gateway, repo, SEED);\n const root = present(await gateway.listTree({ repo, ref: 'main' }), 'root listing');\n assertEqual([root.commit, root.path], [seed.sha, null], 'listing header');\n assertEqual(\n root.entries.map((entry) => [entry.path, entry.name, entry.type, entry.mode]),\n [\n ['a.md', 'a.md', 'blob', '100644'],\n ['dir', 'dir', 'tree', '040000'],\n ['z.md', 'z.md', 'blob', '100644'],\n ],\n 'root entries',\n );\n const dir = present(await gateway.listTree({ repo, ref: 'main', path: 'dir' }), 'dir listing');\n assertEqual(\n dir.entries.map((entry) => entry.path),\n ['dir/b.md', 'dir/sub'],\n 'dir entries',\n );\n },\n ),\n behaviourCase(\n GROUP,\n 'listTree recursive lists everything beneath, directories included',\n async ({ gateway, repo }) => {\n await seedRepo(gateway, repo, SEED);\n const listing = present(\n await gateway.listTree({ repo, ref: 'main', path: 'dir', recursive: true }),\n 'listing',\n );\n assertEqual(\n listing.entries.map((entry) => entry.path),\n ['dir/b.md', 'dir/sub', 'dir/sub/c.md'],\n 'entries',\n );\n },\n ),\n behaviourCase(GROUP, 'listTree is null for a file or a missing directory', async ({ gateway, repo }) => {\n await seedRepo(gateway, repo, SEED);\n assertEqual(await gateway.listTree({ repo, ref: 'main', path: 'a.md' }), null, 'file');\n assertEqual(await gateway.listTree({ repo, ref: 'main', path: 'nope' }), null, 'missing');\n }),\n behaviourCase(GROUP, 'an unchanged directory keeps its tree id', async ({ gateway, repo }) => {\n const seed = await seedRepo(gateway, repo, SEED);\n const next = await writeFiles(gateway, repo, 'main', { 'a.md': 'changed' });\n const dirSha = async (ref: string) =>\n (await gateway.listTree({ repo, ref }))?.entries.find((entry) => entry.path === 'dir')?.sha;\n assertEqual(await dirSha(next.sha), await dirSha(seed.sha), 'dir tree id unchanged');\n assertTrue(next.tree !== seed.tree, 'root tree id changed');\n }),\n behaviourCase(GROUP, 'resolveRef resolves branches and confirms commit ids', async ({ gateway, repo }) => {\n const seed = await seedRepo(gateway, repo, SEED);\n assertEqual(await gateway.resolveRef({ repo, ref: 'main' }), { sha: seed.sha }, 'branch');\n assertEqual(await gateway.resolveRef({ repo, ref: seed.sha }), { sha: seed.sha }, 'commit id');\n assertEqual(await gateway.resolveRef({ repo, ref: 'nope' }), null, 'missing branch');\n assertEqual(await gateway.resolveRef({ repo, ref: UNKNOWN_SHA }), null, 'unknown commit');\n }),\n behaviourCase(\n GROUP,\n 'log lists newest first and pages with limit, offset and hasMore',\n async ({ gateway, repo }) => {\n const first = await seedRepo(gateway, repo, SEED);\n const second = await writeFiles(gateway, repo, 'main', { 'n.md': '2' });\n const third = await writeFiles(gateway, repo, 'main', { 'n.md': '3' });\n const all = await gateway.log({ repo, ref: 'main' });\n assertEqual(\n all.commits.map((c) => c.sha),\n [third.sha, second.sha, first.sha],\n 'newest first',\n );\n assertEqual(all.hasMore, false, 'no more');\n const page = await gateway.log({ repo, ref: 'main', limit: 1, offset: 1 });\n assertEqual([page.commits.map((c) => c.sha), page.hasMore], [[second.sha], true], 'second page');\n const atSha = await gateway.log({ repo, ref: second.sha });\n assertEqual(\n atSha.commits.map((c) => c.sha),\n [second.sha, first.sha],\n 'log from a commit id',\n );\n },\n ),\n behaviourCase(GROUP, 'log since keeps commits at or after the time', async ({ gateway, repo }) => {\n const first = await seedRepo(gateway, repo, SEED);\n const second = await writeFiles(gateway, repo, 'main', { 'n.md': '2' });\n const since = (date: string) => gateway.log({ repo, ref: 'main', since: date });\n assertEqual((await since('2000-01-01T00:00:00.000Z')).commits.length, 2, 'all after the distant past');\n assertEqual((await since('2999-01-01T00:00:00.000Z')).commits, [], 'none after the far future');\n const fromSecond = (await since(second.committer.date)).commits.map((c) => c.sha);\n assertTrue(fromSecond.includes(second.sha), 'a commit at exactly `since` is kept');\n assertTrue(first.committer.date <= second.committer.date, 'dates never go backwards');\n }),\n behaviourCase(\n GROUP,\n 'log of a merge lists both sides, children before parents',\n async ({ gateway, repo }) => {\n const seed = await seedRepo(gateway, repo, SEED);\n const side = await branchFrom(gateway, repo, 'main', 'side', { 's.md': 's' });\n const mainline = await writeFiles(gateway, repo, 'main', { 'm.md': 'm' });\n await gateway.syncBranch({ repo, from: 'side', into: 'main' });\n const shas = (await gateway.log({ repo, ref: 'main' })).commits.map((c) => c.sha);\n assertEqual(shas.length, 4, 'merge, both sides and the seed');\n assertEqual(shas.at(-1), seed.sha, 'root last');\n assertTrue(shas.includes(side.sha) && shas.includes(mainline.sha), 'both sides listed');\n },\n ),\n behaviourCase(\n GROUP,\n 'commitExists checks the repository and, optionally, a branch',\n async ({ gateway, repo }) => {\n const seed = await seedRepo(gateway, repo, SEED);\n const side = await branchFrom(gateway, repo, 'main', 'side', { 's.md': 's' });\n const exists = async (sha: string, branch?: string) =>\n (await gateway.commitExists({ repo, sha, ...(branch === undefined ? {} : { branch }) })).exists;\n assertEqual(await exists(side.sha), true, 'any commit');\n assertEqual(await exists(UNKNOWN_SHA), false, 'unknown commit');\n assertEqual(await exists(seed.sha, 'side'), true, 'ancestor is reachable');\n assertEqual(await exists(side.sha, 'main'), false, 'not on main');\n assertEqual(await exists(seed.sha, 'nope'), false, 'missing branch');\n },\n ),\n];\n"],"mappings":";;;;AAKA,MAAM,QAAQ;AACd,MAAM,OAAO;CAAE,QAAQ;CAAW,YAAY;CAAK,gBAAgB;CAAK,QAAQ;AAAU;AAC1F,MAAM,cAAc;;AAGpB,MAAa,YAAsC;CACjD,cACE,OACA,gEACA,OAAO,EAAE,SAAS,WAAW;EAC3B,MAAM,OAAO,MAAM,SAAS,SAAS,MAAM,IAAI;EAC/C,MAAM,OAAO,QAAQ,MAAM,QAAQ,SAAS;GAAE;GAAM,KAAK;GAAQ,MAAM;EAAO,CAAC,GAAG,aAAa;EAC/F,YACE,MACA;GACE,MAAM;GACN,QAAQ,KAAK;GACb,KAAK;GACL,MAAM;GACN,YAAY;GACZ,UAAU;GACV,SAAS;EACX,GACA,WACF;EACA,MAAM,OAAO,MAAM,QAAQ,SAAS;GAAE;GAAM,KAAK;GAAQ,MAAM;EAAO,CAAC;EACvE,YAAY,M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Q,IAAI,CAAC;EAC5E,MAAM,WAAW,MAAM,WAAW,SAAS,MAAM,QAAQ,EAAE,QAAQ,IAAI,CAAC;EACxE,MAAM,QAAQ,WAAW;GAAE;GAAM,MAAM;GAAQ,MAAM;EAAO,CAAC;EAC7D,MAAM,QAAQ,MAAM,QAAQ,IAAI;GAAE;GAAM,KAAK;EAAO,CAAC,EAAA,CAAG,QAAQ,KAAK,MAAM,EAAE,GAAG;EAChF,YAAY,KAAK,QAAQ,GAAG,gCAAgC;EAC5D,YAAY,KAAK,GAAG,EAAE,GAAG,KAAK,KAAK,WAAW;EAC9C,WAAW,KAAK,SAAS,KAAK,GAAG,KAAK,KAAK,SAAS,SAAS,GAAG,GAAG,mBAAmB;CACxF,CACF;CACA,cACE,OACA,gEACA,OAAO,EAAE,SAAS,WAAW;EAC3B,MAAM,OAAO,MAAM,SAAS,SAAS,MAAM,IAAI;EAC/C,MAAM,OAAO,MAAM,WAAW,SAAS,MAAM,QAAQ,QAAQ,EAAE,QAAQ,IAAI,CAAC;EAC5E,MAAM,SAAS,OAAO,KAAa,YAChC,MAAM,QAAQ,aAAa;GAAE;GAAM;GAAK,GAAI,WAAW,KAAA,IAAY,CAAC,IAAI,EAAE,OAAO;EAAG,CAAC,EAAA,CAAG;EAC3F,YAAY,MAAM,OAAO,KAAK,GAAG,GAAG,MAAM,YAAY;EACtD,YAAY,MAAM,OAAO,WAAW,GAAG,OAAO,gBAAgB;EAC9D,YAAY,MAAM,OAAO,KAAK,KAAK,MAAM,GAAG,MAAM,uBAAuB;EACzE,YAAY,MAAM,OAAO,KAAK,KAAK,MAAM,GAAG,OAAO,aAAa;EAChE,YAAY,MAAM,OAAO,KAAK,KAAK,MAAM,GAAG,OAAO,gBAAgB;CACrE,CACF;AACF"}
@@ -0,0 +1,4 @@
1
+ import { BehaviourCase } from "./behaviour-case.js";
2
+ /** Every syncBranch shape: up to date, fast-forward, merge, conflict, and its refusals. */
3
+ export declare const syncCases: readonly BehaviourCase[];
4
+ //# sourceMappingURL=sync-cases.d.ts.map
@@ -0,0 +1,205 @@
1
+ import { assertEqual, assertTrue, expectGatewayError, expectStatus } from "./assertions.js";
2
+ import { behaviourCase } from "./behaviour-case.js";
3
+ import { branchFrom, filePaths, readText, requireHead, seedRepo, writeFiles } from "./fixtures.js";
4
+ // src/behaviour/sync-cases.ts
5
+ const GROUP = "syncBranch";
6
+ const SEED = {
7
+ "shared.md": "base\n",
8
+ "other.md": "other\n",
9
+ "keep.md": "keep\n"
10
+ };
11
+ /** Diverges `main` and `staging` from a common seed with one commit each; returns both heads. */
12
+ async function diverge(gateway, repo, onMain, onStaging) {
13
+ const base = await seedRepo(gateway, repo, SEED);
14
+ const staging = await branchFrom(gateway, repo, "main", "staging", onStaging);
15
+ const main = await writeFiles(gateway, repo, "main", onMain);
16
+ return {
17
+ base: base.sha,
18
+ main: main.sha,
19
+ staging: staging.sha
20
+ };
21
+ }
22
+ /** Every syncBranch shape: up to date, fast-forward, merge, conflict, and its refusals. */
23
+ const syncCases = [
24
+ behaviourCase(GROUP, "up_to_date when into already contains from", async ({ gateway, repo }) => {
25
+ await seedRepo(gateway, repo, SEED);
26
+ const staging = await branchFrom(gateway, repo, "main", "staging", { "new.md": "n" });
27
+ const output = await gateway.syncBranch({
28
+ repo,
29
+ from: "main",
30
+ into: "staging"
31
+ });
32
+ assertEqual(output, {
33
+ status: "up_to_date",
34
+ head: staging.sha
35
+ }, "nothing to do");
36
+ }),
37
+ behaviourCase(GROUP, "fast_forward when into has no commits of its own", async ({ gateway, repo }) => {
38
+ const seed = await seedRepo(gateway, repo, SEED);
39
+ await gateway.promote({
40
+ repo,
41
+ from: "main",
42
+ into: "staging",
43
+ sha: seed.sha
44
+ });
45
+ const ahead = await writeFiles(gateway, repo, "main", { "new.md": "n" });
46
+ const output = await gateway.syncBranch({
47
+ repo,
48
+ from: "main",
49
+ into: "staging"
50
+ });
51
+ assertEqual(output, {
52
+ status: "fast_forward",
53
+ refUpdate: {
54
+ ref: "refs/heads/staging",
55
+ oldSha: seed.sha,
56
+ newSha: ahead.sha
57
+ }
58
+ }, "fast-forwarded");
59
+ assertEqual(await requireHead(gateway, repo, "staging"), ahead.sha, "staging moved");
60
+ }),
61
+ behaviourCase(GROUP, "merged: changes on different paths are combined", async ({ gateway, repo }) => {
62
+ const heads = await diverge(gateway, repo, {
63
+ "other.md": "main\n",
64
+ "m.md": "m"
65
+ }, {
66
+ "shared.md": "staging\n",
67
+ "keep.md": null
68
+ });
69
+ const merged = expectStatus(await gateway.syncBranch({
70
+ repo,
71
+ from: "main",
72
+ into: "staging"
73
+ }), "merged");
74
+ assertEqual(merged.commit.parents, [heads.staging, heads.main], "parents: into, then from");
75
+ assertEqual(merged.refUpdate, {
76
+ ref: "refs/heads/staging",
77
+ oldSha: heads.staging,
78
+ newSha: merged.commit.sha
79
+ }, "ref");
80
+ assertEqual(await filePaths(gateway, repo, "staging"), [
81
+ "m.md",
82
+ "other.md",
83
+ "shared.md"
84
+ ], "deletion kept, addition taken");
85
+ assertEqual(await readText(gateway, repo, "staging", "other.md"), "main\n", "from-side change taken");
86
+ assertEqual(await readText(gateway, repo, "staging", "shared.md"), "staging\n", "into-side change kept");
87
+ assertEqual(await requireHead(gateway, repo, "main"), heads.main, "from is never moved");
88
+ }),
89
+ behaviourCase(GROUP, "merged: the default message names both branches", async ({ gateway, repo }) => {
90
+ await diverge(gateway, repo, { "a.md": "a" }, { "b.md": "b" });
91
+ const merged = expectStatus(await gateway.syncBranch({
92
+ repo,
93
+ from: "main",
94
+ into: "staging"
95
+ }), "merged");
96
+ assertTrue(merged.commit.message.startsWith("Merge branch 'main' into staging"), "default message");
97
+ }),
98
+ behaviourCase(GROUP, "merged: an explicit author and message are used", async ({ gateway, repo }) => {
99
+ await diverge(gateway, repo, { "a.md": "a" }, { "b.md": "b" });
100
+ const output = await gateway.syncBranch({
101
+ repo,
102
+ from: "main",
103
+ into: "staging",
104
+ author: {
105
+ name: "Sync Bot",
106
+ email: "sync@example.com"
107
+ },
108
+ message: "Sync now"
109
+ });
110
+ const { commit } = expectStatus(output, "merged");
111
+ assertEqual([commit.author.name, commit.committer.email], ["Sync Bot", "sync@example.com"], "author");
112
+ assertTrue(commit.message.startsWith("Sync now"), "message");
113
+ }),
114
+ behaviourCase(GROUP, "merged: the same change on both sides is not a conflict", async ({ gateway, repo }) => {
115
+ await diverge(gateway, repo, {
116
+ "shared.md": "same\n",
117
+ "a.md": "a"
118
+ }, { "shared.md": "same\n" });
119
+ expectStatus(await gateway.syncBranch({
120
+ repo,
121
+ from: "main",
122
+ into: "staging"
123
+ }), "merged");
124
+ assertEqual(await readText(gateway, repo, "staging", "shared.md"), "same\n", "agreed content");
125
+ }),
126
+ behaviourCase(GROUP, "conflict: a path changed differently on both sides", async ({ gateway, repo }) => {
127
+ const heads = await diverge(gateway, repo, {
128
+ "shared.md": "main\n",
129
+ "a.md": "a"
130
+ }, { "shared.md": "staging\n" });
131
+ const output = await gateway.syncBranch({
132
+ repo,
133
+ from: "main",
134
+ into: "staging"
135
+ });
136
+ assertEqual(output, {
137
+ status: "conflict",
138
+ paths: ["shared.md"],
139
+ base: heads.base,
140
+ fromHead: heads.main,
141
+ intoHead: heads.staging
142
+ }, "conflict reported");
143
+ assertEqual(await requireHead(gateway, repo, "staging"), heads.staging, "into unchanged");
144
+ }),
145
+ behaviourCase(GROUP, "conflict: changed on one side, deleted on the other", async ({ gateway, repo }) => {
146
+ await diverge(gateway, repo, { "shared.md": null }, { "shared.md": "edited\n" });
147
+ const output = expectStatus(await gateway.syncBranch({
148
+ repo,
149
+ from: "main",
150
+ into: "staging"
151
+ }), "conflict");
152
+ assertEqual(output.paths, ["shared.md"], "modify/delete conflict");
153
+ }),
154
+ behaviourCase(GROUP, "conflict: a file on one side, a directory on the other", async ({ gateway, repo }) => {
155
+ await diverge(gateway, repo, { thing: "file" }, { "thing/inner.md": "dir" });
156
+ const output = expectStatus(await gateway.syncBranch({
157
+ repo,
158
+ from: "main",
159
+ into: "staging"
160
+ }), "conflict");
161
+ assertTrue(output.paths.includes("thing"), "file/directory conflict names the file");
162
+ }),
163
+ behaviourCase(GROUP, "syncing again after a merge is up_to_date", async ({ gateway, repo }) => {
164
+ await diverge(gateway, repo, { "a.md": "a" }, { "b.md": "b" });
165
+ const merged = expectStatus(await gateway.syncBranch({
166
+ repo,
167
+ from: "main",
168
+ into: "staging"
169
+ }), "merged");
170
+ const again = await gateway.syncBranch({
171
+ repo,
172
+ from: "main",
173
+ into: "staging"
174
+ });
175
+ assertEqual(again, {
176
+ status: "up_to_date",
177
+ head: merged.commit.sha
178
+ }, "idempotent");
179
+ }),
180
+ behaviourCase(GROUP, "a missing branch is ref_not_found", async ({ gateway, repo }) => {
181
+ await seedRepo(gateway, repo, SEED);
182
+ const error = await expectGatewayError(gateway.syncBranch({
183
+ repo,
184
+ from: "main",
185
+ into: "nope"
186
+ }), "ref_not_found");
187
+ assertEqual(error.details.ref, "nope", "names the branch");
188
+ await expectGatewayError(gateway.syncBranch({
189
+ repo,
190
+ from: "nope",
191
+ into: "main"
192
+ }), "ref_not_found");
193
+ }),
194
+ behaviourCase(GROUP, "from and into must differ", async ({ gateway, repo }) => {
195
+ await seedRepo(gateway, repo, SEED);
196
+ await expectGatewayError(gateway.syncBranch({
197
+ repo,
198
+ from: "main",
199
+ into: "main"
200
+ }), "invalid_input");
201
+ })
202
+ ];
203
+ export { syncCases };
204
+
205
+ //# sourceMappingURL=sync-cases.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sync-cases.js","names":[],"sources":["../../src/behaviour/sync-cases.ts"],"sourcesContent":["// SPDX-License-Identifier: Apache-2.0\nimport { assertEqual, assertTrue, expectGatewayError, expectStatus } from './assertions.ts';\nimport { behaviourCase, type BehaviourCase } from './behaviour-case.ts';\nimport { branchFrom, filePaths, readText, requireHead, seedRepo, writeFiles } from './fixtures.ts';\n\nconst GROUP = 'syncBranch';\nconst SEED = { 'shared.md': 'base\\n', 'other.md': 'other\\n', 'keep.md': 'keep\\n' };\n\n/** Diverges `main` and `staging` from a common seed with one commit each; returns both heads. */\nasync function diverge(\n gateway: Parameters<BehaviourCase['run']>[0]['gateway'],\n repo: string,\n onMain: Record<string, string | null>,\n onStaging: Record<string, string | null>,\n): Promise<{ base: string; main: string; staging: string }> {\n const base = await seedRepo(gateway, repo, SEED);\n const staging = await branchFrom(gateway, repo, 'main', 'staging', onStaging);\n const main = await writeFiles(gateway, repo, 'main', onMain);\n return { base: base.sha, main: main.sha, staging: staging.sha };\n}\n\n/** Every syncBranch shape: up to date, fast-forward, merge, conflict, and its refusals. */\nexport const syncCases: readonly BehaviourCase[] = [\n behaviourCase(GROUP, 'up_to_date when into already contains from', async ({ gateway, repo }) => {\n await seedRepo(gateway, repo, SEED);\n const staging = await branchFrom(gateway, repo, 'main', 'staging', { 'new.md': 'n' });\n const output = await gateway.syncBranch({ repo, from: 'main', into: 'staging' });\n assertEqual(output, { status: 'up_to_date', head: staging.sha }, 'nothing to do');\n }),\n behaviourCase(GROUP, 'fast_forward when into has no commits of its own', async ({ gateway, repo }) => {\n const seed = await seedRepo(gateway, repo, SEED);\n await gateway.promote({ repo, from: 'main', into: 'staging', sha: seed.sha });\n const ahead = await writeFiles(gateway, repo, 'main', { 'new.md': 'n' });\n const output = await gateway.syncBranch({ repo, from: 'main', into: 'staging' });\n assertEqual(\n output,\n {\n status: 'fast_forward',\n refUpdate: { ref: 'refs/heads/staging', oldSha: seed.sha, newSha: ahead.sha },\n },\n 'fast-forwarded',\n );\n assertEqual(await requireHead(gateway, repo, 'staging'), ahead.sha, 'staging moved');\n }),\n behaviourCase(GROUP, 'merged: changes on different paths are combined', async ({ gateway, repo }) => {\n const heads = await diverge(\n gateway,\n repo,\n { 'other.md': 'main\\n', 'm.md': 'm' },\n { 'shared.md': 'staging\\n', 'keep.md': null },\n );\n const merged = expectStatus(await gateway.syncBranch({ repo, from: 'main', into: 'staging' }), 'merged');\n assertEqual(merged.commit.parents, [heads.staging, heads.main], 'parents: into, then from');\n assertEqual(\n merged.refUpdate,\n { ref: 'refs/heads/staging', oldSha: heads.staging, newSha: merged.commit.sha },\n 'ref',\n );\n assertEqual(\n await filePaths(gateway, repo, 'staging'),\n ['m.md', 'other.md', 'shared.md'],\n 'deletion kept, addition taken',\n );\n assertEqual(await readText(gateway, repo, 'staging', 'other.md'), 'main\\n', 'from-side change taken');\n assertEqual(await readText(gateway, repo, 'staging', 'shared.md'), 'staging\\n', 'into-side change kept');\n assertEqual(await requireHead(gateway, repo, 'main'), heads.main, 'from is never moved');\n }),\n behaviourCase(GROUP, 'merged: the default message names both branches', async ({ gateway, repo }) => {\n await diverge(gateway, repo, { 'a.md': 'a' }, { 'b.md': 'b' });\n const merged = expectStatus(await gateway.syncBranch({ repo, from: 'main', into: 'staging' }), 'merged');\n assertTrue(merged.commit.message.startsWith(\"Merge branch 'main' into staging\"), 'default message');\n }),\n behaviourCase(GROUP, 'merged: an explicit author and message are used', async ({ gateway, repo }) => {\n await diverge(gateway, repo, { 'a.md': 'a' }, { 'b.md': 'b' });\n const author = { name: 'Sync Bot', email: 'sync@example.com' };\n const output = await gateway.syncBranch({\n repo,\n from: 'main',\n into: 'staging',\n author,\n message: 'Sync now',\n });\n const { commit } = expectStatus(output, 'merged');\n assertEqual([commit.author.name, commit.committer.email], ['Sync Bot', 'sync@example.com'], 'author');\n assertTrue(commit.message.startsWith('Sync now'), 'message');\n }),\n behaviourCase(\n GROUP,\n 'merged: the same change on both sides is not a conflict',\n async ({ gateway, repo }) => {\n await diverge(gateway, repo, { 'shared.md': 'same\\n', 'a.md': 'a' }, { 'shared.md': 'same\\n' });\n expectStatus(await gateway.syncBranch({ repo, from: 'main', into: 'staging' }), 'merged');\n assertEqual(await readText(gateway, repo, 'staging', 'shared.md'), 'same\\n', 'agreed content');\n },\n ),\n behaviourCase(GROUP, 'conflict: a path changed differently on both sides', async ({ gateway, repo }) => {\n const heads = await diverge(\n gateway,\n repo,\n { 'shared.md': 'main\\n', 'a.md': 'a' },\n { 'shared.md': 'staging\\n' },\n );\n const output = await gateway.syncBranch({ repo, from: 'main', into: 'staging' });\n assertEqual(\n output,\n {\n status: 'conflict',\n paths: ['shared.md'],\n base: heads.base,\n fromHead: heads.main,\n intoHead: heads.staging,\n },\n 'conflict reported',\n );\n assertEqual(await requireHead(gateway, repo, 'staging'), heads.staging, 'into unchanged');\n }),\n behaviourCase(GROUP, 'conflict: changed on one side, deleted on the other', async ({ gateway, repo }) => {\n await diverge(gateway, repo, { 'shared.md': null }, { 'shared.md': 'edited\\n' });\n const output = expectStatus(\n await gateway.syncBranch({ repo, from: 'main', into: 'staging' }),\n 'conflict',\n );\n assertEqual(output.paths, ['shared.md'], 'modify/delete conflict');\n }),\n behaviourCase(\n GROUP,\n 'conflict: a file on one side, a directory on the other',\n async ({ gateway, repo }) => {\n await diverge(gateway, repo, { thing: 'file' }, { 'thing/inner.md': 'dir' });\n const output = expectStatus(\n await gateway.syncBranch({ repo, from: 'main', into: 'staging' }),\n 'conflict',\n );\n assertTrue(output.paths.includes('thing'), 'file/directory conflict names the file');\n },\n ),\n behaviourCase(GROUP, 'syncing again after a merge is up_to_date', async ({ gateway, repo }) => {\n await diverge(gateway, repo, { 'a.md': 'a' }, { 'b.md': 'b' });\n const merged = expectStatus(await gateway.syncBranch({ repo, from: 'main', into: 'staging' }), 'merged');\n const again = await gateway.syncBranch({ repo, from: 'main', into: 'staging' });\n assertEqual(again, { status: 'up_to_date', head: merged.commit.sha }, 'idempotent');\n }),\n behaviourCase(GROUP, 'a missing branch is ref_not_found', async ({ gateway, repo }) => {\n await seedRepo(gateway, repo, SEED);\n const error = await expectGatewayError(\n gateway.syncBranch({ repo, from: 'main', into: 'nope' }),\n 'ref_not_found',\n );\n assertEqual(error.details.ref, 'nope', 'names the branch');\n await expectGatewayError(gateway.syncBranch({ repo, from: 'nope', into: 'main' }), 'ref_not_found');\n }),\n behaviourCase(GROUP, 'from and into must differ', async ({ gateway, repo }) => {\n await seedRepo(gateway, repo, SEED);\n await expectGatewayError(gateway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AM,SAAS,SAAS,MAAM,IAAI;EAClC,MAAM,mBAAmB,QAAQ,WAAW;GAAE;GAAM,MAAM;GAAQ,MAAM;EAAO,CAAC,GAAG,eAAe;CACpG,CAAC;AACH"}
@@ -0,0 +1,10 @@
1
+ /** A source of the current time. */
2
+ type Clock = () => Date;
3
+ /**
4
+ * A deterministic clock for tests: the first call returns `start`, each later call `stepMs`
5
+ * milliseconds after the one before. With it, the reference implementation's ids are the same on
6
+ * every run.
7
+ */
8
+ declare function steppingClock(start?: string, stepMs?: number): Clock;
9
+ export { steppingClock as n, Clock as t };
10
+ //# sourceMappingURL=clock-B3MlpmVY.d.ts.map
@@ -0,0 +1,23 @@
1
+ import { z } from "zod";
2
+ /** A commit as stored in a repository. */
3
+ declare const Commit: z.ZodObject<{
4
+ sha: z.ZodString;
5
+ tree: z.ZodString;
6
+ parents: z.ZodArray<z.ZodString>;
7
+ author: z.ZodObject<{
8
+ name: z.ZodString;
9
+ email: z.ZodEmail;
10
+ date: z.ZodISODateTime;
11
+ }, z.core.$strict>;
12
+ committer: z.ZodObject<{
13
+ name: z.ZodString;
14
+ email: z.ZodEmail;
15
+ date: z.ZodISODateTime;
16
+ }, z.core.$strict>;
17
+ message: z.ZodString;
18
+ idempotencyKey: z.ZodNullable<z.ZodString>;
19
+ }, z.core.$strict>;
20
+ /** A stored commit, inferred from {@link Commit}. */
21
+ type Commit = z.infer<typeof Commit>;
22
+ export { Commit as t };
23
+ //# sourceMappingURL=commit-BEZmeAOl.d.ts.map
@@ -0,0 +1,18 @@
1
+ /** One file of the in-memory model: its bytes, executable bit and blob id. */
2
+ interface StoredFile {
3
+ readonly bytes: Uint8Array;
4
+ readonly executable: boolean;
5
+ readonly sha: string;
6
+ }
7
+ /** A snapshot of a repository: every file by full path. Directories are implied by paths. */
8
+ type FileMap = ReadonlyMap<string, StoredFile>;
9
+ /** Every proper parent directory of a path, shallowest first: `a/b/c` → `a`, `a/b`. */
10
+ declare function parentDirectories(path: string): string[];
11
+ /** True when some file lies beneath `path`, i.e. it is a directory of the snapshot. */
12
+ declare function isDirectory(files: FileMap, path: string): boolean;
13
+ /** The shallowest parent of `path` that is a file, or undefined when none is. */
14
+ declare function fileParent(files: FileMap, path: string): string | undefined;
15
+ /** True when two stored files have the same content and mode. */
16
+ declare function sameFile(a: StoredFile | undefined, b: StoredFile | undefined): boolean;
17
+ export { parentDirectories as a, isDirectory as i, StoredFile as n, sameFile as o, fileParent as r, FileMap as t };
18
+ //# sourceMappingURL=file-map-CxUveLWz.d.ts.map
@@ -0,0 +1,39 @@
1
+ import { z } from "zod";
2
+ /** How far back `commit()` looks for a commit carrying the same idempotency key. */
3
+ declare const IdempotencyConfig: z.ZodObject<{
4
+ maxCommits: z.ZodDefault<z.ZodInt>;
5
+ maxAgeSeconds: z.ZodDefault<z.ZodInt>;
6
+ }, z.core.$strict>;
7
+ /** An idempotency window, inferred from {@link IdempotencyConfig}. */
8
+ type IdempotencyConfig = z.infer<typeof IdempotencyConfig>;
9
+ /** An automatic sync run after every push to a branch. */
10
+ declare const SyncRule: z.ZodObject<{
11
+ from: z.ZodString;
12
+ into: z.ZodString;
13
+ }, z.core.$strict>;
14
+ /** An automatic sync rule, inferred from {@link SyncRule}. */
15
+ type SyncRule = z.infer<typeof SyncRule>;
16
+ /** Settings shared by every gateway implementation of the RPC contract. */
17
+ declare const GatewayConfig: z.ZodObject<{
18
+ publicBaseUrl: z.ZodDefault<z.ZodURL>;
19
+ serviceIdentity: z.ZodDefault<z.ZodObject<{
20
+ name: z.ZodString;
21
+ email: z.ZodEmail;
22
+ }, z.core.$strict>>;
23
+ idempotency: z.ZodDefault<z.ZodObject<{
24
+ maxCommits: z.ZodDefault<z.ZodInt>;
25
+ maxAgeSeconds: z.ZodDefault<z.ZodInt>;
26
+ }, z.core.$strict>>;
27
+ inlineRetries: z.ZodDefault<z.ZodInt>;
28
+ authCacheSeconds: z.ZodDefault<z.ZodInt>;
29
+ syncRules: z.ZodDefault<z.ZodArray<z.ZodObject<{
30
+ from: z.ZodString;
31
+ into: z.ZodString;
32
+ }, z.core.$strict>>>;
33
+ }, z.core.$strict>;
34
+ /** A gateway configuration as written (defaults optional). */
35
+ type GatewayConfigInput = z.input<typeof GatewayConfig>;
36
+ /** A complete gateway configuration, inferred from {@link GatewayConfig}. */
37
+ type GatewayConfig = z.output<typeof GatewayConfig>;
38
+ export { SyncRule as i, GatewayConfigInput as n, IdempotencyConfig as r, GatewayConfig as t };
39
+ //# sourceMappingURL=gateway-config-oVsdTEeK.d.ts.map