fix(source-control): keep distinct CI checks with overlapping names (#19162)
Co-authored-by: Simone <[email protected]>
This commit is contained in:
1 parent
573cec0166
commit
5e5c52b7a7
2 files changed
+23
-1
No files matched your search
@@ -50,6 +50,28 @@ describe("dedupeChecks", () => {
|
||||
]);
|
||||
});
|
||||
|
||||
it("keeps distinct workflow and check pairs even when their names join to the same text", () => {
|
||||
const checks = dedupeChecks([
|
||||
entry("Linux tests", "success", {
|
||||
workflowName: "Build",
|
||||
at: "2026-08-11T16:00:00Z",
|
||||
}),
|
||||
entry("tests", "success", {
|
||||
workflowName: "Build Linux",
|
||||
at: "2026-08-11T17:00:00Z",
|
||||
}),
|
||||
entry("Linux tests", "failure", {
|
||||
workflowName: "Build",
|
||||
at: "2026-08-11T18:00:00Z",
|
||||
}),
|
||||
]);
|
||||
|
||||
expect(checks.map((check) => [check.name, check.status])).toEqual([
|
||||
["Linux tests", "failure"],
|
||||
["tests", "success"],
|
||||
]);
|
||||
});
|
||||
|
||||
it("loses a run that never said when it happened to one that did, whichever came first", () => {
|
||||
const undated = dedupeChecks([
|
||||
entry("build", "success", { at: "2026-08-11T16:00:00Z" }),
|
||||
|
||||
@@ -36,7 +36,7 @@ export function dedupeChecks(
|
||||
): ReadonlyArray<PullRequestCheck> {
|
||||
const newestByCheck = new Map<string, (typeof entries)[number]>();
|
||||
for (const entry of entries) {
|
||||
const key = `${entry.workflowName ?? ""} ${entry.check.name}`;
|
||||
const key = JSON.stringify([entry.workflowName ?? "", entry.check.name]);
|
||||
const kept = newestByCheck.get(key);
|
||||
// Re-setting a key a Map already holds keeps its first position, which is the order wanted.
|
||||
if (kept === undefined || isAtLeastAsNew(entry.at, kept.at)) newestByCheck.set(key, entry);
|
||||
|
||||
Reference in new issue
Block a user