(options: {
dispatch: CommitFindingDispatch;
mode: string;
reportRepo: string;
repairRepo: string;
workflow: string;
})
| 807 | } |
| 808 | |
| 809 | function dispatchCommitFinding(options: { |
| 810 | dispatch: CommitFindingDispatch; |
| 811 | mode: string; |
| 812 | reportRepo: string; |
| 813 | repairRepo: string; |
| 814 | workflow: string; |
| 815 | }): void { |
| 816 | const commandArgs = |
| 817 | options.mode === "repository_dispatch" |
| 818 | ? ["api", `repos/${options.repairRepo}/dispatches`, "--method", "POST", "--input", "-"] |
| 819 | : workflowDispatchArgs(options.dispatch, options.reportRepo, options.workflow).map((arg) => |
| 820 | arg === "PLACEHOLDER" ? options.repairRepo : arg, |
| 821 | ); |
| 822 | const maxAttempts = 3; |
| 823 | for (let attempt = 0; attempt < maxAttempts; attempt++) { |
| 824 | const result = spawnSync("gh", commandArgs, { |
| 825 | input: |
| 826 | options.mode === "repository_dispatch" |
| 827 | ? dispatchPayload(options.dispatch, options.reportRepo) |
| 828 | : undefined, |
| 829 | encoding: "utf8", |
| 830 | env: process.env, |
| 831 | }); |
| 832 | if (result.status === 0) return; |
| 833 | |
| 834 | const error = dispatchFailureError(options, result); |
| 835 | const retryKind = ghRetryKind(error); |
| 836 | if (attempt >= maxAttempts - 1 || retryKind === "none") throw error; |
| 837 | |
| 838 | const waitMs = ghRetryWaitMs(retryKind, attempt); |
| 839 | console.warn( |
| 840 | `dispatch failed with ${retryKind} GitHub error; retrying in ${Math.round(waitMs / 1000)}s`, |
| 841 | ); |
| 842 | sleepSync(waitMs); |
| 843 | } |
| 844 | } |
| 845 | |
| 846 | function dispatchFindingsCommand(args: Args): void { |
| 847 | const enabled = argString(args, "enabled", "true"); |
no test coverage detected