pr-merge-queue 0.0.0-stage → 0.0.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 (331) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +125 -2
  3. package/dist/claim-pr/claim-pr.d.mts +45 -0
  4. package/dist/claim-pr/claim-pr.d.mts.map +1 -0
  5. package/dist/claim-pr/claim-pr.mjs +217 -0
  6. package/dist/claim-pr/claim-pr.mjs.map +1 -0
  7. package/dist/claim-pr/index.d.mts +2 -0
  8. package/dist/claim-pr/index.d.mts.map +1 -0
  9. package/dist/claim-pr/index.mjs +2 -0
  10. package/dist/claim-pr/index.mjs.map +1 -0
  11. package/dist/cmd/claim-pr.d.mts +3 -0
  12. package/dist/cmd/claim-pr.d.mts.map +1 -0
  13. package/dist/cmd/claim-pr.mjs +20 -0
  14. package/dist/cmd/claim-pr.mjs.map +1 -0
  15. package/dist/cmd/open-pr.d.mts +3 -0
  16. package/dist/cmd/open-pr.d.mts.map +1 -0
  17. package/dist/cmd/open-pr.mjs +20 -0
  18. package/dist/cmd/open-pr.mjs.map +1 -0
  19. package/dist/cmd/pr-report.d.mts +3 -0
  20. package/dist/cmd/pr-report.d.mts.map +1 -0
  21. package/dist/cmd/pr-report.mjs +20 -0
  22. package/dist/cmd/pr-report.mjs.map +1 -0
  23. package/dist/cmd/push-fixed-pr.d.mts +3 -0
  24. package/dist/cmd/push-fixed-pr.d.mts.map +1 -0
  25. package/dist/cmd/push-fixed-pr.mjs +20 -0
  26. package/dist/cmd/push-fixed-pr.mjs.map +1 -0
  27. package/dist/cmd/report-unowned-prs.d.mts +3 -0
  28. package/dist/cmd/report-unowned-prs.d.mts.map +1 -0
  29. package/dist/cmd/report-unowned-prs.mjs +20 -0
  30. package/dist/cmd/report-unowned-prs.mjs.map +1 -0
  31. package/dist/cmd/unblock-prs.d.mts +3 -0
  32. package/dist/cmd/unblock-prs.d.mts.map +1 -0
  33. package/dist/cmd/unblock-prs.mjs +19 -0
  34. package/dist/cmd/unblock-prs.mjs.map +1 -0
  35. package/dist/entry-point.d.mts +3 -0
  36. package/dist/entry-point.d.mts.map +1 -0
  37. package/dist/entry-point.mjs +3 -0
  38. package/dist/entry-point.mjs.map +1 -0
  39. package/dist/lib/cli-args.d.mts +27 -0
  40. package/dist/lib/cli-args.d.mts.map +1 -0
  41. package/dist/lib/cli-args.mjs +55 -0
  42. package/dist/lib/cli-args.mjs.map +1 -0
  43. package/dist/lib/github-api.d.mts +153 -0
  44. package/dist/lib/github-api.d.mts.map +1 -0
  45. package/dist/lib/github-api.mjs +291 -0
  46. package/dist/lib/github-api.mjs.map +1 -0
  47. package/dist/lib/index.d.mts +7 -0
  48. package/dist/lib/index.d.mts.map +1 -0
  49. package/dist/lib/index.mjs +7 -0
  50. package/dist/lib/index.mjs.map +1 -0
  51. package/dist/lib/json.d.mts +12 -0
  52. package/dist/lib/json.d.mts.map +1 -0
  53. package/dist/lib/json.mjs +28 -0
  54. package/dist/lib/json.mjs.map +1 -0
  55. package/dist/lib/log.d.mts +10 -0
  56. package/dist/lib/log.d.mts.map +1 -0
  57. package/dist/lib/log.mjs +13 -0
  58. package/dist/lib/log.mjs.map +1 -0
  59. package/dist/lib/shell.d.mts +18 -0
  60. package/dist/lib/shell.d.mts.map +1 -0
  61. package/dist/lib/shell.mjs +42 -0
  62. package/dist/lib/shell.mjs.map +1 -0
  63. package/dist/lib/time.d.mts +17 -0
  64. package/dist/lib/time.d.mts.map +1 -0
  65. package/dist/lib/time.mjs +35 -0
  66. package/dist/lib/time.mjs.map +1 -0
  67. package/dist/open-pr/github.d.mts +72 -0
  68. package/dist/open-pr/github.d.mts.map +1 -0
  69. package/dist/open-pr/github.mjs +249 -0
  70. package/dist/open-pr/github.mjs.map +1 -0
  71. package/dist/open-pr/index.d.mts +6 -0
  72. package/dist/open-pr/index.d.mts.map +1 -0
  73. package/dist/open-pr/index.mjs +6 -0
  74. package/dist/open-pr/index.mjs.map +1 -0
  75. package/dist/open-pr/main.d.mts +36 -0
  76. package/dist/open-pr/main.d.mts.map +1 -0
  77. package/dist/open-pr/main.mjs +204 -0
  78. package/dist/open-pr/main.mjs.map +1 -0
  79. package/dist/open-pr/options.d.mts +20 -0
  80. package/dist/open-pr/options.d.mts.map +1 -0
  81. package/dist/open-pr/options.mjs +66 -0
  82. package/dist/open-pr/options.mjs.map +1 -0
  83. package/dist/open-pr/steps.d.mts +23 -0
  84. package/dist/open-pr/steps.d.mts.map +1 -0
  85. package/dist/open-pr/steps.mjs +38 -0
  86. package/dist/open-pr/steps.mjs.map +1 -0
  87. package/dist/open-pr/types.d.mts +179 -0
  88. package/dist/open-pr/types.d.mts.map +1 -0
  89. package/dist/open-pr/types.mjs +20 -0
  90. package/dist/open-pr/types.mjs.map +1 -0
  91. package/dist/pr-report/github.d.mts +59 -0
  92. package/dist/pr-report/github.d.mts.map +1 -0
  93. package/dist/pr-report/github.mjs +561 -0
  94. package/dist/pr-report/github.mjs.map +1 -0
  95. package/dist/pr-report/index.d.mts +8 -0
  96. package/dist/pr-report/index.d.mts.map +1 -0
  97. package/dist/pr-report/index.mjs +8 -0
  98. package/dist/pr-report/index.mjs.map +1 -0
  99. package/dist/pr-report/linked-issues.d.mts +15 -0
  100. package/dist/pr-report/linked-issues.d.mts.map +1 -0
  101. package/dist/pr-report/linked-issues.mjs +39 -0
  102. package/dist/pr-report/linked-issues.mjs.map +1 -0
  103. package/dist/pr-report/main.d.mts +42 -0
  104. package/dist/pr-report/main.d.mts.map +1 -0
  105. package/dist/pr-report/main.mjs +163 -0
  106. package/dist/pr-report/main.mjs.map +1 -0
  107. package/dist/pr-report/options.d.mts +36 -0
  108. package/dist/pr-report/options.d.mts.map +1 -0
  109. package/dist/pr-report/options.mjs +90 -0
  110. package/dist/pr-report/options.mjs.map +1 -0
  111. package/dist/pr-report/queue.d.mts +28 -0
  112. package/dist/pr-report/queue.d.mts.map +1 -0
  113. package/dist/pr-report/queue.mjs +74 -0
  114. package/dist/pr-report/queue.mjs.map +1 -0
  115. package/dist/pr-report/render.d.mts +14 -0
  116. package/dist/pr-report/render.d.mts.map +1 -0
  117. package/dist/pr-report/render.mjs +318 -0
  118. package/dist/pr-report/render.mjs.map +1 -0
  119. package/dist/pr-report/repo-settings.d.mts +12 -0
  120. package/dist/pr-report/repo-settings.d.mts.map +1 -0
  121. package/dist/pr-report/repo-settings.mjs +22 -0
  122. package/dist/pr-report/repo-settings.mjs.map +1 -0
  123. package/dist/push-fixed-pr/index.d.mts +2 -0
  124. package/dist/push-fixed-pr/index.d.mts.map +1 -0
  125. package/dist/push-fixed-pr/index.mjs +2 -0
  126. package/dist/push-fixed-pr/index.mjs.map +1 -0
  127. package/dist/push-fixed-pr/push-fixed-pr.d.mts +54 -0
  128. package/dist/push-fixed-pr/push-fixed-pr.d.mts.map +1 -0
  129. package/dist/push-fixed-pr/push-fixed-pr.mjs +172 -0
  130. package/dist/push-fixed-pr/push-fixed-pr.mjs.map +1 -0
  131. package/dist/report-unowned-prs/index.d.mts +2 -0
  132. package/dist/report-unowned-prs/index.d.mts.map +1 -0
  133. package/dist/report-unowned-prs/index.mjs +2 -0
  134. package/dist/report-unowned-prs/index.mjs.map +1 -0
  135. package/dist/report-unowned-prs/report-unowned-prs.d.mts +49 -0
  136. package/dist/report-unowned-prs/report-unowned-prs.d.mts.map +1 -0
  137. package/dist/report-unowned-prs/report-unowned-prs.mjs +127 -0
  138. package/dist/report-unowned-prs/report-unowned-prs.mjs.map +1 -0
  139. package/dist/tsconfig.json +1 -0
  140. package/dist/unblock-prs/auto-fix.d.mts +45 -0
  141. package/dist/unblock-prs/auto-fix.d.mts.map +1 -0
  142. package/dist/unblock-prs/auto-fix.mjs +207 -0
  143. package/dist/unblock-prs/auto-fix.mjs.map +1 -0
  144. package/dist/unblock-prs/checks.d.mts +307 -0
  145. package/dist/unblock-prs/checks.d.mts.map +1 -0
  146. package/dist/unblock-prs/checks.mjs +372 -0
  147. package/dist/unblock-prs/checks.mjs.map +1 -0
  148. package/dist/unblock-prs/claims.d.mts +21 -0
  149. package/dist/unblock-prs/claims.d.mts.map +1 -0
  150. package/dist/unblock-prs/claims.mjs +23 -0
  151. package/dist/unblock-prs/claims.mjs.map +1 -0
  152. package/dist/unblock-prs/config.d.mts +487 -0
  153. package/dist/unblock-prs/config.d.mts.map +1 -0
  154. package/dist/unblock-prs/config.mjs +119 -0
  155. package/dist/unblock-prs/config.mjs.map +1 -0
  156. package/dist/unblock-prs/constants.d.mts +28 -0
  157. package/dist/unblock-prs/constants.d.mts.map +1 -0
  158. package/dist/unblock-prs/constants.mjs +28 -0
  159. package/dist/unblock-prs/constants.mjs.map +1 -0
  160. package/dist/unblock-prs/demotions.d.mts +42 -0
  161. package/dist/unblock-prs/demotions.d.mts.map +1 -0
  162. package/dist/unblock-prs/demotions.mjs +50 -0
  163. package/dist/unblock-prs/demotions.mjs.map +1 -0
  164. package/dist/unblock-prs/github.d.mts +739 -0
  165. package/dist/unblock-prs/github.d.mts.map +1 -0
  166. package/dist/unblock-prs/github.mjs +626 -0
  167. package/dist/unblock-prs/github.mjs.map +1 -0
  168. package/dist/unblock-prs/index.d.mts +25 -0
  169. package/dist/unblock-prs/index.d.mts.map +1 -0
  170. package/dist/unblock-prs/index.mjs +25 -0
  171. package/dist/unblock-prs/index.mjs.map +1 -0
  172. package/dist/unblock-prs/labels.d.mts +49 -0
  173. package/dist/unblock-prs/labels.d.mts.map +1 -0
  174. package/dist/unblock-prs/labels.mjs +49 -0
  175. package/dist/unblock-prs/labels.mjs.map +1 -0
  176. package/dist/unblock-prs/main.d.mts +179 -0
  177. package/dist/unblock-prs/main.d.mts.map +1 -0
  178. package/dist/unblock-prs/main.mjs +640 -0
  179. package/dist/unblock-prs/main.mjs.map +1 -0
  180. package/dist/unblock-prs/merge-after.d.mts +46 -0
  181. package/dist/unblock-prs/merge-after.d.mts.map +1 -0
  182. package/dist/unblock-prs/merge-after.mjs +65 -0
  183. package/dist/unblock-prs/merge-after.mjs.map +1 -0
  184. package/dist/unblock-prs/options.d.mts +35 -0
  185. package/dist/unblock-prs/options.d.mts.map +1 -0
  186. package/dist/unblock-prs/options.mjs +88 -0
  187. package/dist/unblock-prs/options.mjs.map +1 -0
  188. package/dist/unblock-prs/owner.d.mts +32 -0
  189. package/dist/unblock-prs/owner.d.mts.map +1 -0
  190. package/dist/unblock-prs/owner.mjs +63 -0
  191. package/dist/unblock-prs/owner.mjs.map +1 -0
  192. package/dist/unblock-prs/quiet.d.mts +21 -0
  193. package/dist/unblock-prs/quiet.d.mts.map +1 -0
  194. package/dist/unblock-prs/quiet.mjs +42 -0
  195. package/dist/unblock-prs/quiet.mjs.map +1 -0
  196. package/dist/unblock-prs/rebase.d.mts +120 -0
  197. package/dist/unblock-prs/rebase.d.mts.map +1 -0
  198. package/dist/unblock-prs/rebase.mjs +576 -0
  199. package/dist/unblock-prs/rebase.mjs.map +1 -0
  200. package/dist/unblock-prs/release.d.mts +62 -0
  201. package/dist/unblock-prs/release.d.mts.map +1 -0
  202. package/dist/unblock-prs/release.mjs +94 -0
  203. package/dist/unblock-prs/release.mjs.map +1 -0
  204. package/dist/unblock-prs/set-aside-comment.d.mts +20 -0
  205. package/dist/unblock-prs/set-aside-comment.d.mts.map +1 -0
  206. package/dist/unblock-prs/set-aside-comment.mjs +93 -0
  207. package/dist/unblock-prs/set-aside-comment.mjs.map +1 -0
  208. package/dist/unblock-prs/set-aside-detail.d.mts +41 -0
  209. package/dist/unblock-prs/set-aside-detail.d.mts.map +1 -0
  210. package/dist/unblock-prs/set-aside-detail.mjs +56 -0
  211. package/dist/unblock-prs/set-aside-detail.mjs.map +1 -0
  212. package/dist/unblock-prs/skips.d.mts +85 -0
  213. package/dist/unblock-prs/skips.d.mts.map +1 -0
  214. package/dist/unblock-prs/skips.mjs +141 -0
  215. package/dist/unblock-prs/skips.mjs.map +1 -0
  216. package/dist/unblock-prs/stack.d.mts +98 -0
  217. package/dist/unblock-prs/stack.d.mts.map +1 -0
  218. package/dist/unblock-prs/stack.mjs +141 -0
  219. package/dist/unblock-prs/stack.mjs.map +1 -0
  220. package/dist/unblock-prs/triage.d.mts +28 -0
  221. package/dist/unblock-prs/triage.d.mts.map +1 -0
  222. package/dist/unblock-prs/triage.mjs +396 -0
  223. package/dist/unblock-prs/triage.mjs.map +1 -0
  224. package/dist/unblock-prs/types.d.mts +793 -0
  225. package/dist/unblock-prs/types.d.mts.map +1 -0
  226. package/dist/unblock-prs/types.mjs +26 -0
  227. package/dist/unblock-prs/types.mjs.map +1 -0
  228. package/dist/unblock-prs/util.d.mts +23 -0
  229. package/dist/unblock-prs/util.d.mts.map +1 -0
  230. package/dist/unblock-prs/util.mjs +60 -0
  231. package/dist/unblock-prs/util.mjs.map +1 -0
  232. package/dist/unblock-prs/version-pr.d.mts +57 -0
  233. package/dist/unblock-prs/version-pr.d.mts.map +1 -0
  234. package/dist/unblock-prs/version-pr.mjs +79 -0
  235. package/dist/unblock-prs/version-pr.mjs.map +1 -0
  236. package/dist/unblock-prs/watch.d.mts +17 -0
  237. package/dist/unblock-prs/watch.d.mts.map +1 -0
  238. package/dist/unblock-prs/watch.mjs +128 -0
  239. package/dist/unblock-prs/watch.mjs.map +1 -0
  240. package/package.json +118 -3
  241. package/src/claim-pr/claim-pr.mts +380 -0
  242. package/src/claim-pr/claim-pr.test.mts +176 -0
  243. package/src/claim-pr/index.mts +1 -0
  244. package/src/cmd/claim-pr.mts +32 -0
  245. package/src/cmd/open-pr.mts +28 -0
  246. package/src/cmd/pr-report.mts +28 -0
  247. package/src/cmd/push-fixed-pr.mts +36 -0
  248. package/src/cmd/report-unowned-prs.mts +37 -0
  249. package/src/cmd/unblock-prs.mts +24 -0
  250. package/src/entry-point.mts +3 -0
  251. package/src/lib/cli-args.mts +86 -0
  252. package/src/lib/cli-args.test.mts +92 -0
  253. package/src/lib/github-api.mts +463 -0
  254. package/src/lib/github-api.test.mts +40 -0
  255. package/src/lib/index.mts +6 -0
  256. package/src/lib/json.mts +43 -0
  257. package/src/lib/json.test.mts +34 -0
  258. package/src/lib/log.mts +19 -0
  259. package/src/lib/log.test.mts +45 -0
  260. package/src/lib/shell.mts +52 -0
  261. package/src/lib/time.mts +49 -0
  262. package/src/open-pr/README.md +237 -0
  263. package/src/open-pr/github.mts +444 -0
  264. package/src/open-pr/index.mts +5 -0
  265. package/src/open-pr/main.mts +327 -0
  266. package/src/open-pr/options.mts +101 -0
  267. package/src/open-pr/options.test.mts +67 -0
  268. package/src/open-pr/steps.mts +57 -0
  269. package/src/open-pr/steps.test.mts +59 -0
  270. package/src/open-pr/types.mts +42 -0
  271. package/src/pr-report/README.md +244 -0
  272. package/src/pr-report/github.mts +911 -0
  273. package/src/pr-report/index.mts +7 -0
  274. package/src/pr-report/linked-issues.mts +51 -0
  275. package/src/pr-report/linked-issues.test.mts +65 -0
  276. package/src/pr-report/main.mts +257 -0
  277. package/src/pr-report/options.mts +140 -0
  278. package/src/pr-report/queue.mts +125 -0
  279. package/src/pr-report/render.mts +428 -0
  280. package/src/pr-report/render.test.mts +379 -0
  281. package/src/pr-report/repo-settings.mts +34 -0
  282. package/src/push-fixed-pr/index.mts +1 -0
  283. package/src/push-fixed-pr/push-fixed-pr.mts +276 -0
  284. package/src/push-fixed-pr/push-fixed-pr.test.mts +228 -0
  285. package/src/report-unowned-prs/index.mts +1 -0
  286. package/src/report-unowned-prs/report-unowned-prs.mts +190 -0
  287. package/src/report-unowned-prs/report-unowned-prs.test.mts +87 -0
  288. package/src/unblock-prs/README.md +1616 -0
  289. package/src/unblock-prs/auto-fix.mts +334 -0
  290. package/src/unblock-prs/auto-fix.test.mts +159 -0
  291. package/src/unblock-prs/checks.mts +538 -0
  292. package/src/unblock-prs/checks.test.mts +507 -0
  293. package/src/unblock-prs/claims.mts +33 -0
  294. package/src/unblock-prs/claims.test.mts +64 -0
  295. package/src/unblock-prs/config.mts +187 -0
  296. package/src/unblock-prs/config.schema.json +71 -0
  297. package/src/unblock-prs/config.test.mts +139 -0
  298. package/src/unblock-prs/constants.mts +33 -0
  299. package/src/unblock-prs/demotions.mts +73 -0
  300. package/src/unblock-prs/demotions.test.mts +100 -0
  301. package/src/unblock-prs/github.mts +1042 -0
  302. package/src/unblock-prs/github.test.mts +84 -0
  303. package/src/unblock-prs/index.mts +24 -0
  304. package/src/unblock-prs/labels.mts +70 -0
  305. package/src/unblock-prs/main.mts +1051 -0
  306. package/src/unblock-prs/merge-after.mts +117 -0
  307. package/src/unblock-prs/merge-after.test.mts +120 -0
  308. package/src/unblock-prs/options.mts +157 -0
  309. package/src/unblock-prs/owner.mts +91 -0
  310. package/src/unblock-prs/owner.test.mts +114 -0
  311. package/src/unblock-prs/quiet.mts +62 -0
  312. package/src/unblock-prs/quiet.test.mts +175 -0
  313. package/src/unblock-prs/rebase.mts +962 -0
  314. package/src/unblock-prs/release.mts +149 -0
  315. package/src/unblock-prs/release.test.mts +209 -0
  316. package/src/unblock-prs/set-aside-comment.mts +143 -0
  317. package/src/unblock-prs/set-aside-comment.test.mts +148 -0
  318. package/src/unblock-prs/set-aside-detail.mts +82 -0
  319. package/src/unblock-prs/set-aside-detail.test.mts +131 -0
  320. package/src/unblock-prs/skips.mts +215 -0
  321. package/src/unblock-prs/skips.test.mts +280 -0
  322. package/src/unblock-prs/stack.mts +220 -0
  323. package/src/unblock-prs/stack.test.mts +449 -0
  324. package/src/unblock-prs/triage.mts +669 -0
  325. package/src/unblock-prs/triage.test.mts +100 -0
  326. package/src/unblock-prs/types.mts +358 -0
  327. package/src/unblock-prs/util.mts +78 -0
  328. package/src/unblock-prs/util.test.mts +26 -0
  329. package/src/unblock-prs/version-pr.mts +112 -0
  330. package/src/unblock-prs/version-pr.test.mts +78 -0
  331. package/src/unblock-prs/watch.mts +219 -0
@@ -0,0 +1,119 @@
1
+
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+ import * as fs from 'node:fs/promises';
15
+ import * as path from 'node:path';
16
+ import { Arr, Result } from 'ts-data-forge';
17
+ import * as t from 'ts-fortress';
18
+ import { readJsonFile, repoRoot } from '../lib/index.mjs';
19
+
20
+ export const CONFIG_PATH = '.github/unblock-prs.json';
21
+
22
+
23
+
24
+
25
+
26
+ export const readConfig = async (root) => {
27
+ const file = path.join(root ?? (await repoRoot()), CONFIG_PATH);
28
+ if (!(await exists(file))) {
29
+ return Result.ok(undefined);
30
+ }
31
+ const read = await readJsonFile(file, ConfigFileSchema);
32
+ return Result.isErr(read) ? read : configOf(read.value, file);
33
+ };
34
+
35
+ export const configOf = (file, source) => {
36
+ if (file.autoFix === undefined) {
37
+ return Result.ok({ autoFix: undefined });
38
+ }
39
+ const { ignore, before, prepare, fixers, after } = file.autoFix;
40
+ const patterns = [
41
+ ...ignore.map((pattern, i) => [`autoFix.ignore[${i}]`, pattern]),
42
+ ...prepare.map(({ context }, i) => [`autoFix.prepare[${i}].context`, context]),
43
+ ...fixers.map(({ context }, i) => [`autoFix.fixers[${i}].context`, context]),
44
+ ];
45
+ const invalid = patterns
46
+ .map(([where, pattern]) => [where, compile(pattern)])
47
+ .filter(([, compiled]) => Result.isErr(compiled))
48
+ .map(([where]) => where);
49
+ if (Arr.isNonEmpty(invalid)) {
50
+ return Result.err(`${source}: not a regular expression: ${invalid.join(', ')}`);
51
+ }
52
+ return Result.ok({
53
+ autoFix: {
54
+ ignore: ignore.map(compileValid),
55
+ before,
56
+ prepare: prepare.map(({ context, run }) => ({
57
+ context: compileValid(context),
58
+ run,
59
+ })),
60
+ fixers: fixers.map(({ context, run, stage }) => ({
61
+ context: compileValid(context),
62
+ run,
63
+ stage,
64
+ })),
65
+ after,
66
+ },
67
+ });
68
+ };
69
+
70
+ const regex = () => t.annotate(t.string(), { format: 'regex' });
71
+
72
+
73
+
74
+
75
+
76
+ export const ConfigFileSchema = t.annotate(t.strictRecord({
77
+ $schema: t.optional(t.string()),
78
+ autoFix: t.optional(t.annotate(t.strictRecord({
79
+ ignore: t.annotate(t.array(regex()), {
80
+ description: 'Regular expressions for failed contexts that are only the echo of another, such as an aggregate job, and are not read.',
81
+ }),
82
+ before: t.annotate(t.array(t.string()), {
83
+ description: 'Commands run first, always: what CI does before any job (an install).',
84
+ }),
85
+ prepare: t.annotate(t.array(t.strictRecord({ context: regex(), run: t.string() })), {
86
+ description: 'Commands run after `before` when a context being fixed matches `context`, each command once: what CI gives some jobs and not others (a build).',
87
+ }),
88
+ fixers: t.annotate(t.array(t.strictRecord({
89
+ context: t.annotate(regex(), {
90
+ description: "A regular expression for the failed context's name.",
91
+ }),
92
+ run: t.annotate(t.string(), {
93
+ description: "The command, where $1 to $9 are the context's capture groups, shell-quoted.",
94
+ }),
95
+ stage: t.annotate(t.number(), {
96
+ description: 'Lower stages run first, and within a stage by command.',
97
+ }),
98
+ })), {
99
+ description: 'Every failed context not ignored has to match one of these, the first that matches deciding, or nothing is fixed.',
100
+ }),
101
+ after: t.annotate(t.array(t.string()), {
102
+ description: 'Commands run last, always: settling what the fixers wrote (a formatter).',
103
+ }),
104
+ }), {
105
+ description: "How to fix a failure that is only a fixer's diff: a job that runs a command and then asserts a clean tree. Absent: a failure is never fixed, only reported.",
106
+ })),
107
+ }), {
108
+ title: 'unblock-prs configuration',
109
+ description: "What a repository says about itself in .github/unblock-prs.json: the parts of an unblock-prs run that depend on how its CI is laid out. Labels, Merge-After: and the version pull request's branch are fixed conventions, not set here.",
110
+ });
111
+ const exists = async (file) => Result.isOk(await Result.fromPromise(fs.access(file)));
112
+ const compile = (pattern) =>
113
+
114
+ Result.fromThrowable(() => new RegExp(pattern, 'u'));
115
+
116
+ const compileValid = (pattern) =>
117
+
118
+ new RegExp(pattern, 'u');
119
+ //# sourceMappingURL=config.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.mjs","sourceRoot":"","sources":["../../src/unblock-prs/config.mts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC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CAAC,CAAC,QAAQ,CAAC,KAAK,EAAE,EAAE;gBAC3B,WAAW,EACT,qDAAqD;aACxD,CAAC;YACF,GAAG,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE;gBAC1B,WAAW,EACT,6EAA6E;aAChF,CAAC;YACF,KAAK,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE;gBAC5B,WAAW,EACT,wDAAwD;aAC3D,CAAC;SACH,CAAC,CACH,EACD;YACE,WAAW,EACT,mHAAmH;SACtH,CACF;QACD,KAAK,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE;YACrC,WAAW,EACT,0EAA0E;SAC7E,CAAC;KACH,CAAC,EACF;QACE,WAAW,EACT,6JAA6J;KAChK,CACF,CACF;CACF,CAAC,EACF;IACE,KAAK,EAAE,2BAA2B;IAClC,WAAW,EACT,yOAAyO;CAC5O,CACF,CAAC;AAgBF,MAAM,MAAM,GAAG,KAAK,EAAE,IAAY,EAAoB,EAAE,CACtD,MAAM,CAAC,IAAI,CAAC,MAAM,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAEzD,MAAM,OAAO,GAAG,CAAC,OAAe,EAA2B,EAAE;AAC3D,oGAAoG;AACpG,MAAM,CAAC,aAAa,CAAC,GAAG,EAAE,CAAC,IAAI,MAAM,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC;AAEvD,6DAA6D;AAC7D,MAAM,YAAY,GAAG,CAAC,OAAe,EAAU,EAAE;AAC/C,oGAAoG;AACpG,IAAI,MAAM,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC"}
@@ -0,0 +1,28 @@
1
+ /** How long the loop waits, and how long it waits before giving up. */
2
+ /** How many times to re-list while GitHub still reports `UNKNOWN`. */
3
+ export declare const UNKNOWN_STATE_RETRIES = 6;
4
+ export declare const UNKNOWN_STATE_RETRY_MS = 10000;
5
+ /**
6
+ * How long to wait before surveying again after a rebase that changed
7
+ * nothing, which means the merge state the survey acted on was stale.
8
+ */
9
+ export declare const STALE_STATE_PAUSE_MS = 30000;
10
+ /**
11
+ * How many consecutive polls a pull request may sit with every required
12
+ * context green, and GitHub saying nothing holds the merge, before it is
13
+ * written off as held by something a rebase cannot fix. Triage keeps back
14
+ * the two such things it can read, a missing code-owner approval and an
15
+ * unresolved conversation, so this is what is left: auto-merge armed by
16
+ * someone who may not merge, or a rule nothing here reads.
17
+ */
18
+ export declare const GREEN_POLLS_BEFORE_GIVING_UP = 3;
19
+ /**
20
+ * The same, for a pull request GitHub still calls `BLOCKED` while every
21
+ * required context reads green. That usually means the ruleset wants
22
+ * something the checks do not cover, but it is also what a check run that has
23
+ * just been superseded looks like for a moment, so it is given longer.
24
+ */
25
+ export declare const BLOCKED_GREEN_POLLS_BEFORE_GIVING_UP = 8;
26
+ /** How many consecutive polling errors end a watch. */
27
+ export declare const MAX_CONSECUTIVE_POLL_ERRORS = 5;
28
+ //# sourceMappingURL=constants.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.mts","sourceRoot":"","sources":["../../src/unblock-prs/constants.mts"],"names":[],"mappings":"AAAA,uEAAuE;AAEvE,sEAAsE;AACtE,eAAO,MAAM,qBAAqB,IAAI,CAAC;AAEvC,eAAO,MAAM,sBAAsB,QAAS,CAAC;AAE7C;;;GAGG;AACH,eAAO,MAAM,oBAAoB,QAAS,CAAC;AAE3C;;;;;;;GAOG;AACH,eAAO,MAAM,4BAA4B,IAAI,CAAC;AAE9C;;;;;GAKG;AACH,eAAO,MAAM,oCAAoC,IAAI,CAAC;AAEtD,uDAAuD;AACvD,eAAO,MAAM,2BAA2B,IAAI,CAAC"}
@@ -0,0 +1,28 @@
1
+
2
+
3
+ export const UNKNOWN_STATE_RETRIES = 6;
4
+ export const UNKNOWN_STATE_RETRY_MS = 10_000;
5
+
6
+
7
+
8
+
9
+ export const STALE_STATE_PAUSE_MS = 30_000;
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+ export const GREEN_POLLS_BEFORE_GIVING_UP = 3;
19
+
20
+
21
+
22
+
23
+
24
+
25
+ export const BLOCKED_GREEN_POLLS_BEFORE_GIVING_UP = 8;
26
+
27
+ export const MAX_CONSECUTIVE_POLL_ERRORS = 5;
28
+ //# sourceMappingURL=constants.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.mjs","sourceRoot":"","sources":["../../src/unblock-prs/constants.mts"],"names":[],"mappings":"AAAA,uEAAuE;AAEvE,sEAAsE;AACtE,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAEvC,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC;AAE7C;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC;AAE3C;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,CAAC;AAE9C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,oCAAoC,GAAG,CAAC,CAAC;AAEtD,uDAAuD;AACvD,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * The pull requests picked last: ones a watch saw green and still open, held
3
+ * by something no check reports and triage could not name.
4
+ *
5
+ * `pr-report-core`'s `review-hold.mts` keeps the causes it can read — an
6
+ * owner's approval, an unresolved conversation — from being picked at all. What
7
+ * is left is a pull request whose checks all passed and which did not merge for
8
+ * a reason nothing here can see, and the likeliest thing about it is that it
9
+ * will not merge next time either. A `not-merging` skip record already keeps it
10
+ * from being picked until the base moves; the base moving is what makes it
11
+ * `BEHIND` again, and without this it would then be rebased first, run a full
12
+ * matrix, and sit green once more ahead of everything behind it.
13
+ *
14
+ * So it is picked after everything else, the version pull request included,
15
+ * rather than not at all: a demotion is a guess, and the guess is wrong for
16
+ * a pull request that was waiting on something which has since cleared.
17
+ */
18
+ import type { Demotions, PullRequest, WatchOutcome } from './types.mjs';
19
+ /**
20
+ * Whether the pull request is demoted. A head other than the one recorded is
21
+ * someone else's push — this run's own pushes move the record with them, see
22
+ * {@link followHead} — and a push is the author doing something about it.
23
+ */
24
+ export declare const isDemoted: (demoted: Demotions, pr: PullRequest) => boolean;
25
+ /**
26
+ * What a watch that ended on `head` leaves demoted: the pull request itself
27
+ * if it sat green without merging, and otherwise whatever was demoted before,
28
+ * carried to the head the watch ended on.
29
+ */
30
+ export declare const afterWatch: (demoted: Demotions, prNumber: number, head: string, outcome: WatchOutcome) => Demotions;
31
+ /**
32
+ * Carries a demotion to a head this run pushed. A rebase is not the author
33
+ * doing anything, so it must not read as one on the next survey.
34
+ */
35
+ export declare const followHead: (demoted: Demotions, prNumber: number, head: string) => Demotions;
36
+ /**
37
+ * Drops demotions of pull requests that are gone or that someone else has
38
+ * pushed to. The base moving is deliberately not among them — see the top
39
+ * of this file.
40
+ */
41
+ export declare const pruneDemotions: (demoted: Demotions, pullRequests: readonly PullRequest[]) => Demotions;
42
+ //# sourceMappingURL=demotions.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"demotions.d.mts","sourceRoot":"","sources":["../../src/unblock-prs/demotions.mts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAExE;;;;GAIG;AACH,eAAO,MAAM,SAAS,YAAa,SAAS,MAAM,WAAW,KAAG,OACtB,CAAC;AAE3C;;;;GAIG;AACH,eAAO,MAAM,UAAU,YACZ,SAAS,YACR,MAAM,QACV,MAAM,WACH,YAAY,KACpB,SAGsC,CAAC;AAE1C;;;GAGG;AACH,eAAO,MAAM,UAAU,YACZ,SAAS,YACR,MAAM,QACV,MAAM,KACX,SACwE,CAAC;AAE5E;;;;GAIG;AACH,eAAO,MAAM,cAAc,YAChB,SAAS,gBACJ,SAAS,WAAW,EAAE,KACnC,SASA,CAAC"}
@@ -0,0 +1,50 @@
1
+
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+ import { Arr } from 'ts-data-forge';
19
+
20
+
21
+
22
+
23
+
24
+ export const isDemoted = (demoted, pr) => demoted.get(pr.number) === pr.headRefOid;
25
+
26
+
27
+
28
+
29
+
30
+ export const afterWatch = (demoted, prNumber, head, outcome) => outcome === 'not-merging'
31
+ ? new Map([...demoted, [prNumber, head]])
32
+ : followHead(demoted, prNumber, head);
33
+
34
+
35
+
36
+
37
+ export const followHead = (demoted, prNumber, head) => demoted.has(prNumber) ? new Map([...demoted, [prNumber, head]]) : demoted;
38
+
39
+
40
+
41
+
42
+
43
+ export const pruneDemotions = (demoted, pullRequests) => new Map(Arr.generate(function* () {
44
+ for (const pr of pullRequests) {
45
+ if (isDemoted(demoted, pr)) {
46
+ yield [pr.number, pr.headRefOid];
47
+ }
48
+ }
49
+ }));
50
+ //# sourceMappingURL=demotions.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"demotions.mjs","sourceRoot":"","sources":["../../src/unblock-prs/demotions.mts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAGpC;;;;GAIG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,OAAkB,EAAE,EAAe,EAAW,EAAE,CACxE,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,UAAU,CAAC;AAE3C;;;;GAIG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CACxB,OAAkB,EAClB,QAAgB,EAChB,IAAY,EACZ,OAAqB,EACV,EAAE,CACb,OAAO,KAAK,aAAa;IACvB,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,OAAO,E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