Skip to content

Commit 6ed23cf

Browse files
fix: match existing, prefixed labels in setup (#530)
## PR Checklist - [x] Addresses an existing open issue: fixes #529 - [x] That issue was marked as [`status: accepting prs`](https://github.com/JoshuaKGoldberg/template-typescript-node-package/issues?q=is%3Aopen+is%3Aissue+label%3A%22status%3A+accepting+prs%22) - [x] Steps in [CONTRIBUTING.md](https://github.com/JoshuaKGoldberg/template-typescript-node-package/blob/main/.github/CONTRIBUTING.md) were taken ## Overview Fixes the `.find` logic to match on an aliased or prefixed label.
1 parent a5f7bec commit 6ed23cf

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

src/setup/settings/addOwnerAsAllContributor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export async function addOwnerAsAllContributor(owner: string) {
2222
user = owner;
2323
}
2424

25-
await $`npx -y all-contributors-cli add ${user} ${[
25+
await $`npx -y all-contributors-cli@6.25 add ${user} ${[
2626
"code",
2727
"content",
2828
"doc",

src/setup/steps/labels/getExistingEquivalentLabel.test.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,18 @@ describe("getExistingEquivalentLabel", () => {
1515
expect(actual).toBe(undefined);
1616
});
1717

18-
it("returns the existing label when it matches by name", () => {
18+
it("returns an existing un-prefixed label when it matches by name", () => {
1919
const actual = getExistingEquivalentLabel(["def", "abc", "ghi"], "abc");
2020

2121
expect(actual).toBe("abc");
2222
});
2323

24+
it("returns an existing prefixed label when it matches by name", () => {
25+
const actual = getExistingEquivalentLabel(["abc: def"], "abc: def");
26+
27+
expect(actual).toBe("abc: def");
28+
});
29+
2430
it("returns the existing label when it matches excluding prefix", () => {
2531
const actual = getExistingEquivalentLabel(
2632
["abc: def", "abc", "ghi"],

src/setup/steps/labels/getExistingEquivalentLabel.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@ export function getExistingEquivalentLabel(
99
) {
1010
const outcomeTrimmed = outcomeLabel.replace(/\w+: (\w+)/, "$1");
1111

12-
return existingLabels.find(
13-
(existingLabel) =>
14-
aliases.has(existingLabel) || existingLabel === outcomeTrimmed
15-
);
12+
return existingLabels.find((existingLabel) => {
13+
return (
14+
existingLabel === outcomeLabel ||
15+
existingLabel === outcomeTrimmed ||
16+
aliases.get(existingLabel) === outcomeLabel
17+
);
18+
});
1619
}

0 commit comments

Comments
 (0)