MCPcopy
hub / github.com/openclaw/clawsweeper / validatePrCloseCoverageCoveringRefSafety

Function validatePrCloseCoverageCoveringRefSafety

src/repair/apply-result.ts:1031–1074  ·  view source on GitHub ↗
({
  result,
  actionName,
  target,
  live,
  canonical,
  candidateFix,
  classification,
}: LooseRecord)

Source from the content-addressed store, hash-verified

1029}
1030
1031function validatePrCloseCoverageCoveringRefSafety({
1032 result,
1033 actionName,
1034 target,
1035 live,
1036 canonical,
1037 candidateFix,
1038 classification,
1039}: LooseRecord): PrCloseCoverageProofBlock | null {
1040 const coveringRef = prCloseCoverageProofCoveringRef({
1041 actionName,
1042 classification,
1043 canonical,
1044 candidateFix,
1045 });
1046 if (!coveringRef || coveringRef === target || !live.pull_request) return null;
1047
1048 try {
1049 const coveringIssue = fetchIssue(result.repo, coveringRef);
1050 if (!coveringIssue.pull_request) return null;
1051 const coveringPull = fetchPullRequest(result.repo, coveringRef);
1052 const covering = {
1053 state:
1054 stringFromUnknown(coveringPull.state) ||
1055 stringFromUnknown(coveringIssue.state) ||
1056 "unknown",
1057 mergedAt: stringOrNull(coveringPull.merged_at ?? coveringPull.mergedAt),
1058 };
1059 if (!prCloseCoverageProofCandidateCanClose(covering)) {
1060 return {
1061 reason: `PR close coverage proof requires an open or merged covering pull request; #${coveringRef} is ${covering.state}`,
1062 };
1063 }
1064 const coveringSafetyBlock = validatePrCloseCoverageCoveringSafety({
1065 result,
1066 coveringRef,
1067 coveringIssue,
1068 covering,
1069 });
1070 return coveringSafetyBlock ? { reason: coveringSafetyBlock } : null;
1071 } catch (error) {
1072 return prCloseCoverageProofFailureBlock(error);
1073 }
1074}
1075
1076function prCloseCoverageProofFailureReason(error: unknown): string {
1077 return `PR close coverage proof failed: ${error instanceof Error ? error.message : String(error)}`;

Callers 1

applyCloseActionFunction · 0.85

Calls 8

fetchIssueFunction · 0.70
fetchPullRequestFunction · 0.70
stringFromUnknownFunction · 0.70
stringOrNullFunction · 0.70

Tested by

no test coverage detected