@intentius/chant 0.124.42 → 0.124.44

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.
@@ -4,14 +4,16 @@
4
4
  * asked of the forge through its {@link PrForge} method. All four must pass.
5
5
  *
6
6
  * The checks are terragucci's `apply.requires` (comment-apply.ts:781-860 at
7
- * INTENTIUS/terragucci e6cb431), with no setting to drop one. A check the
7
+ * INTENTIUS/terragucci e6cb431). A product may leave one out with `only`
8
+ * (#4336); chant's own `pr-apply --before-merge` passes no `only`, so it asks
9
+ * all four, as ws-106 requires. A check the
8
10
  * forge has not settled, such as GitHub working out whether a pull request
9
11
  * can merge, is asked again a few times before it counts as unmet.
10
12
  *
11
13
  * Like ./pr-forge.ts this imports nothing beyond it, so a product bundles it
12
14
  * without the TypeScript toolchain.
13
15
  */
14
- import type { PrForge, PrRequireResult } from "./pr-forge";
16
+ import type { PrApproverFilter, PrForge, PrRequireResult } from "./pr-forge";
15
17
 
16
18
  /** The four checks, in the order they run and the report lists them. */
17
19
  export const PR_APPLY_REQUIRES = ["approved", "mergeable", "undiverged", "checks"] as const;
@@ -24,6 +26,13 @@ export interface PrRequireOutcome extends PrRequireResult {
24
26
  }
25
27
 
26
28
  export interface PrRequiresOptions {
29
+ /**
30
+ * The checks to ask (#4336). One left out passes with the reason "not
31
+ * required" and makes no forge call. Default: all four.
32
+ */
33
+ only?: readonly PrApplyRequire[];
34
+ /** Who counts as an approver for `approved` (#4337). Default: anyone other than the authors. */
35
+ approvers?: PrApproverFilter;
27
36
  /** Status names the `checks` require leaves out: the apply's own. */
28
37
  ignore?: readonly string[];
29
38
  /** How many times a pending check is asked in all. Default 5. */
@@ -44,13 +53,18 @@ export async function checkPrRequires(forge: PrForge, pr: number, head: string,
44
53
  const wait = opts.wait ?? ((ms: number) => new Promise<void>((r) => setTimeout(r, ms)));
45
54
  const reads = Math.max(1, opts.reads ?? READS);
46
55
  const ask: Record<PrApplyRequire, (() => Promise<PrRequireResult>) | undefined> = {
47
- approved: forge.prApproved ? () => forge.prApproved!(pr, head) : undefined,
56
+ approved: forge.prApproved ? () => forge.prApproved!(pr, head, opts.approvers) : undefined,
48
57
  mergeable: forge.prMergeable ? () => forge.prMergeable!(pr, head) : undefined,
49
58
  undiverged: forge.prUndiverged ? () => forge.prUndiverged!(pr, head) : undefined,
50
59
  checks: forge.prChecksPassed ? () => forge.prChecksPassed!(pr, head, opts.ignore ?? []) : undefined,
51
60
  };
52
61
  const out: PrRequireOutcome[] = [];
62
+ const asked = new Set<PrApplyRequire>(opts.only ?? PR_APPLY_REQUIRES);
53
63
  for (const name of PR_APPLY_REQUIRES) {
64
+ if (!asked.has(name)) {
65
+ out.push({ name, passed: true, reason: "not required" });
66
+ continue;
67
+ }
54
68
  const call = ask[name];
55
69
  if (!call) {
56
70
  out.push({ name, passed: false, reason: `this ${forge.kind} client cannot say` });