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

Function buildApplyEvent

src/repair/notify-events.ts:149–224  ·  view source on GitHub ↗
(row: JsonObject)

Source from the content-addressed store, hash-verified

147}
148
149export function buildApplyEvent(row: JsonObject): ClawSweeperEvent | null {
150 const action = stringOrNull(row.action);
151 const status = stringOrNull(row.status);
152 const repo = stringOrNull(row.repo);
153 if (!action || !status || !repo) return null;
154
155 const reason = stringOrNull(row.reason);
156 const target = normalizeTarget(row.target);
157 const title = stringOrNull(row.title);
158 const runId = stringOrNull(row.run_id);
159 const runUrl = stringOrNull(row.run_url);
160 const clusterId = stringOrNull(row.cluster_id);
161 const publishedAt = stringOrNull(row.published_at);
162 const commit = stringOrNull(row.merge_commit_sha);
163 const base = {
164 repo,
165 target,
166 title,
167 runId,
168 runUrl,
169 clusterId,
170 publishedAt,
171 action,
172 status,
173 reason,
174 };
175
176 if (MERGE_ACTIONS.has(action)) {
177 if (status === "executed") {
178 if (reason?.toLowerCase() === "already merged") return null;
179 return createEvent({
180 ...base,
181 type: "clawsweeper.pr_merged",
182 severity: "info",
183 url: target ? `https://github.com/${repo}/pull/${target.slice(1)}` : null,
184 discriminator: commit ?? stringOrNull(row.merged_at) ?? publishedAt ?? runId,
185 details: row,
186 });
187 }
188 if (["blocked", "failed"].includes(status)) {
189 return createEvent({
190 ...base,
191 type: "clawsweeper.merge_blocked",
192 severity: status === "failed" ? "error" : "warning",
193 url: target ? `https://github.com/${repo}/pull/${target.slice(1)}` : null,
194 discriminator: reason ?? publishedAt ?? runId,
195 details: row,
196 });
197 }
198 }
199
200 if (CLOSE_ACTIONS.has(action)) {
201 if (status === "executed") {
202 return createEvent({
203 ...base,
204 type: "clawsweeper.item_closed",
205 severity: "info",
206 url: target ? `https://github.com/${repo}/issues/${target.slice(1)}` : null,

Callers 2

collectClawSweeperEventsFunction · 0.85

Calls 4

normalizeTargetFunction · 0.85
createEventFunction · 0.85
hasMethod · 0.80
stringOrNullFunction · 0.70

Tested by

no test coverage detected