Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/signals/contributor-open-pr-monitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ function duplicatePronePullNumbers(openPullRequests: PullRequestRecord[]): Set<n
const byNormalizedTitle = new Map<string, PullRequestRecord[]>();
for (const pr of openPullRequests) {
const key = normalizeTitle(pr.title);
if (!key) continue;
const bucket = byNormalizedTitle.get(key) ?? [];
bucket.push(pr);
byNormalizedTitle.set(key, bucket);
Expand Down
32 changes: 32 additions & 0 deletions test/unit/contributor-open-pr-monitor-empty-title.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { describe, expect, it } from "vitest";
import { __contributorOpenPrMonitorInternals } from "../../src/signals/contributor-open-pr-monitor";
import type { PullRequestRecord } from "../../src/types";

function pr(number: number, title: string, labels: string[] = []): PullRequestRecord {
return {
repoFullName: "acme/widgets",
number,
title,
state: "open",
authorLogin: "contributor",
labels,
linkedIssues: [],
} as PullRequestRecord;
}

describe("duplicate-prone title grouping", () => {
it("does not group unrelated titles whose normalized form is empty", () => {
const flagged = __contributorOpenPrMonitorInternals.duplicatePronePullNumbers([pr(1, "..."), pr(2, "🎉🎉🎉")]);
expect([...flagged]).toEqual([]);
});

it("still groups matching non-empty normalized titles", () => {
const flagged = __contributorOpenPrMonitorInternals.duplicatePronePullNumbers([pr(3, "Fix bug"), pr(4, "fix bug!!")]);
expect([...flagged].sort((a, b) => a - b)).toEqual([3, 4]);
});

it("still flags explicit wip and duplicate labels", () => {
const flagged = __contributorOpenPrMonitorInternals.duplicatePronePullNumbers([pr(5, "...", ["wip"]), pr(6, "🎉", ["duplicate"])]);
expect([...flagged].sort((a, b) => a - b)).toEqual([5, 6]);
});
});
Loading